K8S 常用命令
kubectl get po --all-namespaces (显示所有节点)kubectl exec tomcat -pod-id -n [namespace]--netstat -tnl(查看pod端口)
1、pod 操作命令
kubectl get po --all-namespaces (显示所有节点)
kubectl get pods --all-namespaces -o wide (查看pod详细信息)
kubectl describe po devops-ci-backend-765fbd6cb4-9zx7g -n c7n-system
kubectl exec devops-ci-backend-7b47b7cd6-rzstx -n c7n-system -it /bin/sh
kubectl exec tomcat -pod-id -n [namespace] --netstat -tnl(查看pod端口)
kubectl delete po <your-pod-name> -n <name-space> --force --grace-period=0
# 批量删除命令
kubectl get pods -n kube-system | grep kube-proxy | awk '{print $1}' | xargs kubectl delete pods -n kube-system
2、pod monitor 命令
kubectl top pod -n steam-system
kubectl get pod -n steam-uat --watch
3、pod log 命令
kubectl logs --tail=100 devops-ci-backend-7f95bbc4d8-8v66n -n c7n-system
kubectl logs --since=2m devops-ci-backend-7f95bbc4d8-8v66n -n c7n-system
kubectl logs -f anubis-helm-86798d8cfb-lbnlh-c anubis-server
-n c7n-system
4、deployment 操作命令
kubectl rollout history deployment devops-ci --namespace=steam-uat
kubectl rollout history deployment devops-ci -n steam-uat --revision=183
kubectl rollout undo deployment/devops-ci -n steam-uat --to-revision=2
pod 扩容
kubectl scale --replicas=8 deployment spark-worker-deployment -n c7n-system
5、node 操作命令
设置当前节点不可调度(在client机器上面执行)
kubectl cordon jtdopsvpca03
设置当前节点可调度(在client机器上面执行)
kubectl uncordon jtdopsvpca03
节点下线
kubectl delete node jtdopsvpca03
6、namespace 操作命令
kubectl get ns
kubectl create namespace kube-app
7、pv/pvc 操作命令
kubectl get pvc -n gitlab
kubectl get pv -n gitlab
kubectl describe pv gitlab-mysql-pv -n gitlab
8、configmap操作命令
kubectl edit configmap gitlab-cm -n gitlab
配置命令
kubectl config view
查看全局限制
kubectl get LimitRange --all-namespaces
权限命令
kubectl get role
kubectl get clusterrole admin -o yaml
Security命令
kubectl create security tls tomcat-ingress-security --cert=tls.cert --key=tls.key
查看k8s命令文档
kubectl api-versions
kubectl explain pods
kubectl explain pods.metadata
kubelet
启动服务 systemctl start kubelet / service kubelet start
重启服务 systemctl restart kubelet / service kubelet restart
关闭服务 systemctl stop kubelet / service kubelet stop
查看服务状态 systemctl status kubelet / service kubelet reload
加入到启动项 systemctl enable kubelet / service kubelet status
集群命令
kubectl cluster-info
kubectl get nodes
更多推荐
所有评论(0)