Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

전공공부

1. K8S Pod 설치 본문

Study/K8S

1. K8S Pod 설치

monitor 2023. 1. 29. 20:18

1. CLI 명령 기반 배포

마스터 노드에 터미널로 접속한 상태에서 다음과 같은 명령을 실행한다.

kubectl run nginx --image=nginx //k8s docker hub로 부터 이미지 가져와서 pod run
kubectl get pod // pod 확인

 

2. YAML 파일 배포

 

pod-define.yaml

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
    type: frontend
spec:
  containers: #리스트 형태로 여러 컨테이너 사용 가능
  - name: nginx-controller
    image: nginx

 

kubectl apply -f <파일명.yaml>

kubectl create -f <파일명.yaml> # 둘다 사용가능 

 

해당 yaml 파일 구조를 기억하기 힘들고 파일 상세 명세를 미리 만들려면 아래의 명령어로 제작 할 수 있다.

 

사용을 위한 구조
kubectl <options>  --dry-run -o yaml
실 사용 예시
kubectl run redis --image=redis --dry-run -o yaml

 

 

'Study > K8S' 카테고리의 다른 글

Service Account  (2) 2023.03.19
Docker Security  (0) 2023.03.19
Secret  (0) 2023.03.03
configMaps  (0) 2023.03.03
2. Replica & ReplicaSet 제작  (0) 2023.01.29