diff --git a/content/appendix/kubectl/node.md b/content/appendix/kubectl/node.md index 4742715..47d1b17 100644 --- a/content/appendix/kubectl/node.md +++ b/content/appendix/kubectl/node.md @@ -1,4 +1,4 @@ -# Node 格式化输出 +# Node 相关 ## 表格输出各节点占用的 podCIDR @@ -121,7 +121,7 @@ ## 查看节点可用区分布情况 - + ``` bash kubectl get nodes -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.failure-domain\.beta\.kubernetes\.io\/zone}{"\n"}{end}' @@ -129,7 +129,7 @@ - + ```txt 10.83.96.127 100004 diff --git a/content/appendix/kubectl/pod.md b/content/appendix/kubectl/pod.md new file mode 100644 index 0000000..7e4268f --- /dev/null +++ b/content/appendix/kubectl/pod.md @@ -0,0 +1,41 @@ +## Pod 相关 + +## 清理 Evicted 的 pod + + + + + ``` bash + kubectl get pod -o wide --all-namespaces | awk '{if($4=="Evicted"){cmd="kubectl -n "$1" delete pod "$2; system(cmd)}}' + ``` + + + + + + ``` bash + kubectl get pod -o wide --all-namespaces | awk '{if($4!="Running"){cmd="kubectl -n "$1" delete pod "$2; system(cmd)}}' + ``` + + + + +## 升级镜像 + +``` bash +export NAMESPACE="kube-system" +export WORKLOAD_TYPE="daemonset" +export WORKLOAD_NAME="ip-masq-agent" +export CONTAINER_NAME="ip-masq-agent" +export IMAGE="ccr.ccs.tencentyun.com/library/ip-masq-agent:v2.5.0" +``` + +``` bash +kubectl -n $NAMESPACE patch $WORKLOAD_TYPE $WORKLOAD_NAME --patch '{"spec": {"template": {"spec": {"containers": [{"name": "$CONTAINER_NAME","image": "$IMAGE" }]}}}}' +``` + +## 查看某命名空间的镜像列表 + +```bash +kubectl -n kube-system get pod -ojsonpath='{range .items[*]}{range .spec.containers[*]}{"\n"}{.image}{end}{end}' | sort | uniq +``` diff --git a/content/appendix/sidebars.ts b/content/appendix/sidebars.ts index 7ed45f2..e3e55a6 100644 --- a/content/appendix/sidebars.ts +++ b/content/appendix/sidebars.ts @@ -14,6 +14,7 @@ const sidebars: SidebarsConfig = { items: [ 'get-raw', 'node', + 'pod', ] }, {