# Bootstrapping the Kubernetes Control Plane In this chapter, you will bootstrap the Kubernetes control plane across three virtual machines and configure it for high availability. You will also create an load balancer that exposes the Kubernetes API Servers to remote clients. The following components will be installed on each node: Kubernetes API Server, Scheduler, and Controller Manager. ## Prerequisites The commands in this lab must be run on each controller node: `controller-1`, `controller-2`, and `controller-3`. Login to each controller node: ``` $ ssh -i ~/.ssh/id_rsa-k8s 10.240.0.11 ``` ### Running commands in parallel with tmux [tmux](https://github.com/tmux/tmux/wiki) can be used to run commands on multiple compute instances at the same time. See the [Running commands in parallel with tmux](01-prerequisites.md#running-commands-in-parallel-with-tmux) section in the Prerequisites lab. ## Provision the Kubernetes Control Plane Create the Kubernetes configuration directory: ``` $ sudo mkdir -p /etc/kubernetes/config ``` ### Download and Install the Kubernetes Controller Binaries Download the official Kubernetes release binaries: ``` $ wget -q --show-progress --https-only --timestamping \ "https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kube-apiserver" \ "https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kube-controller-manager" \ "https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kube-scheduler" \ "https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl" ``` Install the Kubernetes binaries: ``` $ { chmod +x kube-apiserver kube-controller-manager kube-scheduler kubectl sudo mv kube-apiserver kube-controller-manager kube-scheduler kubectl /usr/local/bin/ } ``` ### Configure the Kubernetes API Server ``` $ { sudo mkdir -p /var/lib/kubernetes/ sudo mv ca.pem ca-key.pem kubernetes-key.pem kubernetes.pem \ service-account-key.pem service-account.pem \ encryption-config.yaml /var/lib/kubernetes/ } ``` The instance internal IP address will be used to advertise the API Server to members of the cluster. Get the internal IP address for the current compute instance: ``` $ INTERNAL_IP=$(ip a s | grep 'inet 10' | awk '{ print $2 }' | awk -F"/" '{ print $1 }') ``` Create the `kube-apiserver.service` systemd unit file: ``` $ cat < Allow up to 10 seconds for the Kubernetes API Server to fully initialize. ### Verification ``` $ kubectl get componentstatuses --kubeconfig admin.kubeconfig ``` ``` NAME STATUS MESSAGE ERROR controller-manager Healthy ok scheduler Healthy ok etcd-2 Healthy {"health": "true"} etcd-0 Healthy {"health": "true"} etcd-1 Healthy {"health": "true"} ``` ## RBAC for Kubelet Authorization In this section you will configure RBAC permissions to allow the Kubernetes API Server to access the Kubelet API on each worker node. Access to the Kubelet API is required for retrieving metrics, logs, and executing commands in pods. > This tutorial sets the Kubelet `--authorization-mode` flag to `Webhook`. Webhook mode uses the [SubjectAccessReview](https://kubernetes.io/docs/admin/authorization/#checking-api-access) API to determine authorization. ``` $ ssh -i ~/.ssh/id_rsa-k8s.pub 10.240.0.11 ``` Create the `system:kube-apiserver-to-kubelet` [ClusterRole](https://kubernetes.io/docs/admin/authorization/rbac/#role-and-clusterrole) with permissions to access the Kubelet API and perform most common tasks associated with managing pods: ``` $ cat < output ``` { "major": "1", "minor": "12", "gitVersion": "v1.12.0", "gitCommit": "0ed33881dc4355495f623c6f22e7dd0b7632b7c0", "gitTreeState": "clean", "buildDate": "2018-09-27T16:55:41Z", "goVersion": "go1.10.4", "compiler": "gc", "platform": "linux/amd64" } ``` Next: [Bootstrapping the Kubernetes Worker Nodes](09-bootstrapping-kubernetes-workers.md)