kubectl get all -n kube-system -l k8s-app=kube-dns //根据label查找资源,这里查找kube-system域名下k8s-app标签为kube-dns的所有资源,例如pod、service、deployment等.注意不包括configmap 查看所有pod kubectl get pods --all-namespaces kubectl get pods -o wide kubectl get pods -o wide -w //可以看到...
4)再使用kubectl get nodes查看节点状态,发现d-node1虽然还处于Ready状态,但是同时还被禁止了调度,这意味着新的pod将不会被调度到d-node1上。 5)再查看nginx状态,没有任何变化,两个副本仍运行在d-node1和k-node2上; 6)执行drain命令,将运行在d-node1上运行的pod平滑的赶到其他节点上; 7)再查看nginx的状...
kubectl exec -p $(get_current_pod_name) my_script.sh Myget_current_pod_namereturns the name of the first pod matching a label, and that covers the case when I want to execute the script on any one and only one container. For fetching server logs of different pods/containers, for examp...
kubectl port-forward [pod-name] [local-port]:[remote-port] # Filtering Pods by Node Name kubectl get pods --field-selector spec.nodeName=[node-name] # Filtering Pods by Phase kubectl get pods --field-selector status.phase=Running # Delete a pod named "my-pod" in the default namespac...
kubectl logs -l app=frontend # 返回所有标记为 app=frontend 的 pod 的合并日志。 1. 2. 3. 4. 5. 查看节点 labels kubectl get node --show-lables 1. 重启pod kubectl get pod <POD名称> -n <NAMESPACE名称> -o yaml | kubectl replace --force -f - ...
kubectl logs-lapp=frontend# 返回所有标记为 app=frontend 的 pod 的合并日志。 查看节点 labels kubectlgetnode--show-lables 重启pod kubectlget pod <POD名称>-n <NAMESPACE名称>-o yaml | kubectl replace--force-f- 2、命令自动补全 source <(kubectl completionbash)# 在 bash 中设置当前 shell 的自动...
4、列某个namepsace 下某个service所代表的所有pod的名字。 注意最终要的只是名字。 先kubectl get service看下label 是什么,再kubectl get pod -l 看下面名字,然后需要保留的是名字 kubectl get pods "-o=custom-columns=NAME:.metadata.name" 代码语言:javascript ...
$ kubectlgetpod mypod-o yaml|sed's/\(image: myimage\):.*$/\1:v4/'|kubectl replace-f-$ kubectl label pods my-podnew-label=awesome # 添加标签 $ kubectl annotate pods my-pod icon-url=http://goo.gl/XXBTWq # 添加注解 $ kubectl autoscale deployment foo--min=2--max=10# 自动扩展 ...
# 根据重启次数排序列出 pod$ kubectl get pods --sort-by='.status.containerStatuses[0].restartCount' # 获取所有具有 app=cassandra 的 pod 中的 version 标签$ kubectl get pods --selector=app=cassandra rc -o \jsonpath='{.items[*].metadata.l...
[root@node01 ~]# kubectl get ns kube-flannel -o yamlapiVersion:v1kind:Namespacemetadata:annotations:kubectl.kubernetes.io/last-applied-configuration:|{"apiVersion":"v1","kind":"Namespace","metadata":{"annotations":{},"labels":{"pod-security.kubernetes.io/enforce":"privileged"},"name":"...