티스토리 뷰

[업데이트 2021.10.14 09:46]

 

- Bash alias 생성

# Create an alias kubectl command
alias kk=kubectl

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

 

- Pod, Deployment, Service 생성

# Pod
kubectl run nginx --image=nginx --dry-run=client -o yaml > my-pod.yaml

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

# Service
# Cluster IP
kubectl create service clusterip redis --tcp=6379:6379 --dry-run=client -o yaml > my-svc.yaml

# NodePort
kubectl create service nodeport nginx --tcp=80:80 --node-port=30080 --dry-run=client -o yaml > my-svc.yaml

- get 명령어

# namespace
kubectl get ns

# get all info
kubectl get all

# get all pods in current namespace
kubectl get pods -A

# get pods in a namespace
kubectl get pods -n myspace

# get pods with wide columns
kubectl get pods -o wide

# get a pod in all namespaces
kubectl get pods --all-namespace | grep red

# node
kubectl get node

# pod
kubectl get pods

# deployment
kubectl get deploy

# replicaset
kubectl get rs

# service
kubectl get svc

# cluster info
kubectl get cluster-info

# persistent volume
kubectl get pv

# persistent volume claim
kubectl get pvc

 

- Deployment rolling update

# Upgrade
kubectl set image deployment nginx-deployment nginx=nginx:1.161 --record=true

# Undo
kubectl rollout undo deployment nginx-deployment

# Undo(specific revision)
kubectl rollout undo deployment my-nginx --to-revision=2

# rollout status
kubectl rollout status deployment nginx-deployment

# rollout history
kubectl rollout history deployment nginx-deployment

- exec

kubectl exec -i -t webapp-1 -- /bin/sh

- Create a pod in specific node

# In pod yaml file

...

spec:
 nodeName: master

...

- Secret field base64 encoding

echo -n 'my-app' | base64

 

- Add taints to node

kubectl taint nodes node1 key=value:NoSchedule

 

- Add label to node

kubectl label nodes node02 app_type=beta

 

- Create a namespace

kubectl create namespace myspace01

- API resources

kubectl api-resources

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
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 31
글 보관함