$ kubectl -n kube-system get secret # All secrets with type'kubernetes.io/service-account-token' will allow to login. # Note that they have different privileges. NAME TYPE DATA AGE deployment-controller-token-frsqj kubernetes.io/service-account-token 3 22h $ kubectl -n kube-system describe secret deployment-controller-token-frsqj Name: deployment-controller-token-frsqj Namespace: kube-system Labels: <none> Annotations: kubernetes.io/service-account.name=deployment-controller kubernetes.io/service-account.uid=64735958-ae9f-11e7-90d5-02420ac00002
Type: kubernetes.io/service-account-token
Data ==== ca.crt: 1025 bytes namespace: 11 bytes token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZXBsb3ltZW50LWNvbnRyb2xsZXItdG9rZW4tZnJzcWoiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGVwbG95bWVudC1jb250cm9sbGVyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiNjQ3MzU5NTgtYWU5Zi0xMWU3LTkwZDUtMDI0MjBhYzAwMDAyIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRlcGxveW1lbnQtY29udHJvbGxlciJ9.OqFc4CE1Kh6T3BTCR4XxDZR8gaF1MvH4M3ZHZeCGfO-sw-D0gp826vGPHr_0M66SkGaOmlsVHmP7zmTi-SJ3NCdVO5viHaVUwPJ62hx88_JPmSfD0KJJh6G5QokKfiO0WlGN7L1GgiZj18zgXVYaJShlBSz5qGRuGf0s1jy9KOBt9slAN5xQ9_b88amym2GIXoFyBsqymt5H-iMQaGP35tbRpewKKtly9LzIdrO23bDiZ1voc5QZeAZIWrizzjPY5HPM1qOqacaY9DcGc7akh98eBJG_4vZqH2gKy76fMf0yInFTeNKr45_6fWt8gRM77DQmPwb3hbrjWXe1VvXX_g
# kubectl delete pods busybox-na3tm pod "busybox-na3tm" deleted # kubectl get pods NAME READY STATUS RESTARTS AGE busybox-vlzh3 0/1 ContainerCreating 0 14s # kubectl delete pod busybox-vlzh3 --grace-period=0 # kubectl delete pods --all pod "busybox-131cq" deleted pod "busybox-136x9" deleted pod "busybox-13f8a" deleted pod "busybox-13svg" deleted pod "busybox-1465m" deleted pod "busybox-14uz1" deleted pod "busybox-15raj" deleted pod "busybox-160to" deleted pod "busybox-16191" deleted # kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE default busybox-c9rnx 0/1 RunContainerError 0 23s
高票回答
您需要删除deployment,而deployment会自动删除pod和replica sets
列出所有deployment:
1
kubectl get deployments --all-namespaces
然后删除deployment:
1
kubectl delete -n NAMESPACE deployment DEPLOYMENT
NAMESPACE是其所在的命名空间,而DEPLOYMENT是deployment资源的名称。
在某些情况下,由于job或daemonset也可能正在运行。检查以下内容并运行相应的删除命令。
1 2 3 4 5
kubectl get jobs
kubectl get daemonsets.app --all-namespaces
kubectl get daemonsets.extensions --all-namespaces