지니데비 기록 자세히보기

데브옵스/Orchestration

[Kubernetes] 6. 쿠버네티스 아키텍처와 yaml 파일

지니데비 2024. 11. 4. 19:56
728x90

kuernetes cluster 구성

Master Node(Control plane Node)

  • kube-apiserver
  • controller manager
  • etcd
  • kube-scheduler

Worker Node

  • kubelet
  • kube-proxy
  • container runtime engine
yaml 파일 구성 
apiVersion:
kind:
metadata:
spec:
yaml 예제
※ 들여쓰기 주의 ※
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels: 
    app: myapp
    type: front-end
spec:
  containers:
    - name: nginx-container
      image: nginx

※ labels: dictionary (key-value)

 containers: array/list (-로 구분하는 object)

yaml 파일 빠르게 생성하기 : --dry-run
kubectl run redis --image=reids --dry-run=client -o yaml > redis-pod.yaml
kubectl apply -f redis-pod.yaml

kubectl create deployment --image=nginx nginx --replicas=4 --dry-run=client -o yaml > nginx-deployment.yaml
kubectl apply -f nginx-deployment.yaml
command
kubectl --help
kubectl get --help
kubectl api-resources
kubectl explain rs

kubectl get pod
# o: outfut
kubectl get pod -o wide
kubectl get pod -o yaml
kubectl get pod -o json

kubectl run [pod name] --image=nginx
kubectl run [pod name] --image=nginx --dry-run=client -o yaml > [yaml file name]
kubectl describe pod [pod name]

kubectl delete [resource type] [resource name]


## Pod 수정(1) - 직접 수정
kubectl edit [resource type] [resource name]

## Pod 수정(2) - yaml 파일 수정 후
# f: file
kubectl apply -f [yaml file name]

 

728x90
반응형