12. Tips - create YAML

2024. 9. 11. 02:59·Kubernetes
이 글은 아래 자료를 참고하여 작성되었습니다.

Udemy [Certified Kubernetes Administrator (CKA) with Practice Tests]
https://kubernetes.io/docs/reference/kubectl/conventions/

 

YAML 파일을 직접 작성하고 수정하는 것이 CLI 환경에서 꽤 까다로울 수 있는데, kubectl run 명령어를 사용하면 YAML 파일을 생성하지 않고도 kubectl run 명령어를 사용하면 YAML을 생성하지 않고 작업을 끝내거나, YAML을 쉽게 생성할 수 있다.

 

1. YAML 파일 없이 리소스 생성하기

1-1. pod

kubectl run nginx --image=nginx

1-2. deployment

kubectl create deployment --image=nginx nginx

 

2. YAML 파일 쉽게 생성하기

2-1. pod manifest YAML

kubectl run nginx --image=nginx --dry-run=client -o yaml

2-2. deployment manifest YAML

kubectl create deployment --image=nginx nginx --dry-run=client -o yaml

2-3. 생성한 YAML을 파일로 저장하기

kubectl create deployment --image=nginx nginx --dry-run=client -o yaml > nginx-deployment.yaml

# k8s version 1.19 이상에서는 --replicas 설정 가능
kubectl create deployment --image=nginx nginx --replicas=4 --dry-run=client -o yaml > nginx-deployment.yaml

 

'Kubernetes' 카테고리의 다른 글

14. Tips - Imperative vs Declarative  (0) 2024.09.12
13. Core Concepts - Namespace  (2) 2024.09.11
11. Practices - Microservices Architecture  (2) 2024.07.25
10. Core Concepts - Services  (1) 2024.07.18
9. Kubernetes Overview - Networking  (1) 2024.07.08
'Kubernetes' 카테고리의 다른 글
  • 14. Tips - Imperative vs Declarative
  • 13. Core Concepts - Namespace
  • 11. Practices - Microservices Architecture
  • 10. Core Concepts - Services
SerenaDev
SerenaDev
나의 기술블로그 입니다.
  • SerenaDev
    나의 기술블로그
    SerenaDev
    • 분류 전체보기 (33)
      • FastAPI (1)
      • Iceberg (6)
      • Kubernetes (24)
      • ETC (1)
      • 독서 (1)
  • hELLO· Designed By정상우.v4.10.0
SerenaDev
12. Tips - create YAML
상단으로

티스토리툴바