Skip to content

Latest commit

 

History

History
170 lines (120 loc) · 4.84 KB

tasks.adoc

File metadata and controls

170 lines (120 loc) · 4.84 KB

Tasks

Install Tools

Administer a Cluster

Administration with kubeadm

Certificate Management with kubeadm
Upgrading kubeadm clusters

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

Access Applications in a Cluster

Web UI (Dashboard)

Steps to setup env

Creating a cluster with kubeadm

Environment:

cd labs/bootstrap
docker-compose -f 1node.yaml up

Setup

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

Verify

# make pods can be scheduled to master node
kubectl taint nodes --all node-role.kubernetes.io/master-
kubectl create deployment nginx --image=nginx --port 80
kubectl expose deployment nginx
kubectl run tmp-$RANDOM --image=alpine --restart=Never --rm -it -- wget -qO- nginx

Creating Highly Available clusters with kubeadm — external etcd

setup etcd cluster:

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

Set up the first control plane node

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

Creating Highly Available clusters with kubeadm

Env

cd labs/bootstrap
docker-compose -f lb.yaml up -d

Steps

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

Upgrade cluster

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