Skip to content

Kubectl:run

kubectl의 run 명령

Example

$ kubectl run nginx --image=nginx
pod/nginx created

kubectl:get 명령으로 확인 결과:

$ kubectl get pods
NAME    READY   STATUS              RESTARTS   AGE
nginx   0/1     ContainerCreating   0          11s

kubectl:describe 명령으로 확인 방법:

$ kubectl describe pods/nginx

그리고 결과:

Name:         nginx
Namespace:    default
Priority:     0
Node:         yourid-sf314-42/192.168.1.209
Start Time:   Wed, 29 Mar 2023 22:33:56 +0900
Labels:       run=nginx
Annotations:  <none>
Status:       Running
IP:           10.42.0.44
IPs:
  IP:  10.42.0.44
Containers:
  nginx:
    Container ID:   containerd://657c9fc2c68166949dccfd3dd3541f438abbce0a9558c2271c44edbb13cb336e
    Image:          nginx
    Image ID:       docker.io/library/nginx@sha256:2ab30d6ac53580a6db8b657abf0f68d75360ff5cc1670a85acb5bd85ba1b19c0
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Wed, 29 Mar 2023 22:34:09 +0900
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-5jgd5 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  kube-api-access-5jgd5:
    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  46s   default-scheduler  Successfully assigned default/nginx to yourid-sf314-42
  Normal  Pulling    46s   kubelet            Pulling image "nginx"
  Normal  Pulled     34s   kubelet            Successfully pulled image "nginx" in 12.378215819s
  Normal  Created    34s   kubelet            Created container nginx
  Normal  Started    33s   kubelet            Started container nginx

Pod 제거:

$ kubectl delete pods/nginx
pod "nginx" deleted

See also