1 # namespace pods
2 kubectl get pods --all-namespaces
3 # pods, namespace
4 kubectl get pods kubernetes-dashboard-76479d66bb-nj8wr --namespace=kube-system
5 # pods
6 kubectl get pods -o wide kubernetes-dashboard-76479d66bb-nj8wr --namespace=kube-system
7 #
8 kubectl get cs
9 # deployment
10 kubectl get deployment --all-namespaces
11 # namespace pod
12 kubectl get pods --include-uninitialized
13 # deployment()
14 kubectl get deployment nginx-app
15 # rc servers
16 kubectl get rc,services
17 # pods ( , )
18 # ,node
19 kubectl describe pods xxxxpodsname --namespace=xxxnamespace
20 # , kubectl get
21 # pod
22 kubectl logs $POD_NAME
23 # pod
24 kubectl exec my-nginx-5j8ok -- printenv | grep SERVICE
25 #
26 kubectl get cs #
27 kubectl cluster-info #
28 kubectl get namespaces #
29 kubectl version #
30 kubectl api-versions # API
31 kubectl get events #
32 kubectl get nodes //
33 kubectl delete node k8s2 //
34 kubectl rollout status deploy nginx-test
35 #
36 kubectl create -f ./nginx.yaml #
37 kubectl create -f . # yaml
38 kubectl create -f ./nginx1.yaml -f ./mysql2.yaml #
39 kubectl create -f ./dir #
40 kubectl create -f https://git.io/vPieo # url
41 kubectl run -i --tty busybox --image=busybox ---- pod
42 kubectl run nginx --image=nginx # nginx
43 kubectl run mybusybox --image=busybox --replicas=5 ---- pod
44 kubectl explain pods,svc # pod svc
45 #
46 kubectl rolling-update python-v1 -f python-v2.json # pod frontend-v1
47 kubectl rolling-update python-v1 python-v2 --image=image:v2 #
48 kubectl rolling-update python --image=image:v2 # frontend pod
49 kubectl rolling-update python-v1 python-v2 --rollback #
50 cat pod.json | kubectl replace -f - # stdin JSON pod
51 , 。 。
52 kubectl replace --force -f ./pod.json
53 nginx RC , 80 8000
54 kubectl expose rc nginx --port=80 --target-port=8000
55
56 pod (tag) v4
57 kubectl get pod nginx-pod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
58 kubectl label pods nginx-pod new-label=awesome #
59 kubectl annotate pods nginx-pod icon-url=http://goo.gl/XXBTWq #
60 kubectl autoscale deployment foo --min=2 --max=10 # deployment “foo”
61 #
62 kubectl edit svc/docker-registry # docker-registry service
63 KUBE_EDITOR="nano" kubectl edit svc/docker-registry #
64 # pod
65 kubectl scale --replicas=3 rs/foo # foo 3
66 kubectl scale --replicas=3 -f foo.yaml # “foo” 。
67 kubectl scale --current-replicas=2 --replicas=3 deployment/mysql # deployment/mysql 2 3
68 kubectl scale --replicas=5 rc/foo rc/bar rc/baz #
69 kubectl rollout status deploy deployment/mysql #
70 #
71 kubectl delete -f ./pod.json # pod.json pod
72 kubectl delete pod,service baz foo # “baz” pod “foo” service
73 kubectl delete pods,services -l name=myLabel # name=myLabel pod serivce
74 kubectl delete pods,services -l name=myLabel --include-uninitialized # name=myLabel pod service,
75 kubectl -n my-ns delete po,svc --all # my-ns namespace pod serivce,
76 kubectl delete pods prometheus-7fcfcb9f89-qkkf7 --grace-period=0 --force
77
78 #
79 kubectl logs nginx-pod # dump pod (stdout)
80 kubectl logs nginx-pod -c my-container # dump pod (stdout,pod )
81 kubectl logs -f nginx-pod # pod (stdout)
82 kubectl logs -f nginx-pod -c my-container # pod (stdout,pod )
83 kubectl run -i --tty busybox --image=busybox -- sh # shell pod
84 kubectl attach nginx-pod -i #
85 kubectl port-forward nginx-pod 5000:6000 # pod 6000 5000
86 kubectl exec nginx-pod -- ls / # ( )
87 kubectl exec nginx-pod -c my-container -- ls / # (pod )
88 kubectl top pod POD_NAME --containers # pod
89 #
90 $ kubectl cordon k8s-node # my-node
91 $ kubectl drain k8s-node # my-node
92 $ kubectl uncordon k8s-node # my-node
93 $ kubectl top node k8s-node # my-node
94 $ kubectl cluster-info dump # stdout
95 $ kubectl cluster-info dump --output-directory=/path/to/cluster-state # /path/to/cluster-state
96 # (taint) ,
97 $ kubectl taint nodes foo dedicated=special-user:NoSchedule