update at 2024-04-11 17:01:47

pull/158/head
roc 2024-04-11 17:01:47 +08:00
parent a22ef9c8d8
commit 469ca4494c
3 changed files with 45 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# Node 格式化输出 # Node 相关
## 表格输出各节点占用的 podCIDR ## 表格输出各节点占用的 podCIDR
@ -121,7 +121,7 @@
## 查看节点可用区分布情况 ## 查看节点可用区分布情况
<Tabs> <Tabs>
<TabItem value="cmd-allocated-mem" label="命令"> <TabItem value="cmd-zone" label="命令">
``` bash ``` bash
kubectl get nodes -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.failure-domain\.beta\.kubernetes\.io\/zone}{"\n"}{end}' kubectl get nodes -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.failure-domain\.beta\.kubernetes\.io\/zone}{"\n"}{end}'
@ -129,7 +129,7 @@
</TabItem> </TabItem>
<TabItem value="output-allocated-mem" label="输出效果"> <TabItem value="output-zone" label="输出效果">
```txt ```txt
10.83.96.127 100004 10.83.96.127 100004

View File

@ -0,0 +1,41 @@
## Pod 相关
## 清理 Evicted 的 pod
<Tabs>
<TabItem value="evicted" label="清理 Evicted 状态的 Pod">
``` bash
kubectl get pod -o wide --all-namespaces | awk '{if($4=="Evicted"){cmd="kubectl -n "$1" delete pod "$2; system(cmd)}}'
```
</TabItem>
<TabItem value="not-running" label="清理所有非 Running 状态的 Pod">
``` bash
kubectl get pod -o wide --all-namespaces | awk '{if($4!="Running"){cmd="kubectl -n "$1" delete pod "$2; system(cmd)}}'
```
</TabItem>
</Tabs>
## 升级镜像
``` 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
```

View File

@ -14,6 +14,7 @@ const sidebars: SidebarsConfig = {
items: [ items: [
'get-raw', 'get-raw',
'node', 'node',
'pod',
] ]
}, },
{ {