# Bootstrapping the Kubernetes Control Plane In this lab you will bootstrap the Kubernetes control plane across 2 compute instances and configure it for high availability. You will also create an external 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 instance: `master-1`, and `master-2`. Login to each controller instance using SSH Terminal. Example: ### 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.13.0/bin/linux/amd64/kube-apiserver" \ "https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/amd64/kube-controller-manager" \ "https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/amd64/kube-scheduler" \ "https://storage.googleapis.com/kubernetes-release/release/v1.13.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 cp ca.crt ca.key kube-apiserver.crt kube-apiserver.key \ service-account.key service-account.crt \ etcd-server.key etcd-server.crt \ encryption-config.yaml /var/lib/kubernetes/ } ``` The instance internal IP address will be used to advertise the API Server to members of the cluster. Retrieve the internal IP address for the current compute instance: ``` INTERNAL_IP=$(ip addr show enp0s8 | grep "inet " | awk '{print $2}' | cut -d / -f 1) ``` Verify it is set ``` echo $INTERNAL_IP ``` 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-0 Healthy {"health": "true"} etcd-1 Healthy {"health": "true"} ``` > Remember to run the above commands on each controller node: `master-1`, and `master-2`. ## The Kubernetes Frontend Load Balancer In this section you will provision an external load balancer to front the Kubernetes API Servers. The `kubernetes-the-hard-way` static IP address will be attached to the resulting load balancer. ### Provision a Network Load Balancer ``` #Install HAProxy sudo apt-get update && sudo apt-get install -y haproxy ``` ``` cat > /etc/haproxy/haproxy.cfg < output ``` { "major": "1", "minor": "13", "gitVersion": "v1.13.0", "gitCommit": "ddf47ac13c1a9483ea035a79cd7c10005ff21a6d", "gitTreeState": "clean", "buildDate": "2018-12-03T20:56:12Z", "goVersion": "go1.11.2", "compiler": "gc", "platform": "linux/amd64" } ``` Next: [Bootstrapping the Kubernetes Worker Nodes](09-bootstrapping-kubernetes-workers.md)