Weight: 15
Print the names of all deployments in the admin2406 namespace in the following format:
DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE
<deployment name> <container image used> <ready replica count> <Namespace>
. The data should be sorted by the increasing order of the deployment name.
Example:
DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE
deploy0 nginx:alpine 1 admin2406
Write the result to the file /opt/admin2406_data.
- 정보 확인
controlplane ~ ➜ k get deploy -n admin2406
NAME READY UP-TO-DATE AVAILABLE AGE
deploy1 1/1 1 1 15m
deploy2 1/1 1 1 15m
deploy3 1/1 1 1 15m
deploy4 1/1 1 1 15m
deploy5 1/1 1 1 15m
controlplane ~ ✖ k get deploy deploy1 -n admin2406 -o json
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"deployment.kubernetes.io/revision": "1"
},
"creationTimestamp": "2024-07-22T13:34:55Z",
"generation": 1,
"labels": {
"app": "deploy1"
},
"name": "deploy1",
"namespace": "admin2406",
"resourceVersion": "5100",
"uid": "c28faff1-bf27-4298-8f3c-f30aa4f15dbb"
},
"spec": {
"progressDeadlineSeconds": 600,
"replicas": 1,
"revisionHistoryLimit": 10,
"selector": {
"matchLabels": {
"app": "deploy1"
}
},
"strategy": {
"rollingUpdate": {
"maxSurge": "25%",
"maxUnavailable": "25%"
},
"type": "RollingUpdate"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "deploy1"
}
},
"spec": {
"containers": [
{
"image": "nginx",
"imagePullPolicy": "Always",
"name": "nginx",
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File"
}
],
"dnsPolicy": "ClusterFirst",
"restartPolicy": "Always",
"schedulerName": "default-scheduler",
"securityContext": {},
"terminationGracePeriodSeconds": 30
}
}
},
"status": {
"availableReplicas": 1,
"conditions": [
{
"lastTransitionTime": "2024-07-22T13:34:55Z",
"lastUpdateTime": "2024-07-22T13:34:57Z",
"message": "ReplicaSet \"deploy1-67b55d4f9f\" has successfully progressed.",
"reason": "NewReplicaSetAvailable",
"status": "True",
"type": "Progressing"
},
{
"lastTransitionTime": "2024-07-22T13:45:13Z",
"lastUpdateTime": "2024-07-22T13:45:13Z",
"message": "Deployment has minimum availability.",
"reason": "MinimumReplicasAvailable",
"status": "True",
"type": "Available"
}
],
"observedGeneration": 1,
"readyReplicas": 1,
"replicas": 1,
"updatedReplicas": 1
}
}
kubectl -n admin2406 get deployment -o custom-columns=DEPLOYMENT:.metadata.name,\
CONTAINER_IMAGE:.spec.template.spec.containers[].image,\
READY_REPLICAS:.status.readyReplicas,\
NAMESPACE:.metadata.namespace --sort-by=.metadata.name
DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE
deploy1 nginx 1 <none>
deploy2 nginx:alpine 1 <none>
deploy3 nginx:1.16 1 <none>
deploy4 nginx:1.17 1 <none>
deploy5 nginx:latest 1 <none>
kubectl -n admin2406 get deployment -o custom-columns=DEPLOYMENT:.metadata.name,\
CONTAINER_IMAGE:.spec.template.spec.containers[].image,\
READY_REPLICAS:.status.readyReplicas,\
NAMESPACE:.metadata.namespace --sort-by=.metadata.name > /opt/admin2406_data
controlplane ~ ➜ k get deployments.apps -n admin2406 -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:.spec.template.spec.containers[*].image,REDY_REPLICAS:.status.readyReplicas,NAMESPACE:.metatdata.namespace --sort-by=.metadata.name
DEPLOYMENT CONTAINER_IMAGE REDY_REPLICAS NAMESPACE
deploy1 nginx 1 <none>
deploy2 nginx:alpine 1 <none>
deploy3 nginx:1.16 1 <none>
deploy4 nginx:1.17 1 <none>
deploy5 nginx:latest 1 <none>
controlplane ~ ➜ kubectl -n admin2406 get deployment -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:.spec.template.spec.cont
ainers[].image,READY_REPLICAS:.status.readyReplicas,NAMESPACE:.metadata.namespace --sort-by=.metadata.name
DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE
deploy1 nginx 1 admin2406
deploy2 nginx:alpine 1 admin2406
deploy3 nginx:1.16 1 admin2406
deploy4 nginx:1.17 1 admin2406
deploy5 nginx:latest 1 admin2406
controlplane ~ ➜ k get deployments.apps -n admin2406 -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:.spec.template.spec.cont
ainers[].image,REDY_REPLICAS:.status.readyReplicas,NAMESPACE:.metatdata.namespace
DEPLOYMENT CONTAINER_IMAGE REDY_REPLICAS NAMESPACE
deploy1 nginx 1 <none>
deploy2 nginx:alpine 1 <none>
deploy3 nginx:1.16 1 <none>
deploy4 nginx:1.17 1 <none>
deploy5 nginx:latest 1 <none>
'자격증 > CKA' 카테고리의 다른 글
[CKA] Udemy Lightning Lab (4/7) (0) | 2024.07.24 |
---|---|
[CKA] Udemy Lightning Lab (3/7) (0) | 2024.07.24 |
[CKA] Udemy Lightning Lab (1/7) (2) | 2024.07.17 |
[CKA] Udemy 74. Static Pods (0) | 2024.07.13 |
[CKA] Udemy 71. Daemon Sets (0) | 2024.07.13 |