CKA (Certified Kubernetes Administrator)/Kode Kloud

MockExam (1)

seulseul 2022. 2. 4. 17:12

MOCK EXAMS, MOCK EXAM – 1

 

01. Deploy a pod named nginx-pod using the nginx:alpine image.


Once done, click on the Next Question button in the top right corner of this panel. You may navigate back and forth freely between all questions. Once done with all questions, click on End Exam. Your work will be validated at the end and score shown. Good Luck!

 
  • Name: nginx-pod
  • Image: nginx:alpine
k run nginx-pod --image nginx:alpine

02. Deploy a messaging pod using the redis:alpine image with the labels set to tier=msg.


 
  • Pod Name: messaging
  • Image: redis:alpine
  • Labels: tier=msg
k run messaging --image redis:alpine -l tier=msg

03. Create a namespace named apx-x9984574.


 
  • Namespace: apx-x9984574
k create namespace apx-x9984574

 

04. Get the list of nodes in JSON format and store it in a file at /opt/outputs/nodes-z3444kd9.json.


 

 

  • Task completed
k get node -o json > /opt/outputs/nodes-z3444kd9.json

05. 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
k expose pod messaging --port=6379 --name=messaging-service -l tier=msg

 

06. Create a deployment named hr-web-app using the image kodekloud/webapp-color with 2 replicas.


 
  • Name: hr-web-app
  • Image: kodekloud/webapp-color
  • Replicas: 2
k create deployment hr-web-app --image=kodekloud/webapp-color --dry-run=client --replicas=2 -oyaml > 06.yaml


k create -f 06.yaml

 

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


 
  • Name: static-busybox
  • Image: busybox
apiVersion: v1
kind: Pod
metadata:
  name: static-busybox
spec:
  containers:
  - name: static-busybox
    image: busybox
    command: ['sh', '-c', 'sleep 1000']

 

08. Create a POD in the finance namespace named temp-bus with the image redis:alpine.


 
  • Name: temp-bus
  • Image Name: redis:alpine
apiVersion: v1
kind: Pod
metadata:
  name: temp-bus
  namespace: finance
spec:
  containers:
  - name: temp-bus
    image: redis:alpine

09. A new application orange is deployed. There is something wrong with it. Identify and fix the issue.


 
  • Issue fixed
apiVersion: v1
kind: Pod
metadata:
  name: orange
spec:
  containers:
  - command:
    - sh
    - -c
    - echo The app is running! && sleep 3600
    image: busybox:1.28
    imagePullPolicy: IfNotPresent
    name: orange-container
  initContainers:
  - command:
    - sh
    - -c
    - sleep 2; # sleeeeep 으로 돼있었음
    image: busybox
    name: init-myservice
~

 

10. 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
apiVersion: v1
kind: Service
metadata:
  name: hr-web-app-service
spec:
  type: NodePort
  selector:
    app: hr-web-app
  ports:
      # By default and for convenience, the `targetPort` is set to the same value as the `port` field.
    - port: 8080
      targetPort: 8080
      # Optional field
      # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
      nodePort: 30082
kubectl expose deployment hr-web-app --type=NodePort --port=8080 \
--name=hr-web-app-service --dry-run=client -o yaml > hr-web-app-service.yaml

10. 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.

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

11. Create a Persistent Volume with the given specification.


 
  • Volume Name: pv-analytics
  • Storage: 100Mi
  • Access modes: ReadWriteMany
  • Host Path: /pv/data-analytics
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-analytics
spec:
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/pv/data-analytics"