본문 바로가기
CKA

CKA - kodekloud Practice Test - Lightning Lab

by 2won2 2025. 7. 4.

1번

  • 현재 1.32 버전으로 업데이트 불가

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

 

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
    • metadata.name : deploy에서 확인 후 작성
    • namespace 추가
    • spec.volumeName : alpha-pv 명시
    • 처음엔 spec.resources.requests.storage: 8Gi가 default였고, 이대로 하니
      Cannot bind to requested volume "alpha-pv": requested PV is too small
      와 같은 에러가 발생함.
      • k get pv alpha-pv -o yaml로 확인해 보니 storage가 1Gi 였기에 pvc에서도 1Gi로 변경함
  • 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.

 

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: {}