1

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

Name: nginx-pod
Image: nginx:alpine
$ k run nginx-pod --image=nginx:alpine

2

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 --labels=tier=msg

3

Create a namespace named apx-x9984574.

Namespace: apx-x9984574
$ k create ns apx-x9984574

4

Get the list of nodes in JSON format and store it in a file at /opt/outputs/nodes-z3444kd9.json.
$ k get node -o json > /opt/outputs/nodes-z3444kd9.json
$ cat /opt/outputs/nodes-z3444kd9.json

5

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 --name=messaging-service --port=6379 --labels=tier=msg

6

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 deploy hr-web-app --image=kodekloud/webapp-color --replicas=2

7

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
Static Pod Path = /etc/kubernetes/manifests

$ k run static-busybox --image=busybox --dry-run=client -o yaml --command -- sleep 1000 > /etc/kubernetes/manifests/static-pod.yaml

8

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

Name: temp-bus
Image Name: redis:alpine
$ k run temp-bus -n finance --image=redis:alpine

9

A new application orange is deployed. There is something wrong with it. Identify and fix the issue.
$ k describe pod orange
$ k edit pod orange

initContainers:
  - command:
    - sh
    - -c
    - sleep 2;

$ k delete pod orange --force
$ k apply -f /tmp/kubectl-edit-1754973846.yaml
$ k get pod --watch

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
$ k expose deploy hr-web-app --name=hr-web-app-service --type=NodePort --port=8080
$ k edit svc hr-web-app-service
ports:
- nodePort: 30082
  port: 8080
  protocol: TCP
$ k get endpoints hr-web-app-service

11

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 node -o json
$ k get node -o jsonpath='{.items[*].status.nodeInfo.osImage}' > /opt/outputs/nodes_os_x43kj56.txt

12

Create a Persistent Volume with the given specification: -

Volume name: pv-analytics
Storage: 100Mi
Access mode: ReadWriteMany
Host path: /pv/data-analytics

Is the volume name set?
Is the storage capacity set?
Is the accessMode set?
Is the hostPath set?
$ vi pv.yaml
pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-analytics
spec:
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: /pv/data-analytics
    
$ k apply -f pv.yaml
$ k get pv
profile
Cloud Engineer / DevOps Engineer

0개의 댓글