나는 명령으로 포드를 시작했다
$ kubectl run busybox --image=busybox --restart=Never --tty -i --generator=run-pod/v1
문제가 발생하여 이제 삭제할 수 없습니다 Pod
.
아래 설명 된 방법을 사용해 보았지만 Pod
계속 재생됩니다.
$ 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
답변
배포를 삭제해야합니다. 그러면 포드 및 복제본 세트가 삭제됩니다. https://github.com/kubernetes/kubernetes/issues/24137
모든 배포를 나열하려면
kubectl get deployments --all-namespaces
그런 다음 배치를 삭제하려면 다음을 수행하십시오.
kubectl delete -n NAMESPACE deployment DEPLOYMENT
여기서 NAMESPACE는 네임 스페이스이고 DEPLOYMENT는 배포의 네임 스페이스 name
입니다.
경우에 따라 작업 또는 데몬 세트로 인해 실행 중일 수도 있습니다. 다음을 확인하고 적절한 삭제 명령을 실행하십시오.
kubectl get jobs
kubectl get daemonsets.app --all-namespaces
kubectl get daemonsets.extensions --all-namespaces
답변
배포, deamonset, statefulset …인지 또는 무엇인지 파악하려고 시도하는 대신 (내 경우에는 새로운 포드에 걸쳐있는 복제 컨트롤러였습니다.) 이미지를 확장하는 것이 무엇인지 확인하기 위해 I 이 명령으로 모든 리소스를 얻었습니다.
kubectl get all
물론 모든 네임 스페이스에서 모든 리소스를 얻을 수도 있습니다.
kubectl get all --all-namespaces
또는 검사하려는 네임 스페이스를 정의하십시오.
kubectl get all -n NAMESPACE_NAME
복제 컨트롤러가 내 문제에 대한 책임이 있음을 확인한 후 복제 컨트롤러를 삭제했습니다.
kubectl delete replicationcontroller/CONTROLLER_NAME
답변
포드의 이름이와 같으면 이름 name-xxx-yyy
이 replicasets.apps에 의해 제어 될 수 있습니다 name-xxx
. 포드를 삭제하기 전에 해당 복제 세트를 먼저 삭제해야합니다
kubectl delete replicasets.apps name-xxx
답변
상태 저장 세트도 찾아보십시오
kubectl get sts --all-namespaces
네임 스페이스에서 모든 상태 저장 세트를 삭제하는 방법
kubectl --namespace <yournamespace> delete sts --all
하나씩 삭제
kubectl --namespace ag1 delete sts mssql1
kubectl --namespace ag1 delete sts mssql2
kubectl --namespace ag1 delete sts mssql3
답변
경우에 따라 배포를 삭제해도 포드가 여전히 사라지지 않습니다. 이 경우 강제로 삭제하려면 아래 명령을 실행할 수 있습니다.
kubectl delete pods podname --grace-period=0 --force
답변
네임 스페이스의 모든 포드, 배포, 서비스 및 작업에 대한 정보를 제공합니다.
kubectl get pods,services, deployments, jobs
배포 또는 작업으로 포드를 만들 수 있습니다.
kubectl delete job [job_name]
kubectl delete deployment [deployment_name]
배포 또는 작업을 삭제하면 포드 다시 시작을 중지 할 수 있습니다.
답변
여기에 많은 답변이 특정 k8s 객체를 삭제하라는 메시지를 표시하지만 하나씩 대신 여러 객체를 동시에 삭제할 수 있습니다 .
kubectl delete deployments,jobs,services,pods --all -n <namespace>
필자의 경우 OLM- Operator Lifecycle Manager 와 함께 OpenShift 클러스터를 실행하고 있습니다. OLM은 배포를 제어하는 사람이므로 배포를 삭제했을 때 포드가 다시 시작되는 것을 중지하기에 충분하지 않았습니다.
OLM 과 해당 구독을 삭제 한 경우에만 배포, 서비스 및 포드가 사라졌습니다.
먼저 네임 스페이스의 모든 k8s 객체를 나열하십시오.
$ kubectl get all -n openshift-submariner
NAME READY STATUS RESTARTS AGE
pod/submariner-operator-847f545595-jwv27 1/1 Running 0 8d
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/submariner-operator-metrics ClusterIP 101.34.190.249 <none> 8383/TCP 8d
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/submariner-operator 1/1 1 1 8d
NAME DESIRED CURRENT READY AGE
replicaset.apps/submariner-operator-847f545595 1 1 1 8d
OLM은에 나열되어 있지 않으므로 get all
구체적으로 검색합니다.
$ kubectl get olm -n openshift-submariner
NAME AGE
operatorgroup.operators.coreos.com/openshift-submariner 8d
NAME DISPLAY VERSION
clusterserviceversion.operators.coreos.com/submariner-operator Submariner 0.0.1
이제 OLM, 구독, 배포, 복제 세트 등을 포함한 모든 개체를 삭제하십시오.
$ kubectl delete olm,svc,rs,rc,subs,deploy,jobs,pods --all -n openshift-submariner
operatorgroup.operators.coreos.com "openshift-submariner" deleted
clusterserviceversion.operators.coreos.com "submariner-operator" deleted
deployment.extensions "submariner-operator" deleted
subscription.operators.coreos.com "submariner" deleted
service "submariner-operator-metrics" deleted
replicaset.extensions "submariner-operator-847f545595" deleted
pod "submariner-operator-847f545595-jwv27" deleted
다시 객체 나열-모두 사라짐 :
$ kubectl get all -n openshift-submariner
No resources found.
$ kubectl get olm -n openshift-submariner
No resources found.
