diff --git a/docs/08-bootstrapping-kubernetes-controllers.md b/docs/08-bootstrapping-kubernetes-controllers.md index ede6ce0..b045ec1 100644 --- a/docs/08-bootstrapping-kubernetes-controllers.md +++ b/docs/08-bootstrapping-kubernetes-controllers.md @@ -4,12 +4,24 @@ In this lab you will bootstrap the Kubernetes control plane across three compute ## Prerequisites -The commands in this lab must be run on each controller instance: `controller-0`, `controller-1`, and `controller-2`. Login to each controller instance using the `gcloud` command. Example: +The commands in this lab must be run on each controller instance: `controller-0`, `controller-1`, and `controller-2`. Login to each controller instance: +```gcloud``` ``` gcloud compute ssh controller-0 ``` +```az``` +``` +az ssh vm --name controller-0 --local-user azureuser +``` + +OR + +``` +ssh -i $HOME/.ssh/k8sthehardway azureuser@$(az vm show -d --name controller-0 --query "publicIps" -o tsv) +``` + ### 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. @@ -37,42 +49,42 @@ wget -q --show-progress --https-only --timestamping \ 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/ -} +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. Retrieve the internal IP address for the current compute instance: +```gcloud``` ``` INTERNAL_IP=$(curl -s -H "Metadata-Flavor: Google" \ http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip) -``` - -``` REGION=$(curl -s -H "Metadata-Flavor: Google" \ http://metadata.google.internal/computeMetadata/v1/project/attributes/google-compute-default-region) -``` - -``` KUBERNETES_PUBLIC_ADDRESS=$(gcloud compute addresses describe kubernetes-the-hard-way \ --region $REGION \ --format 'value(address)') ``` +```az``` +``` +sudo apt-get update +sudo apt-get install -y jq +INTERNAL_IP=$(curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq -r '.network.interface[0].ipv4.ipAddress[0].privateIpAddress') +REGION=$(curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq -r '.compute.location') +KUBERNETES_PUBLIC_ADDRESS=$(az network public-ip show --name kubernetes-the-hard-way --query ipAddress -o tsv) +``` + Create the `kube-apiserver.service` systemd unit file: ``` @@ -202,11 +214,9 @@ EOF ### Start the Controller Services ``` -{ - sudo systemctl daemon-reload - sudo systemctl enable kube-apiserver kube-controller-manager kube-scheduler - sudo systemctl start kube-apiserver kube-controller-manager kube-scheduler -} +sudo systemctl daemon-reload +sudo systemctl enable kube-apiserver kube-controller-manager kube-scheduler +sudo systemctl start kube-apiserver kube-controller-manager kube-scheduler ``` > Allow up to 10 seconds for the Kubernetes API Server to fully initialize.