- 导出待删除namespace的json文件
kubectl get namespace jenkins -o json > tmp.json
- 删除tmp.json中的spec内容
删除前
删除后
- 通过api接口执行删除操作
为证书用户添加权限
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: cluster-admin-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: kube-apiserver
执行操作
curl -k --cacert /etc/kubernetes/ssl/kube-ca.pem --cert /etc/kubernetes/ssl/kube-apiserver.pem --key /etc/kubernetes/ssl/kube-apiserver-key.pem -H "Content-Type: application/json" -X PUT --data-binary @tmp.json https://127.0.0.1:6443/api/v1/namespaces/volcano-system/finalize
- 查看结果
kubectl get namespaces