Home

OS upgrades

When pods are drained, they are gracefully terminated on the node they are on and recreated on another.

//kubectl drain node-1 //kubectl drain node01 –ignore-daemonsets

The node is marked unschedulable. No pod can be placed until manually turned to schedulable.

When the node comes online, it needs to be scheduled

//kubectl uncordon node-1

//marks a node unchedulable. It doesn't get terminated though //kubectl cordon node-1

Kubernetes software versions

V major.minor.patch v.1.11.3

kube-apiserver, controller-manager, kube-scheduler, kubelet, kube-proxy, kubectl have same version numbers

ETCD Cluster and CoreDNS have different versions

Reference: https://kubernetes.io/docs/concepts/overview/kubernetes-api/

Here is a link to kubernetes documentation if you want to learn more about this topic (You don’t need it for the exam though):

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md

Cluster Upgrade

Kube-apiserver X v1.10

Control-manager X-1 v1.9, v1.10 kube-scheduler X-1 v1.9, v1.10

Kubelet X-2 v1.8, v1.9, v1.10 Kube-proxy X-2 v1.8, v1.9, v1.10

Kubelet X+1>X-1 v1.9, v1.10, v1.11

Recommended to upgrade the cluster, one minor version at a time.

First, upgrade the master node and then the worker When the master node is upgraded, the controlplane componenet such as the api-server, scheduler and controller-manager go down briefly.

If a pod fails at this moment, new pods will not be created.

Strategy 1: upgrade all worker nodes. Requires downtime

Strategy II: We upgrade one node at a time where the workload are shared with other nodes.

Strategy III: add new upgraded node to the cluster.

//Kubeadm upgrade

//kubeadm upgrade plan //update the kubeadm first //next upgrade the kubelets which kubeadm doesn't do

Steps: //drain the node //kubectl drain node-1 –ignore-daemonsets //enter the node //apt-get upgrade -y kubeadm=1.12.0-00 //apt-get upgrade -y kubelet=1.12.0-00 //kubeadm upgrade node config –kubelet-version v1.12.0 //sysctl restart kubelet //kubectl uncordon node-1

Backup and Restore

Resource Configuration: application, pods, service, deployment files Declarative -> Move to source control Imperative -> Request kubeapi-server for all configuration files created on the cluster // kubesctl get all -all-namspace -o yaml > all-deploy-services.yaml

//Use Velero by HeptIO

ETCD Cluster: Cluster-related state info

STCD is installed on the master node, the data directory mentioned in the etcd configuration file can be backed up.

//snapshot command //ETCDCTL_API=3 ectdctl snapshot save snapshot.db //status of the backup //ETCDCTL_API=3 etcdctl snapshot status snapshot.db

//restoring from the etcd snapshot // stop kubeapi server // service kube-apiserver stop //ETCDCTL_API=3 etcdctl snapshot restore snaphot.db –data-dir /path-of-backup //systemctl daemon-reload //service etcd restart //service kube-apiserver restart

//export ETCDCTL_API=3

ETCDCTL_API=3 etcdctl --endpoints=https://[127.0.0.1]:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
snapshot save /opt/snapshot-pre-boot.db

//Restore

ETCDCTL_API=3 etcdctl  --data-dir /var/lib/etcd-from-backup \
snapshot restore /opt/snapshot-pre-boot.db

Persistent Volume: