zoukankan      html  css  js  c++  java
  • kubernetes常用命令

    kubectl

    source <(kubectl completion bash) #命令补全

    启动-状态

    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

    常用命令

    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

    基础进阶

    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.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 #命令升级
    20. kubectl rolling-update redis-master --image=redis-master:1.0 --rollback #pod版本回滚
  • 相关阅读:
    Microsoft Security Essentials
    android studio 引用远程仓库下载慢(JCenter下载慢)的办法
    Android studio Unable to start the daemon process
    Android studio 怎么使用已经下载好的Android SDK ?
    解决Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!
    U3d中实现A*寻路,附源文件
    [运维-服务器 – 1A] – nginx.conf(转)
    unity客户端与c++服务器之间的简单通讯_1
    [Java Web – Maven – 1A]maven 3.3.3 for windows 配置(转)
    [Android-2A] -仿IOS微信滑动删除_SwipeListview左滑删除例子
  • 原文地址:https://www.cnblogs.com/liyongsan/p/9114561.html
Copyright © 2011-2022 走看看