kubernetes基本操作命令
常用命令
-------------------------------------------------------------------------------------
kubectl get cs 查看组件状态信息
kubectl get ns 查看命名空间名称
kubectl describe node node01 查看node01的详细信息
kubectl get node 查看node状态
kubectl get pod -n命名空间 查看服务的状态
kubectl exec –it [option] –n命名空间 bash 以bash进入服务里面
kubectl get deploy -n命名空间 查看deploy类型的命名服务
kubectl edit deploy [option] -n命名空间 eg:kubectl edit deploy mysql -nketan 编辑mysql配置文件
kubectl delete pod PODNAME -n NAMESPACE --grace-period=0 –force 强制删除一个pod
kubectl get deployment -n jenkins :查询 jenkins 命名空间下的 deployment
kubectl delete deployment jenkins2 -n jenkins :删除 jenkins 命名空间下的 jenkins2 的 deployment ,删除deployment 之后 pod 自动删除
kubectl delete ns 命名空间的名字
# 或者使用
kubectl delete ns 命名空间的名字 --force --grace-period=0
kubectl get deployment -w (-w表示监控)
kubectl get pods -l app 只看标签为app的pod
kubectl label pods pod-demo release=canary 修改标签
kubectl label pods pod-demo release=stable --overwrite 修改新标签并覆盖原有标签
kubeadm config images list 查看镜像列表
kubectl cp infoplus-v2.0-2019083.sql ketanyun/mysql-669bb87597-cxn45:/opt/. 将sql文件拷贝到mysql中
kubectl cp podname:logs ./ -n ketanyun 将pod内logs文件夹拷贝到 ./
kubectl exec -it mysql-669bb87597-cxn45 -n ketanyun bash 进入到mysql中
kubectl scale --replicas=2 deploy taskcenter -n ketanyun # --replicas=2表示将pod节点扩为两个
kubectl get ingress -n ketanyun 查看ingress
kubectl create secret tls tls-hrbeu --cert=./214932563040839.pem --key=./214932563040839.key --namespace=ketanyun 添加集群证书
kubectl run 创建并运行一个特定的映像,可能是复制的 eg:kubectl run nginx --image=nginx
kubectl get node --show-labels 查看node标签
nodeSelector:
kubernetes.io/hostname: k8s-nodeb
本文来自博客园,作者:Jerry·,转载请注明原文链接:https://www.cnblogs.com/jerry-0910/p/15396273.html