상세 컨텐츠

본문 제목

CKA Questions part-1

카테고리 없음

by BenzhaminKim 2021. 11. 20. 20:46

본문

Question 1. Create a new pod called admin-pod with image busybox. Allow the pod to be able to set system_time. The container should sleep for 3200 seconds.

 

kubectl run admin-pod --image=busybox --command sleep 3200 --dry-run=client -o yaml


```
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: admin-pod
  name: admin-pod
spec:
  containers:
  - command:
    - sleep
    - "3200"
    image: busybox
    name: admin-pod
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
```

securityContext:
      capabilities:
        add: ["SYS_TIME"]

By adding securityContext, you can add SYS_TIME.

```
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: admin-pod
  name: admin-pod
spec:
  containers:
  - command:
    - sleep
    - "3200"
    image: busyboxi
    securityContext:
      capabilities:
        add: ["SYS_TIME"]
    name: admin-pod
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
```

 

 

Question 2. A kubeconfig file called test.kubeconfig has been created in /root/TEST. There is something wrong with the configuration. Troubleshoot and fix it.

Kubernetes API uses 6443 port. So, you need to set the port as 6443.

kubectl config view

```
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://211.106.66.120:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
root@master-01:~/backup/temp# kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://211.106.66.120:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
```

 

Question 3. Create a new deployment called web-proj-268, with image nginx:1.16 and 1 replica. Next upgrade the deployment to version 1.17 using rolling update. Make sure that the version upgrade is recorded in the resource annotation.

 

kubectl create deployment web-proj-268 --image=nginx:1.16 

kubectl set image web-proj-268 nginx=nginx:1.17 --record 

kubectl describe deployment web-proj-268

 

댓글 영역