kubernetesコマンド大全
4400 ワード
#
kubectl cluster-info
systemctl status kube-apiserver
systemctl status kubelet
systemctl status kube-proxy
systemctl status kube-scheduler
systemctl status kube-controller-manager
systemctl status docker
node
# namespaces
kubectl get namespaces
# lable
kubectl label nodes 10.126.72.31 points=test
# lable
kubectl get nodes --show-labels
#
kubectl get componentstatuses
# Node
##
kubectl cordon k8s-node1
##
kubectl uncordon k8s-node1
# nodes
kubectl get nodes
# yaml
kubectl get -f xxx-yaml/
#
kubectl get resourcequota
# endpoints
kubectl get endpoints
# pods
# `kube-system` pods
kubectl get po -n kube-system
#
kubectl get pods -o wide --all-namespaces
#
kubectl get pod -o wide --namespace=kube-system
# svc
kubectl get svc --all-namespaces
#
kubectl get services --all-namespaces
# lable
kubectl get pods -l app=nginx -o yaml|grep podIP
# pod , pods
kubectl describe pod xxx
#
kubectl get events --all-namespaces
pod
# pods
kubectl delete pods --all
# lable pod serivce
kubectl delete pods,services -l name=
# ui server,
kubectl delete deployments kubernetes-dashboard --namespace=kube-system
kubectl delete services kubernetes-dashboard --namespace=kube-system
#
kubectl delete deployment kafka-1
# rc
kubectl delete rs --all && kubectl delete rc --all
## Terminating pod
kubectl delete deployment kafka-1 --grace-period=0 --force
#
kubectl apply -f xxx.yaml --record
#
kubectl rollout undo deployment javademo
#
kubectl rollout history deployment { }
#
kubectl logs -f kube-dns-699984412-vz1q6 -n kube-system
kubectl logs --tail=10 nginx
#
kubectl logs kube-dns-699984412-n5zkz -c kubedns --namespace=kube-system
kubectl logs kube-dns-699984412-vz1q6 -c dnsmasq --namespace=kube-system
kubectl logs kube-dns-699984412-mqb14 -c sidecar --namespace=kube-system
#
journalctl -f
#
sudo journalctl -f -u kube-scheduler.service
service kube-scheduler status -l -f
# yaml
kubectl -n kube-system get pod kube-apiserver-ha-proxy-k8s-node-1 -o yaml
#
kubectl scale rc xxxx --replicas=3
kubectl scale rc mysql --replicas=1
kubectl scale --replicas=3 -f foo.yaml
#
nohup kubectl proxy --address='10.1.70.247' --port=8001 --accept-hosts='^*$' >/dev/null 2>&1 &
#
kubectl exec kube-dns-699984412-vz1q6 -n kube-system -c kubedns ifconfig
kubectl exec kube-dns-699984412-vz1q6 -n kube-system -c kubedns ifconfig /bin/bash
#
kubectl exec kube-dns-4140740281-pfjhr -c etcd --namespace=kube-system etcdctl get /skydns/local/cluster/default/redis-master
while true; do sleep 1; done
# ( )
kubectl rollout pause deployment xxx
#
kubectl rollout resume deployment xxx
# 、cpu
kubectl set resources deployment xxx -c=xxx --limits=cpu=200m,memory=512Mi --requests=cpu=1m,memory=1Mi
# storageclass
kubectl patch storageclass -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
#
kubectl create -f dashboard-controller.yaml
kubectl delete -f dashboard-dashboard.yaml
# pods
kubectl exec xxx env
# dns
kubectl exec busybox -- nslookup kube-dns.kube-system
# kube-proxy
systemctl status kube-proxy -l
# token
kubectl get serviceaccount/kube-dns --namespace=kube-system -o yaml|grep token
# status :
CrashLoopBackOff: ,kubelet
InvalidImageName:
ImageInspectError:
ErrImageNeverPull:
ImagePullBackOff:
RegistryUnavailable:
ErrImagePull:
CreateContainerConfigError: kubelet
CreateContainerError:
m.internalLifecycle.PreStartContainer hook
RunContainerError:
PostStartHookError: hook
ContainersNotInitialized:
ContainersNotReady:
ContainerCreating:
PodInitializing:pod
pending : ( :cpu,memory)
Terminating: ( )
DockerDaemonNotReady:docker
NetworkPluginNotReady:
Evicted: , ,kubernetes Pod。 。