본문 바로가기
IT 기술/k8s

[cka] Deployments

by Geunny 2024. 5. 28.
반응형

1. How many PODs exist on the system?  In the current(default) namespace.

 

$ controlplane ~ ➜  k get pods
No resources found in default namespace.

 

 answer : 0

 

 

2.  How many ReplicaSets exist on the system? In the current(default) namespace.

$ controlplane ~ ➜ k get replicasets.apps 
No resources found in default namespace.

 

answer :0

 

3. How many Deployments exist on the system? In the current(default) namespace.

 

$ controlplane ~ ➜  k get deployments.apps 
No resources found in default namespace.

 

answer : 0

 

4. How many Deployments exist on the system now? We just created a Deployment! Check again!

 

$ controlplane ~ ➜  k get deployments.apps 
NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
frontend-deployment   0/4     4            0           13s

 

 

answer : 1

 

5. How many ReplicaSets exist on the system now?

 

$ controlplane ~ ➜ k get replicasets.apps 
NAME                             DESIRED   CURRENT   READY   AGE
frontend-deployment-7b9984b987   4         4         0       2m8s

 

answer : 1

 

6. How many PODs exist on the system now?

 

$ controlplane ~ ➜  k get po
NAME                                   READY   STATUS             RESTARTS   AGE
frontend-deployment-7b9984b987-2kvbn   0/1     ImagePullBackOff   0          2m59s
frontend-deployment-7b9984b987-swrn9   0/1     ImagePullBackOff   0          2m59s
frontend-deployment-7b9984b987-zc4pt   0/1     ImagePullBackOff   0          2m59s
frontend-deployment-7b9984b987-djbcv   0/1     ImagePullBackOff   0          2m59s

 

answer : 4

 

7. Out of all the existing PODs, how many are ready?

 

6번 참조

answer : 0

 

8. What is the image used to create the pods in the new deployment?

 

$ controlplane ~ ➜  k describe po frontend-deployment-7b9984b987-zc4pt
...


IPs:
  IP:           10.42.0.9
Controlled By:  ReplicaSet/frontend-deployment-7b9984b987
Containers:
  busybox-container:
    Container ID:  
    Image:         busybox888
 ...

 

answer : BUSYBOX888

 

9. Why do you think the deployment is not ready?

 

이미지 명 잘못됨.

 

answer : The image BUSYBOX888 doesn't exist

 

 

10 . Create a new Deployment using the deployment-definition-1.yaml file located at /root/.
There is an issue with the file, so try to fix it.

 

 

 

vi deployment-definition-1.yaml

---
apiVersion: apps/v1
kind: deployment   ### deployment -> Deployment 대문자로 변경
metadata:
  name: deployment-1
spec:
  replicas: 2
  selector:
    matchLabels:
      name: busybox-pod
  template:
    metadata:
      labels:
        name: busybox-pod
    spec:
      containers:
      - name: busybox-container
        image: busybox888 ### -> 이미지명 변경 busybox
        command:
        - sh
        - "-c"
        - echo Hello Kubernetes! && sleep 3600
        
$ controlplane ~ ➜  k apply -f deployment-definition-1.yaml
deployment.apps/deployment-1 created

 

 

11. Create a new Deployment with the below attributes using your own deployment definition file.
Name: httpd-frontend;
Replicas: 3;
Image: httpd:2.4-alpine

 

https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment

 

Deployments

A Deployment manages a set of Pods to run an application workload, usually one that doesn't maintain state.

kubernetes.io

 

apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpd-frontend
  labels:
    app: frontend
spec:
  replicas: 3
  selector:
    matchLabels:
      app: frontend
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
      - name: httpd-frontend
        image: httpd:2.4-alpine
        
$ k apply -f httpd-deployments.yaml

 

'IT 기술 > k8s' 카테고리의 다른 글

[cka] Services  (0) 2024.06.01
[cka] namespace  (1) 2024.05.28
[cka] ReplicaSets  (0) 2024.05.27
[cka] kodecloud PODs 생성하기.  (0) 2024.05.27
[k8s] kubeadm token 생성하기.  (0) 2024.05.15

댓글