Programming/Kubernetes

K8S - Deployment, Replicas, pods 생성

잇(IT) 2022. 7. 26. 11:04
kubectl create deployment nginx-app --image nginx --replicas 2 --namespace 2team


Name:         nginx-app-5568c89dcd-7r54d
Namespace:    2team
Priority:     0
Node:         node3/10.0.0.13
Start Time:   Tue, 26 Jul 2022 09:48:20 +0900
Labels:       app=nginx-app
              pod-template-hash=5568c89dcd
Annotations:  cni.projectcalico.org/containerID: fa22e5bfbf85331c0ae1a4fa0834c1ff3dfac0654df18306a2a433bcaeee6ba0
              cni.projectcalico.org/podIP: 192.168.135.10/32
              cni.projectcalico.org/podIPs: 192.168.135.10/32
Status:       Running
IP:           192.168.135.10
IPs:
  IP:           192.168.135.10
Controlled By:  ReplicaSet/nginx-app-5568c89dcd
Containers:
  nginx:
    Container ID:   containerd://56b5c7334ab7170b7d44343a8a0230dd953eb09394ba42d6e401a2ffb0108c06
    Image:          nginx
    Image ID:       docker.io/library/nginx@sha256:1761fb5661e4d77e107427d8012ad3a5955007d997e0f4a3d41acc9ff20467c7
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Tue, 26 Jul 2022 09:48:23 +0900
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-t9gng (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-t9gng:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  84s   default-scheduler  Successfully assigned 2team/nginx-app-5568c89dcd-7r54d to node3
  Normal  Pulling    83s   kubelet            Pulling image "nginx"
  Normal  Pulled     81s   kubelet            Successfully pulled image "nginx" in 2.135834301s
  Normal  Created    81s   kubelet            Created container nginx
  Normal  Started    81s   kubelet            Started container nginx

Name:         nginx-app-5568c89dcd-s5nhp
Namespace:    2team
Priority:     0
Node:         node1/10.0.0.11
Start Time:   Tue, 26 Jul 2022 09:48:20 +0900
Labels:       app=nginx-app
              pod-template-hash=5568c89dcd
Annotations:  cni.projectcalico.org/containerID: 7f3714d0d48d4da147e54ca8dc2c0741afafdcec0e4623b2d81747e34f500593
              cni.projectcalico.org/podIP: 192.168.166.134/32
              cni.projectcalico.org/podIPs: 192.168.166.134/32
Status:       Running
IP:           192.168.166.134
IPs:
  IP:           192.168.166.134
Controlled By:  ReplicaSet/nginx-app-5568c89dcd
Containers:
  nginx:
    Container ID:   containerd://d94672d60fec87a44a3942ec02ce6766aba6dbc55d5babeefaa4763d854d32de
    Image:          nginx
    Image ID:       docker.io/library/nginx@sha256:1761fb5661e4d77e107427d8012ad3a5955007d997e0f4a3d41acc9ff20467c7
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Tue, 26 Jul 2022 09:48:23 +0900
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-mt2r4 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-mt2r4:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age    From               Message
  ----    ------     ----   ----               -------
  Normal  Scheduled  2m19s  default-scheduler  Successfully assigned 2team/nginx-app-5568c89dcd-s5nhp to node1
  Normal  Pulling    2m18s  kubelet            Pulling image "nginx"
  Normal  Pulled     2m16s  kubelet            Successfully pulled image "nginx" in 2.180748232s
  Normal  Created    2m16s  kubelet            Created container nginx
  Normal  Started    2m16s  kubelet            Started container nginx

apiVersion: v1
kind: Pod
metadata:
  namespace: 2team
  name: nginx
spec:
  containers:
  - name: n1
    image: nginx:1.14.2
    ports:
    - containerPort: 80

 

- 새롭게 pod가 생성된 것이 아닌 버전만 업그레이드 된 것을 확인 할 수 있다.


- mysql pod 생성

 

apiVersion: v1
kind: Pod
metadata:
  namespace: 2team
  name: mysql
spec:
  containers:
  - name: m1
    image: mysql:5.6
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: It12345!
    - name: MYSQL_DATABASE
      value: wordpress
    - name: MYSQL_USER
      value: wordpress
    - name: MYSQL_ROOT_HOST
      value: '%'
    - name: MYSQL_PASSWORD
      value: It12345!
    ports:
    - containerPort: 3306


apiVersion: v1
kind: Pod
metadata:
  namespace: 2team
  name: wordpress
spec:
  containers:
  - name: w1
    image: wordpress
    ports:
    - containerPort: 80

 

- /bin/bash로 접속

 

 

728x90

'Programming > Kubernetes' 카테고리의 다른 글

K8S - Wordpress, MySQL (yml 파일) 생성 후 배포  (0) 2022.07.27
K8S - Replicaset  (0) 2022.07.27
K8S - pod describe 정보  (0) 2022.07.26
K8S - yml 파일을 이용한 pod 생성  (0) 2022.07.25
K8S - namespace, yml 파일  (0) 2022.07.25