본문 바로가기

카테고리 없음

네임스페이스 관련 명령어

kubectl get pods -n defulat: -n을 주고 네임스페이스에 대한 파드를 볼 수 있음

kubectl get pods --all-namespaces : 네임스페이스에서 사용되는 모든 파드들을 보여줘

kubectl config view : 쿠버네티스 컨피그 정보를 보여줘

kubectl config set-context blue --cluster=kubernetes --user=blue --namespace=blue

  -  컨피그에 네임스페이스 등록하는 방법

 kubectl config use-context blue

 - 컨피그에 네임스페이스 등록후 기본 네임스페이스를 변경

kubectl delete namespaces blue : name스페이스 제거

 

네임스페이스를 실행하는 방법

 1. CLI로 실행

   - kubectl create namespace blue

 2. 메니페스트 파일로 실행

  - kubectl create namespace orenge --dry-run -o yaml > orenge.ns.yaml

     - orenge 네임스페이스를 실행하는데 진짜로 실행하지 말고 yaml로 실행가능한지 출력해주고 그걸 yaml파일에 담아줘

 

특정 파드를 특정 네임스페이스에서 생성하는 방법

  - metadata에 namescpe를 blue로 넣어주면됨

 

apiVersion: v1
kind: Pod
metadata:
    name: mypod
    namespace: blue
spec:
    containers:
     - image: nginx:1.14
       name: nginx
       ports:
        - containerPort: 80
        - containerPort: 443