Pod Task

2024. 12. 4. 19:35쿠버네티스/쿠버네티스

728x90
반응형

Create a new pod with the nginx image.

Run the command: kubectl run nginx --image=nginx

 

How many pods are created now?

Note: We have created a few more pods. So please check again in the current(default) namespace.

kubectl get pods

 

What is the image used to create the new pods?

You must look at one of the new pods in detail to figure this out.

kubectl describe pod newpods-4ncn6

 

Which nodes are these pods placed on?

You must look at all the pods in detail to figure this out.

kubectl describe pod newpods-4ncn6
  • node 필드 확인

 

How many containers are part of the pod webapp?

Note: We just created a new POD. Ignore the state of the POD for now.

 

Delete the webapp Pod.

Once deleted, wait for the pod to fully terminate.

kubectl delete pod webapp

 

Create a new pod with the name redis and the image redis123.

Use a pod-definition YAML file. And yes the image name is wrong!

kubectl run redis --image=redis123 --dry-run=client -o yaml > redis-definition.yaml
kubectl create -f redis-definition.yaml
kubectl get pods
  • Now change the image on this pod to redis. Once done, the pod should be in a running state. If you used a pod definition file then update the image from redis123 to redis

 

  • kubectl run:
    • Kubernetes에서 새로운 Pod(또는 이전 버전에서는 Deployment)를 생성할 때 사용되는 명령어입니다.
    • 여기서는 redis라는 이름의 Pod을 생성하려고 시도합니다.
  • redis:
    • 생성할 리소스의 이름입니다. 여기서는 redis라는 이름의 리소스를 정의합니다.
  • --image=redis123:
    • Pod에 사용할 컨테이너 이미지를 지정합니다. 이 경우 redis123라는 이미지를 사용합니다.
    • redis123는 Docker Hub 또는 다른 컨테이너 레지스트리에서 사용 가능한 이미지 이름이어야 합니다.
  • --dry-run=client:
    • 실제로 리소스를 생성하지 않고, 명령 실행 결과를 클라이언트 측에서 검증만 합니다.
    • 이 옵션은 리소스 정의 파일을 생성하거나 구성을 확인할 때 유용합니다.
  • -o yaml:
    • 출력 형식을 YAML 형식으로 지정합니다. Kubernetes 리소스는 일반적으로 YAML로 정의되므로 이 옵션을 사용합니다.
  • > redis-definition.yaml:
    • 명령의 출력을 redis-definition.yaml 파일로 저장합니다. 이를 통해 생성된 YAML 파일을 편집하거나 검토할 수 있습니다.

 

반응형

'쿠버네티스 > 쿠버네티스' 카테고리의 다른 글

ETCD  (2) 2024.12.11
개요  (1) 2024.12.11
쿠버네티스를 사용하여 마이크로서비스 아키텍처 배포-1  (1) 2024.11.25
kubespray로 k8s설치  (2) 2024.11.21
kubectl 실습  (1) 2023.09.10