🎃

CKA(問題演習メモ-1)

2023/05/13に公開

alias設定

alias k=kubectl
complete -o default -F __start_kubectl k

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

▼実行結果

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

▼実行結果
deployment.apps/hr-web-app created

k expose pod messaging --port 6379 --name messaging-service

▼実行結果

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

k run static-busybox --image=busybox --dry-run=client -o yaml --command -- sleep 1000 > static-busybox.yaml

▼実行結果

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 --image="redis:alpine" -n finance

▼実行結果
pod/temp-bus created

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

▼実行結果
service/hr-web-app-service exposed

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

▼実行結果
service/messaging-service exposed

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.
Task Completed

kubectl get nodes -o=jsonpath="{.items[*].status.nodeInfo.osImage}"

▼実行結果
Ubuntu 20.04.5 LTS

Discussion