CKA 분류
[KodeKloud | CKA ]LIGHTNING LABS, LIGHTNING LAB – 1
컨텐츠 정보
- 1,803 조회
- 1 댓글
- 0 추천
- 목록
본문
# LIGHTNING LABS, LIGHTNING LAB – 1
Q. 1
- *info_outline*Question
Upgrade the current version of kubernetes from `1.25.0` to `1.26.0` exactly using the `kubeadm` utility. Make sure that the upgrade is carried out one node at a time starting with the controlplane 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.
현재 버전이 `1.25.0`인 쿠버네티스를 `kubeadm` 유틸리티를 사용하여 정확하게 `1.26.0`으로 업그레이드하십시오. 업그레이드는 컨트롤플레인 노드부터 한 번에 한 노드씩 수행되도록하십시오. 다운 타임을 최소화하기 위해 각 노드를 업그레이드하기 전에 `gold-nginx` 배포를 다른 노드로 재스케줄해야합니다.
먼저 `controlplane` 노드를 업그레이드하고 업그레이드하기 전에 `node01` 노드를 비워두십시오. `gold-nginx`의 Pods는 이후에 `controlplane` 노드에서 실행되어야합니다.
- *info_outline*Solution
Here is the solution for this task. Please note that the output of these commands have not been added here.
On the `controlplane` node:
```
root@controlplane:~# kubectl drain controlplane --ignore-daemonsets
root@controlplane:~# apt update
root@controlplane:~# apt-get install kubeadm=1.26.0-00
root@controlplane:~# kubeadm upgrade plan v1.26.0
root@controlplane:~# kubeadm upgrade apply v1.26.0
root@controlplane:~# apt-get install kubelet=1.26.0-00
root@controlplane:~# systemctl daemon-reload
root@controlplane:~# systemctl restart kubelet
root@controlplane:~# kubectl uncordon controlplane
```
Before draining `node01`, we need to remove the taint from the `controlplane` node.
`node01`을 비우기 전에 `controlplane` 노드에서 오염을 제거해야합니다.
```
# Identify the taint first.
root@controlplane:~# kubectl describe node controlplane | grep -i taint
# Remove the taint with help of "kubectl taint" command.
root@controlplane:~# kubectl taint node controlplane node-role.kubernetes.io/control-plane:NoSchedule-
# Verify it, the taint has been removed successfully.
root@controlplane:~# kubectl describe node controlplane | grep -i taint
```
Now, drain the `node01` as follows: -
```
root@controlplane:~# kubectl drain node01 --ignore-daemonsets
```
`SSH` to the `node01` and perform the below steps as follows:
```
root@node01:~# apt update
root@node01:~# apt-get install kubeadm=1.26.0-00
root@node01:~# kubeadm upgrade node
root@node01:~# apt-get install kubelet=1.26.0-00
root@node01:~# systemctl daemon-reload
root@node01:~# systemctl restart kubelet
```
To exit from the specific node, type `exit` or `logout` on the terminal.
Back on the `controlplane` node:
```
root@controlplane:~# kubectl uncordon node01
root@controlplane:~# kubectl get pods -o wide | grep gold (make sure this is scheduled on node)
```
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 2
- *info_outline*Question
Print the names of all deployments in the `admin2406` namespace in the following format:
- *info_outline*질문
다음 형식으로 `admin2406` 네임스페이스에 있는 모든 배포 이름을 출력하십시오:
`DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS 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`.
- *info_outline*Solution
Run the below command to get the correct output:
```
kubectl -n admin2406 get deployment -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:.spec.template.spec.containers[].image,READY_REPLICAS:.status.readyReplicas,NAMESPACE:.metadata.namespace --sort-by=.metadata.name > /opt/admin2406_data
```
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 3
- *info_outline*Question
A kubeconfig file called `admin.kubeconfig` has been created in `/root/CKA`. There is something wrong with the configuration. Troubleshoot and fix it.
- *info_outline*Solution
Make sure the port for the `kube-apiserver` is correct. So for this change port from `4380` to `6443`.
Run the below command to know the cluster information:
```
kubectl cluster-info --kubeconfig /root/CKA/admin.kubeconfig
```
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 4
- *info_outline*Question
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`.
- *info_outline*Solution
Make use of the `kubectl create` command to create the deployment and explore the `--record` option while upgrading the deployment image.
Run the below command to create a deployment `nginx-deploy`:
```
kubectl create deployment nginx-deploy --image=nginx:1.16
```
Run the below command to update the new image for `nginx-deploy` deployment and to record the version:
```
kubectl set image deployment/nginx-deploy nginx=nginx:1.17 --record
```
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 5
- *info_outline*Question
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.
새로운 배포인 `alpha-mysql`이 `alpha` 네임스페이스에 배포되었습니다. 그러나 파드가 실행되지 않습니다. 문제를 해결하십시오. 배포는 영구 볼륨 `alpha-pv`를 사용하여 `/var/lib/mysql`에 마운트해야하며 빈 루트 암호를 사용하기 위해 환경 변수 `MYSQL_ALLOW_EMPTY_PASSWORD=1`을 사용해야합니다.
Important: Do not alter the persistent volume.
- *info_outline*Solution
Use the command `kubectl describe` and try to fix the issue.
Solution manifest file to create a pvc called `mysql-alpha-pvc` as follows:
```
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-alpha-pvc
namespace: alpha
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: slow
```
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 6
- *info_outline*Question
Take the backup of ETCD at the location `/opt/etcd-backup.db` on the `controlplane` node.
- *info_outline*Solution
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 7
- *info_outline*Question
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`.
- *info_outline*질문
`admin1401` 네임스페이스에 `busybox` 이미지를 사용하여 `secret-1401`이라는 파드를 만듭니다. 파드 내부의 컨테이너는 `secret-admin`이라는 이름이어야하며 `4800`초 동안 슬립해야합니다.
컨테이너는 `/etc/secret-volume` 경로에서 `read-only` 비밀 볼륨 `secret-volume`을 마운트해야합니다. 마운트되는 비밀은 이미 `dotfile-secret`라는 이름으로 생성되었습니다.
Use the command `kubectl run` to create a pod definition file. Add secret volume and update container name in it.
Alternatively, run the following command:
```
kubectl run secret-1401 -n admin1401 --image=busybox --dry-run=client -oyaml --command -- sleep 4800 > admin.yaml
```
Add the `secret` volume and mount path to create a pod called `secret-1401` in the `admin1401` namespace as follows:
```
---
apiVersion: v1
kind: Pod
metadata:
creationTimestamp:nulllabels:
run: secret-1401
name: secret-1401
namespace: admin1401
spec:
volumes:
- name: secret-volume
# secret volume
secret:
secretName: dotfile-secret
containers:
- command:
- sleep
- "4800"
image: busybox
name: secret-admin
# volumes' mount path
volumeMounts:
- name: secret-volume
readOnly:truemountPath: "/etc/secret-volume"
```
관련자료
-
링크