CKA (Certified Kubernetes Administrator)/Kode Kloud

12.Lightning Labs

seulseul 2022. 2. 8. 15:45

12.Lightning Labs

 

01.

Upgrade the current version of kubernetes from 1.19 to 1.20.0 exactly using the kubeadm utility.

Make sure that the upgrade is carried out one node at a time starting with the master node.

To minimize downtime, the deployment gold-nginx should be rescheduled on an alternate node before upgrading each node.

Upgrade controlplane node first and drain node node01 before upgrading it.

Pods for gold-nginx should run on the controlplane node subsequently.
 
  • Cluster Upgraded?
  • pods 'gold-nginx' running on controlplane?

(파랑색 부분은 node01위에서 작업해야하는 명령어들이다)

  1. 먼저 controlplane에 대해 drain 작업
  2. apt-get update -> apt-get install kubeadm=1.20.0-00
  3. kubeadm upgrade plan v1.20.0
  4. kubeadm upgrade apply v1.20.0
  5. apt-get install kubelet=1.20.0-00
  6. systemctl daemon-reload
  7. systemctl restart kubelet
  8. kubectl uncordon controlplane
  9. kubectl drain node01 --ignore-daemonsets
  10. apt-get update
  11. apt-get install kubeadm=1.20.0-00
  12. kubeadm upgrade node
  13. apt-get install kubelet=1.20.0-00
  14. systemctl daemon-reload
  15. systemctl restart kubelet
  16. kubectl uncordon node01



출처: https://jaeyung1001.tistory.com/239?category=944222 [공부방 & 일상]

# step 1
kubectl drain controlplane --ignore-daemonsets

# step 2
apt-get update

# step 3-1
kubeadm upgrade plan v1.20.0

# step 3-2
kubeadm upgrade apply v1.20.0


# step 4
apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm=1.20.0-00 && \
apt-mark hold kubeadm

# step 5
systemctl daemon-reload && systemctl restart kubelet

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.20.0-00 kubectl=1.20.0-00 && \
apt-mark hold kubelet kubectl

https://kubernetes.io/ko/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/

 

kubeadm 클러스터 업그레이드

이 페이지는 kubeadm으로 생성된 쿠버네티스 클러스터를 1.22.x 버전에서 1.23.x 버전으로, 1.23.x 버전에서 1.23.y(여기서 y > x) 버전으로 업그레이드하는 방법을 설명한다. 업그레이드가 지원되지 않는

kubernetes.io

02.

Print the names of all deployments in the admin2406 namespace in the following format:

DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE

<deployment name> <container image used> <ready replica count> <Namespace>

The data should be sorted by the increasing order of the deployment name.

Example:
DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE

deploy0 nginx:alpine 1 admin2406

Write the result to the file /opt/admin2406_data.
kubectl get deployments -n admin2406 -o custom-columns=DEPLOYMENT:.metadata.name,\
CONTAINER_IMAGE:.spec.template.spec.containers[0].image,\
READY_REPLICAS:.spec.replicas,NAMESPACE:.metadata.namespace  > /opt/admin2406_data

 


03.


A kubeconfig file called admin.kubeconfig has been created in /root/CKA.

There is something wrong with the configuration.


Troubleshoot and fix it.

 
  • Fix /root/CKA/admin.kubeconfig

 

04.


Create a new deployment called nginx-deploy, with image nginx:1.16 and 1 replica.

Next upgrade the deployment to version 1.17 using rolling update.

 
  • Image: nginx:1.16
  • Task: Upgrade the version of the deployment to 1:17

 

05.

A new deployment called alpha-mysql has been deployed in the alpha namespace.

However, the pods are not running. Troubleshoot and fix the issue.

The deployment should make use of the persistent volume alpha-pv

 to be mounted at /var/lib/mysql and should use

the environment variable MYSQL_ALLOW_EMPTY_PASSWORD=1 to make use of an empty root password.

Important: Do not alter the persistent volume.
 
  • Troubleshoot and fix the issues

 

ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
--cacert=<trusted-ca-file \
--cert=<cert-file> \
--key=<key-file> \
snapshot save <backup-file-location>

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

 


07

Create a pod called secret-1401 in the admin1401 namespace using the busybox image.

The container within the pod should be called secret-admin and should sleep for 4800 seconds.


The container should mount a read-only secret volume called secret-volume at the path /etc/secret-volume.

The secret being mounted has already been created for you and is called dotfile-secret.

 
  • Pod created correctly?
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: secret-1401
  name: secret-1401
  namespace: admin1401
spec:
  containers:
  - image: busybox
    name: secret-admin
    command: ["sh","-c","sleep 4800"]
    volumeMounts:
    - mountPath: "/etc/secret-volume"
      name: secret-volume
      readOnly: true
  dnsPolicy: ClusterFirst
  restartPolicy: Always
  volumes:
  - name: secret-volume
    secret:
      secretName: dotfile-secret

'CKA (Certified Kubernetes Administrator) > Kode Kloud' 카테고리의 다른 글

Mock Exam(3)  (0) 2022.02.07
MockExam(2)  (0) 2022.02.07
MockExam (1)  (0) 2022.02.04
10.Troubleshooting - Troubleshoot Network  (0) 2022.02.04
10. Troubleshooting - Worker Node Failure  (0) 2022.02.04