Kubernetes Common Commands

Source: Internet
Author: User
Tags etcd k8s

Kubectl

SOURCE < (KUBECTL completion bash) #命令补全

Start-State
  1. master
  2. systemctl daemon-reload
  3. systemctl start kube-apiserver
  4. systemctl start kube-controller-manager
  5. systemctl start kube-scheduler
  6. etcd
  7. systemctl start etcd.service
  8. client
  9. systemctl start kube-proxy -l
  10. systemctl start docker -l
  11. systemctl start kubelet -l
  12. status
  13. systemctl status etcd.service
  14. systemctl status kube-apiserver -l
  15. systemctl status kube-controller-manager -l
  16. systemctl status kube-scheduler
  17. systemctl status kube-proxy -l
  18. systemctl status docker -l
  19. systemctl status kubelet -l
Common commands
  1. kubectl get pods
  2. kubectl get rc
  3. kubectl get service
  4. kubectl get componentstatuses
  5. kubectl get endpoints
  6. kubectl cluster-info
  7. kubectl create -f redis-master-controller.yaml
  8. kubectl delete -f redis-master-controller.yaml
  9. kubectl delete pod nginx-772ai
  10. kubectl logs -f pods/heapster-xxxxx -n kube-system #查看日志
  11. kubectl scale rc redis-slave --replicas=3 #修改RC的副本数量,来实现Pod的动态缩放
  12. etcdctl cluster-health #检查网络集群健康状态
  13. etcdctl --endpoints=https://192.168.71.221:2379 cluster-health #带有安全认证检查网络集群健康状态
  14. etcdctl member list
  15. etcdctl set /k8s/network/config ‘{ "Network": "10.1.0.0/16" }‘
  16. etcdctl get /k8s/network/config
Base Advanced
  1. kubectl get services kubernetes-dashboard -n kube-system #查看所有service
  2. kubectl get deployment kubernetes-dashboard -n kube-system #查看所有发布
  3. kubectl get pods --all-namespaces #查看所有pod
  4. kubectl get pods -o wide --all-namespaces #查看所有pod的IP及节点
  5. kubectl get pods -n kube-system | grep dashboard
  6. kubectl describe service/kubernetes-dashboard --namespace="kube-system"
  7. kubectl describe pods/kubernetes-dashboard-349859023-g6q8c --namespace="kube-system" #指定类型查看
  8. kubectl describe pod nginx-772ai #查看pod详细信息
  9. kubectl scale rc nginx --replicas=5 # 动态伸缩
  10. kubectl scale deployment redis-slave --replicas=5 #动态伸缩
  11. kubectl scale --replicas=2 -f Redis -slave-deployment.< Span class= "PLN" >yaml  #动态伸缩
  12. kubectl exec -it redis-master-1033017107-q47hh /bin/bash #进入容器
  13. kubectl label nodes node1 zone=north #增加节点lable值 spec.nodeSelector: zone: north #指定pod在哪个节点
  14. kubectl get nodes -lzone #获取zone的节点
  15. kubectl label pod redis-master-1033017107-q47hh role=master #增加lable值 [key]=[value]
  16. kubectl label pod redis-master-1033017107-q47hh role- #删除lable值
  17. kubectl label pod redis-master-1033017107-q47hh role=backend --overwrite #修改lable值
  18. kubectl rolling-update redis-master -f redis-master-controller-v2.yaml #配置文件滚动升级
  19. kubectl rolling-update Redis -master --image =redis-master:2.0< Span class= "PLN" >  #命令升级
  20. kubectl rolling-update redis-master --image=redis-master:1.0 --rollback #pod版本回滚

Kubernetes Common Commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.