DevOps/CKA

[CKA 준비] yaml 생성 템플릿 명령어

돌돌김 2021. 3. 21. 03:05

Create an NGINX Pod

kubectl run nginx --image=nginx

 

Generate POD Manifest YAML file (-o yaml). Don't create it(--dry-run)

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

 

Create a deployment

kubectl create deployment --image=nginx nginx

 

Generate Deployment YAML file (-o yaml). Don't create it(--dry-run)

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

 

Generate Deployment YAML file (-o yaml). Don't create it(--dry-run) with 4 Replicas (--replicas=4)

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

 

 

Service와 Pod연결해서 생성하기, yaml 파일 생성하지 않고 테스트로 보기

kubectl run httpd --image=httpd:alpine --port 80 --expose --dry-run=client -o yaml 

# 실제 생성 할 때
kubectl run httpd --image=httpd:alpine --port 80 --expose                          
service/httpd created
pod/httpd created

 

명령어 정리

# 오브젝트에 대해 모든 네임스페이스에서 검색
kubectl get pods --all-namespaces