# Bootstrapping an H/A Kubernetes Control Plane In this lab you will bootstrap a 3 node Kubernetes controller cluster. The following virtual machines will be used: * controller0 * controller1 * controller2 In this lab you will also create a frontend load balancer with a public IP address for remote access to the API servers and H/A. ## Why The Kubernetes components that make up the control plane include the following components: * Kubernetes API Server * Kubernetes Scheduler * Kubernetes Controller Manager Each component is being run on the same machines for the following reasons: * The Scheduler and Controller Manager are tightly coupled with the API Server * Only one Scheduler and Controller Manager can be active at a given time, but it's ok to run multiple at the same time. Each component will elect a leader via the API Server. * Running multiple copies of each component is required for H/A * Running each component next to the API Server eases configuration. ## Setup Authentication and Authorization ### Authentication [Token based authentication](http://kubernetes.io/docs/admin/authentication) will be used to bootstrap the Kubernetes cluster. The authentication token is used by the following components: * kubelet (client) * Kubernetes API Server (server) The other components, mainly the `scheduler` and `controller manager`, access the Kubernetes API server locally over the insecure API port which does not require authentication. The insecure port is only enabled for local access. Generate a token: BOOTSTRAP_TOKEN=$(head -c 16 /dev/urandom | od -An -t x | tr -d ' ') Generate a token file: ``` cat > token.csv < bootstrap.kubeconfig < kube-apiserver.service < kube-controller-manager.service < kube-scheduler.service < Remember to run these steps on `controller0`, `controller1`, and `controller2` ## Setup Kubernetes API Server Frontend Load Balancer The virtual machines created in this tutorial will not have permission to complete this section. Run the following commands from the same place used to create the virtual machines for this tutorial. ### GCE ``` gcloud compute http-health-checks create kube-apiserver-check \ --description "Kubernetes API Server Health Check" \ --port 8080 \ --request-path /healthz ``` ``` gcloud compute target-pools create kubernetes-pool \ --http-health-check=kube-apiserver-check ``` ``` gcloud compute target-pools add-instances kubernetes-pool \ --instances controller0,controller1,controller2 ``` ``` KUBERNETES_PUBLIC_ADDRESS=$(gcloud compute addresses describe kubernetes \ --format 'value(address)') ``` ``` gcloud compute forwarding-rules create kubernetes-rule \ --address ${KUBERNETES_PUBLIC_ADDRESS} \ --ports 6443 \ --target-pool kubernetes-pool ``` ### AWS ``` aws elb register-instances-with-load-balancer \ --load-balancer-name kubernetes \ --instances ${CONTROLLER_0_INSTANCE_ID} ${CONTROLLER_1_INSTANCE_ID} ${CONTROLLER_2_INSTANCE_ID} ``` ## RBAC Set up bootstrapping roles: ``` kubectl create clusterrolebinding kubelet-bootstrap \ --clusterrole=system:node-bootstrapper \ --user=kubelet-bootstrap ```