마스터 초기화

# kubeadm init
# kubeadm reset
# kubectl delete node {{node name}}
# kubeadm token create --print-join-command 

클러스터

# kubectl version
# kubectl get componentstatuses
# kubectl cluster-info
# kubectl config view

클러스터 노드

# kubectl get nodes
# kubectl describe node {nodeName}

클러스터 이벤트

# kubectl get events

클러스터 서비스

# kubectl get service
# kubectl get services --namespace=kube-system kube-dns

클러스터 해체

# kube-down.sh

포드

# kubectl get pods
# kubectl get pods --namespaces=kube-system
# kubectl describe pods
# kubectl describe pods {{pod name}}
# kubectl describe pods/{{pod name}}
# kubectl exec {{pod name}} -- curl <<IP>>

객체 생성, 업데이트, 삭제

yaml 를 사용한 객체 생성 및 업데이트. (생성 및 업데이트 명령은 동일함)

# kubectl run kuard --image=gcr.io/kuar-demo/kuard-amd64:1
# kubectl apply -f name.yaml

# kubectl delete -f name.yaml
# kubectl delete deployments/kuard
# kubectl delete pods/kuard
# kubectl delete {자원이름} {객체이름}


# kubectl run user-service --image={} --replicas={} --label={}
# kubectl expose deployment user-service
# kubectl get service -o wide
# kubectl edit deployment/user-service

# kubectl get endpoints user-service --watch
# kubectl edit service user-service
# kubectl describe service user-sercie


# kubectl port-forward kuard 8080:8080

데몬

# kubectl ger daemonSets --namespace=kube-system kube-proxy

디플로이먼트

# kubectl get deployments --namespace=kube-system kube-dns


네임스페이스 변경 

# kubectl config set-context myContext --namespace=context //각 다른 클러스터를 사용할때 사용
# kubectl config use-context myContext


라벨과 애노테이션

라벨 업데이트 (이름이 name 인 pod에 color=service 라벨 추가)

label, annotate 는 기본적으로 이미 존재하는 라벨에 덮어쓰기 불가. 

덮어쓰기를 수행하기 위해서는 --overwrite 옵션 사용.

# kubectl label pods name color=service

라벨 삭제.

# kubectl label pods name -color 

로그 

pod 내 다수 컨테이너가 있는 경우, -c 사용하여 특정 컨테이너 로그 추출.

# kubectl logs -f {pod name} 
# kubectl logs kuard

컨테이너 내부 접속.

# kubectl exec -it {pod name} --bash
# kubectl exec kuard date
# kubectl exec -it kuard ash
# kubectl exec -it {pod name} bash

컨테이너로 파일 복사

# kubectl cp {pod name}:/path/file /local/path/file 
# kubectl cp {pod name}:/captures/captrue1.txt ./capture1.txt
# kubetctl cp $HOME/config.txt {pod name}:/config.txt






  • No labels
Write a comment…