Tasks in https://kubernetes.io/docs/tasks/
The following script will setup a HA cluster (3 masters + 2 workers + 1 load balancer). The repository packages.cloud.google.com is setup. and kubeadm is installed as 1.19.5. /root/.kube is correctly configured.
./up.sh upgrade
Enter the nodes by running docker exec. Refer https://v1-19.docs.kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/ to for other upgrade steps.
docker exec -it kind-control-plane /bin/bash
Steps to setup env
-
minikube start --embed-certs (in windows)
-
kubectl proxy (in windows)
-
cat /mnt/c/Users/jackl/.kube/config > ~/.kube/config #in wsl
-
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
-
steps at https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md
-
in windows 10, browse http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/cronjob?namespace=default
Due to kindnet and the whole environment running in docker, there are some limitations. Running the following commands to setup the node
docker exec -it bootstrap_kind-control-plane_1 /bin/sh
#following commands are run in the above shell
kubeadm init --ignore-preflight-errors=all --pod-network-cidr=10.240.0.0/16
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f /kind/manifests/default-cni.yaml
kubectl apply -f /kind/manifests/default-storage.yaml
Copy the following files from any etcd node in the cluster to the first control plane node:
docker cp /home/jack/cert/etcd/172.19.1.2/pki bootstrap_kind-control-plane_1:/etc/kubernetes/pki
Create a file called kubeadm-config.yaml with the following scripts:
ETCD_0_IP=$(getent hosts etcd1 | awk '{print $1}')
ETCD_1_IP=$(getent hosts etcd2 | awk '{print $1}')
ETCD_2_IP=$(getent hosts etcd3 | awk '{print $1}')
LOAD_BALANCER_DNS=$(getent hosts haproxy | awk '{print $1}')
cat <<EOF | tee /root/kubeadm-config.yaml
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: stable
controlPlaneEndpoint: "${LOAD_BALANCER_DNS}:6443"
etcd:
external:
endpoints:
- https://${ETCD_0_IP}:2379
- https://${ETCD_1_IP}:2379
- https://${ETCD_2_IP}:2379
caFile: /etc/kubernetes/pki/etcd/ca.crt
certFile: /etc/kubernetes/pki/apiserver-etcd-client.crt
keyFile: /etc/kubernetes/pki/apiserver-etcd-client.key
EOF
kubeadm init --config kubeadm-config.yaml --upload-certs --ignore-preflight-errors=all0
following the instructions at https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/high-availability/
notice ignore-preflight-errors and pod-network-cidr.
kubeadm init --control-plane-endpoint "172.19.0.100:6443" --upload-certs \
--ignore-preflight-errors=all \
--pod-network-cidr=10.240.0.0/16
env:
./up.sh upgrade
Notice: during installing new version kubeadm even specified the version, seems kubelet and kubectl are updated into the latest version as well. To compensate this, pass the --allow-downgrades to apt install during installation of kubelet and kubectl
apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y --allow-downgrades kubelet=1.19.7-00 kubectl=1.19.7-00 && \
apt-mark hold kubelet kubectl