본문 바로가기

클라우드/CKA

[CKA] mock exam 01

[문제]

Create a service messaging-service to expose the messaging application within the cluster on port 6379.


Use imperative commands.

 
  • Service: messaging-service
  • Port: 6379
  • Type: ClusterIp
  • Use the right labels

[나의 풀이]

root@controlplane:~# kubectl create service clusterip messaging-service --tcp=6379
service/messaging-service created

 

[정답]

kubectl expose pod messaging --port=6379 --name messaging-service

 

 

[문제]

Create a static pod named static-busybox on the master node that uses the busybox image and the command sleep 1000

 

[정답]

kubectl run static-busybox --image=busybox --dry-run=client -o yaml > static-busybox.yaml
vi static-busybox.yaml

command: ["sleep", "1000"] 추가

apiVersion: v1
kind: Pod
metadata:
  name: static-busybox
spec:
  containers:
  - name: static-busybox
    image: busybox
    command: ["sleep", "1000"]

 

mv static_busybox.yaml /etc/kubernetes/manifests

 

 

[문제]

Expose the hr-web-app as service hr-web-app-service application on port 30082 on the nodes on the cluster.

The web application listens on port 8080.

  • Name: hr-web-app-service
  • Type: NodePort
  • Endpoints: 2
  • Port: 8080
  • NodePort: 30082
root@controlplane:~# kubectl expose deployment hr-web-app --type=NodePort --port=8080 --name=hr-web-app-service
service/hr-web-app-service exposed
root@controlplane:~# kubectl get svcNAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
hr-web-app-service   NodePort    10.99.216.56     <none>        8080:30647/TCP   3s
kubernetes           ClusterIP   10.96.0.1        <none>        443/TCP          87m
messaging-service    ClusterIP   10.111.245.134   <none>        6379/TCP         27m

 

root@controlplane:~# kubectl edit svc hr-web-app-service 
// nodePort를 30082로 변경
apiVersion: v1
kind: Service
metadata:
  name: hr-web-app-service
  labels:
    app: hr-web-app
spec:
  type: NodePort
  selector:
    app: hr-web-app
  ports:
    - port: 8080
      nodePort: 30082
service/hr-web-app-service edited

 

[문제]

Use JSON PATH query to retrieve the osImages of all the nodes and store it in a file /opt/outputs/nodes_os_x43kj56.txt.

The osImages are under the nodeInfo section under status of each node.

 

[정답]

kubectl get nodes -o jsonpath='{.items[*].status.nodeInfo.osImage}' > /opt/outputs/nodes_os_x43kj56.txt

'클라우드 > CKA' 카테고리의 다른 글

[CKA] Ligtning Lab  (0) 2022.01.02
[CKA] mock exam 03  (0) 2021.12.26
[CKA] mock exam 02  (0) 2021.12.26
[CKA] mock exam 01  (0) 2021.12.15
[network] dns  (0) 2021.10.16
[network] switching routing  (0) 2021.10.16