Skip to content

Latest commit

 

History

History
215 lines (146 loc) · 4.41 KB

networking.md

File metadata and controls

215 lines (146 loc) · 4.41 KB

Services & Networking (20%)

kubernetes.io > Documentation > Reference > kubectl CLI > kubectl Cheat Sheet

kubernetes.io > Documentation > Tasks > Monitoring, Logging, and Debugging > Get a Shell to a Running Container

kubernetes.io > Documentation > Tasks > Access Applications in a Cluster > Configure Access to Multiple Clusters

kubernetes.io > Documentation > Tasks > Access Applications in a Cluster > Accessing Clusters using API

kubernetes.io > Documentation > Tasks > Access Applications in a Cluster > Use Port Forwarding to Access Applications in a Cluster

Drain a node for maintenance named node1.mylabserver.com

show

kubectl drain node1.mylabserver.com --ignore-daemonsets --force

Put the node node1.mylabserver.com back into service, so pods can be scheduled to it

show

kubectl uncordon node1.mylabserver.com

Updgrade kubeadm to version 1.18.6

show

sudo apt install -y kubeadm --allow-change-held-packages kubeadm=1.18.6-00

Plan and upgrade the control plane components with kubeadm to version 1.18.6

show

sudo kubeadm upgrade plan

sudo kubeadm upgrade apply v1.18.6

Update kubelet to version 1.18.6

show

sudo apt install kubelet=1.18.6-00

Update kubectl to version 1.18.6

show

sudo apt install kubectl=1.18.6-00

Restart kubelet on the node

show

sudo systemctl daemon-reload

sudo systemctl restart kubelet

Upgrade the kubelet configuration on a worker node

show

sudo kubeadm upgrade node

List all namespaces in your cluster

show

kubectl get ns

List all pod in all namespaces

show

kubectl get po --all-namespaces

Create a new namespace named web

show

kubectl create ns web

Look up the value for the key cluster.name in the etcd cluster and backup etcd

show

ETCDCTL_API=3 etcdctl get cluster.name \
--endpoints=https://10.0.1.101:2379 \
--cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
--cert=/home/cloud_user/etcd-certs/etcd-server.crt \
--key=/home/cloud_user/etcd-certs/etcd-server.key

ETCDCTL_API=3 etcdctl snapshot save /home/cloud_user/etcd_backup.db \
--endpoints=https://10.0.1.101:2379 \
--cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
--cert=/home/cloud_user/etcd-certs/etcd-server.crt \
--key=/home/cloud_user/etcd-certs/etcd-server.key

Reset etcd and remove all data from the etcd

show

sudo systemctl stop etcd

sudo rm -rf /var/lib/etcd

Restore an etcd store from backup.

show

# spin up a temporary etcd cluster and save the data from the backup file to a new directory (/var/lib/etcd)
sudo ETCDCTL_API=3 etcdctl snapshot restore /home/cloud_user/etcd_backup.db \
--initial-cluster etcd-restore=https://10.0.1.101:2380 \
--initial-advertise-peer-urls https://10.0.1.101:2380 \
--name etcd-restore \
--data-dir /var/lib/etcd

# set ownership of the new data directory
sudo chown -R etcd:etcd /var/lib/etcd

# start etcd
sudo systemctl start etcd

# Verify the data was restored
ETCDCTL_API=3 etcdctl get cluster.name \
--endpoints=https://10.0.1.101:2379 \
--cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
--cert=/home/cloud_user/etcd-certs/etcd-server.crt \
--key=/home/cloud_user/etcd-certs/etcd-server.key

MORE CKA EXAM EXERCISES HERE