我想通过Ansible Play从特定名称空间中删除所有Pod。在这里,我试图从命名空间“ postgres-ns”中删除所有postgres pod。
我正在使用下面的有趣游戏将其删除:
- name: Unistalling postgres from K8s
block:
- name: Removing Statefulsets & Service from "{{postgres_namespace}}"
action:
shell kubectl -n "{{postgres_namespace}}" delete statefulsets "{{postgres_release_name}}" && kubectl -n "{{postgres_namespace}}" delete service "{{postgres_release_name}}"-service
register: postgres_removal_status
- debug:
var: postgres_removal_status.stdout_lines
但出现此错误:
Error from server (NotFound): statefulsets.apps \"postgres\" not found
这是kc -n postgres-ns get all
的结果:
NAME READY STATUS RESTARTS AGE`
`pod/postgres-postgresql-0 1/1 Running 0 57s`
`NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE`
`service/postgres-postgresql ClusterIP 10.108.64.70 <none> 5432/TCP 57s`
`service/postgres-postgresql-headless ClusterIP None <none> 5432/TCP 57s`
`NAME READY AGE`
`statefulset.apps/postgres-postgresql 1/1 57s
有人可以帮我吗?
谢谢。
答案 0 :(得分:1)
Error from server (NotFound): statefulsets.apps \"postgres\" not found
这表示您要删除名称为postgress
的状态集,但是从您的get all
命令中,状态集的名称为statefulset.apps/postgres-postgresql
。您是否需要更新delete statefulsets "{{postgres_release_name}}"-postgresql
或传递正确的值postgres_release_name
?