Kubectl 관리 도구 상용 명령

3775 단어 k8s
용기 와 미 러 삭제: 우선: kubectl get all 에서 이전에 만 든 nginx 용기 와 서비스 이름 을 찾 은 다음 kubectl delete deployment. apps / nginx kubectl delete service / nginx 를 삭제 합 니 다.
1. 창설
kubectl run nginx --replicas=3 --labels="app=nginx-example" --image=nginx:1.10 --port=80

2. 보기
#    
[root@master ~]# kubectl get deploy
NAME      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
nginx     3         3         3            3           18h
#       
[root@master ~]# kubectl get pods --show-labels
NAME                     READY     STATUS    RESTARTS   AGE       LABELS
nginx-5b8c7bbc4c-6zt6w   1/1       Running   0          18h       app=nginx-example,pod-template-hash=1647366707
nginx-5b8c7bbc4c-jmzf9   1/1       Running   0          18h       app=nginx-example,pod-template-hash=1647366707
nginx-5b8c7bbc4c-r7ljf   1/1       Running   0          18h       app=nginx-example,pod-template-hash=1647366707
#          
[root@master ~]# kubectl get pods -l  app=nginx-example
NAME                     READY     STATUS    RESTARTS   AGE
nginx-5b8c7bbc4c-6zt6w   1/1       Running   0          18h
nginx-5b8c7bbc4c-jmzf9   1/1       Running   0          18h
nginx-5b8c7bbc4c-r7ljf   1/1       Running   0          18h
#         
[root@master ~]# kubectl get pods -o wide
NAME                     READY     STATUS    RESTARTS   AGE       IP            NODE
nginx-5b8c7bbc4c-6zt6w   1/1       Running   0          18h       172.17.13.2   192.168.1.42
nginx-5b8c7bbc4c-jmzf9   1/1       Running   0          18h       172.17.94.5   192.168.1.40
nginx-5b8c7bbc4c-r7ljf   1/1       Running   0          18h       172.17.94.3   192.168.1.40

--

3. 발표
  kubectl get deploy   name   
#    name  ,
kubectl expose deployment nginx --port=88 --type=NodePort --target-port=80 --name=nginx-service
#       :
[root@master ~]# kubectl get svc
NAME            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes      ClusterIP   10.10.10.1             443/TCP        7d
nginx-service   NodePort    10.10.10.107           88:42784/TCP   24s
             :
curl 10.10.10.107:88         :http://192.168.1.40:42784
      :
kubectl describe service nginx-service

4. 고장 검사
#     
kubectl describe TYPE NAME_PREFIX
  :
replicaset.apps/nginx-5b8c7bbc4c
#     
kubectl logs nginx-xxx
  :
kubectl logs pod/nginx-5b8c7bbc4c-6zt6w
#        
kubectl exec –it nginx-xxx bash
  :
kubectl exec -it nginx-5b8c7bbc4c-jmzf9 bash

5. 항목 업데이트
# nginx     1.11,--record    
 kubectl set image deployment/nginx nginx=nginx:1.11 --record
      :
kubectl describe pod nginx-69fcd8b884-blnkg
            :
kubectl edit deployment/nginx
          :
      :
kubectl describe pod nginx-86b8d5d87c-4fwvr

      
[root@master ~]# kubectl rollout status deployment/nginx
deployment "nginx" successfully rolled out

      :
[root@master ~]# kubectl rollout history deployment/nginx
deployments "nginx"
REVISION  CHANGE-CAUSE
2         
3         
4         kubectl set image deployment/nginx nginx=nginx:1.13 --record=true
     3    :
[root@master ~]# kubectl rollout history deployment/nginx --revision=3

6. 스크롤 백 항목
#         
kubectl rollout undo deployment/nginx
#       
kubectl rollout undo deployment/nginx --to-revision=2
#      
kubectl describe pod nginx-86b8d5d87c-7c24f

7. 확장 프로젝트 던 전
#       5 
kubectl scale deploy/nginx --replicas=5
#     4 
kubectl scale deploy/nginx --replicas=4
  :
kubectl scale deployment nginx --replicas=4

8. 항목 삭제
kubectl delete deploy/nginx
kubectl delete service/nginx-service

좋은 웹페이지 즐겨찾기