CKA
CKA - kodekloud Practice Test - Lightning Lab
by 2won2
2025. 7. 4.
1번
2번
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 deploy -n admin2406 -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:.spec.template.spec.containers[0].image,READY_REPLICAS:.status.readyReplicas,NAMESPACE:.metadata.namespace --sort-by=.metadata.name > /opt/admin2406_data
3번
A kubeconfig file called admin.kubeconfig has been created in /root/CKA.
There is something wrong with the configuration. Troubleshoot and fix it.
4번
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 and add the annotation message
Updated nginx image to 1.17
- deploy 생성
- kubectl create deploy nginx-deploy --image=nginx:1.16 --replicas=1
- upgrade
- annotation
5번
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.
- k get pvc -n alpha로 pvc가 있는지 확인
- k describe pod alpha-mysql-b4fbd744d-zrsk8 -n alpha 후 env, mounts 경로 확인(없다면 pvc 생성 후 작성)
- describe 후, ClaimName과 pvc에서 사용할 metadata.name이 일치해야 하기에 확인
- vi alpha-pvc.yaml
- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql-alpha-pvc namespace: alpha spec: volumeName: alpha-pv accessModes: - ReadWriteOnce volumeMode: Filesystem resources: requests: storage: 1Gi storageClassName: slow selector: matchLabels: release: "stable" matchExpressions: - {key: environment, operator: In, values: [dev]}
- k apply -f alpha-pvc.yaml
- k get pods -n alpha로 제대로 적용 되었는지 확인
- 참고 docs : https://kubernetes.io/docs/concepts/storage/persistent-volumes/
6번
Take the backup of ETCD at the location /opt/etcd-backup.db on the controlplane node.
- cat /etc/kubernetes/manifests/etcd.yaml로 확인(기억 안나면 static pod docs에 경로 있음)
- 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/etcd-backup.db
- 참고 docs
7번
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.
- k run secret-1401 --image=busybox -n admin1401 --dry-run=client -o yaml > secret.yaml
- vi secret.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: secret-1401
name: secret-1401
namespace: admin1401
spec:
volumes:
- name: secret-volume
secret:
secretName: dotfile-secret
containers:
- image: busybox
volumeMounts:
- mountPath: /etc/secret-volume
name: secret-volume
readOnly: true
name: secret-admin
resources: {}
command: [ "sh", "-c", "sleep 4800" ]
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
- spec.volumes 추가
- spec.containers.volumeMounts 추가(spec.volumes의 name과 volumeMounts의 name은 같아야함)
- spec.containers.command 추가
- 참고 docs