kubectl get pods --all-namespaces
kubectl get pods kubernetes-dashboard-76479d66bb-nj8wr --namespace=kube-system
kubectl get pods -o wide kubernetes-dashboard-76479d66bb-nj8wr --namespace=kube-system
kubectl get cs
kubectl get deployment --all-namespaces
kubectl get pods --include-uninitialized
kubectl get deployment nginx-app
kubectl get rc,services
kubectl describe pods xxxxpodsname --namespace=xxxnamespace
kubectl logs $POD_NAME
kubectl exec my-nginx-5j8ok -- printenv | grep SERVICE
kubectl get cs
kubectl cluster-info
kubectl get namespaces
kubectl version
kubectl api-versions
kubectl get events
kubectl get nodes //获取全部节点
kubectl delete node k8s2 //删除节点
kubectl rollout status deploy nginx-test
kubectl create -f ./nginx.yaml
kubectl create -f .
kubectl create -f ./nginx1.yaml -f ./mysql2.yaml
kubectl create -f ./dir
kubectl create -f https://git.io/vPieo
kubectl run -i --tty busybox --image=busybox ----创建带有终端的pod
kubectl run nginx --image=nginx
kubectl run mybusybox --image=busybox --replicas=5 ----启动多个pod
kubectl explain pods,svc
kubectl rolling-update python-v1 -f python-v2.json
kubectl rolling-update python-v1 python-v2 --image=image:v2
kubectl rolling-update python --image=image:v2
kubectl rolling-update python-v1 python-v2 --rollback
cat pod.json | kubectl replace -f -
强制替换,删除后重新创建资源。会导致服务中断。
kubectl replace --force -f ./pod.json
为 nginx RC 创建服务,启用本地 80 端口连接到容器上的 8000 端口
kubectl expose rc nginx --port=80 --target-port=8000
更新单容器 pod 的镜像版本(tag)到 v4
kubectl get pod nginx-pod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
kubectl label pods nginx-pod new-label=awesome
kubectl annotate pods nginx-pod icon-url=http://goo.gl/XXBTWq
kubectl autoscale deployment foo --min=2 --max=10
kubectl edit svc/docker-registry
KUBE_EDITOR="nano" kubectl edit svc/docker-registry
kubectl scale --replicas=3 rs/foo
kubectl scale --replicas=3 -f foo.yaml
kubectl scale --current-replicas=2 --replicas=3 deployment/mysql
kubectl scale --replicas=5 rc/foo rc/bar rc/baz
kubectl rollout status deploy deployment/mysql
kubectl delete -f ./pod.json
kubectl delete pod,service baz foo
kubectl delete pods,services -l name=myLabel
kubectl delete pods,services -l name=myLabel --include-uninitialized
kubectl -n my-ns delete po,svc --all
kubectl delete pods prometheus-7fcfcb9f89-qkkf7 --grace-period=0 --force 强制删除
kubectl logs nginx-pod
kubectl logs nginx-pod -c my-container
kubectl logs -f nginx-pod
kubectl logs -f nginx-pod -c my-container
kubectl run -i --tty busybox --image=busybox -- sh
kubectl attach nginx-pod -i
kubectl port-forward nginx-pod 5000:6000
kubectl exec nginx-pod -- ls /
kubectl exec nginx-pod -c my-container -- ls /
kubectl top pod POD_NAME --containers
kubectl cordon k8s-node
kubectl drain k8s-node
kubectl uncordon k8s-node
kubectl top node k8s-node
kubectl cluster-info dump
kubectl cluster-info dump --output-directory=/path/to/cluster-state
kubectl taint nodes foo dedicated=special-user:NoSchedule