[k8s] pods

jordy·2022년 12월 24일
0

study-k8s

목록 보기
1/7

PODS

get pods image info

  1. k get pod newpods-gjfh4 -o yaml | grep image ( RECOMMAND )
controlplane ~ ➜  k get pod newpods-gjfh4 -o yaml | grep image
    image: busybox
    imagePullPolicy: Always
    image: docker.io/library/busybox:latest
    imageID: docker.io/library/busybox@sha256:05a79c7279f71f86a2a0d05eb72fcb56ea36139150f0a75cd87e80a4272e4e39
  1. k describe pod newpods-gjfh4 | grep image
controlplane ~ ➜  k describe pod newpods-gjfh4 | grep image
  Normal  Pulling    3m4s  kubelet            Pulling image "busybox"
  Normal  Pulled     3m2s  kubelet            Successfully pulled image "busybox" in 1.887974613s

check pods placed on

  1. kubectl get pods -o wide
controlplane ~ ✖ kubectl get pods -o wide
NAME            READY   STATUS    RESTARTS   AGE   IP           NODE           NOMINATED NODE   READINESS GATES
nginx           1/1     Running   0          12m   10.42.0.9    controlplane   <none>           <none>
newpods-gjfh4   1/1     Running   0          11m   10.42.0.11   controlplane   <none>           <none>
newpods-qf5hl   1/1     Running   0          11m   10.42.0.12   controlplane   <none>           <none>
newpods-x9fcg   1/1     Running   0          11m   10.42.0.10   controlplane   <none>           <none>

run pod with yaml

  1. vim redis.yaml

redis.yml

apiVersion: v1
kind: Pod
metadata:
  name: redis
spec:
  containers:
  - name: redis
    image: redis123 ## 잘못된 이미지 입력
  1. kubectl apply -f redis.yaml
controlplane ~ ➜  kubectl apply -f redis.yaml
pod/redis created

controlplane ~ ➜  kubectl get pod redis
NAME    READY   STATUS             RESTARTS   AGE
redis   0/1     ImagePullBackOff   0          27s

edit pod

  1. kubectl edit pod redis
apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"redis","namespace":"default"},"spec":{"containers":[{"image":"redis123","name":"redis"}]}}
  creationTimestamp: "2022-12-24T13:52:43Z"
  name: redis
  namespace: default
  resourceVersion: "976"
  uid: 61e293ac-44b8-40c7-aa7a-7df4afba330b
spec:
  containers:
  - image: redis # redis123 -> redis 수정
    imagePullPolicy: Always
    name: redis
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    
 ... 생략 

수정 후 STATUS Running 확인

controlplane ~ ➜  kubectl edit pod redis
pod/redis edited

controlplane ~ ➜  kubectl get pod redis
NAME    READY   STATUS    RESTARTS   AGE
redis   1/1     Running   0          5m15s
profile
Hello Worlds!

1개의 댓글

comment-user-thumbnail
2022년 12월 24일

열심히시네요! 멋있어요!

답글 달기