<p>I have a failed pod which is not properly created. I used these steps:</p>
<pre><code>kubernetes@kubernetes1:~$ cd /opt/registry
kubernetes@kubernetes1:/opt/registry$ kubectl create -f private-registry1.yaml
persistentvolume/pv1 created
kubernetes@kubernetes1:/opt/registry$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                       READY   STATUS              RESTARTS       AGE
default       private-repository-k8s-6ddbcd9c45-s6dfq    0/1     ContainerCreating   0              2d1h
kube-system   calico-kube-controllers-58dbc876ff-dgs77   1/1     Running             4 (125m ago)   2d13h
kube-system   calico-node-czmzc                          1/1     Running             4 (125m ago)   2d13h
kube-system   calico-node-q4lxz                          1/1     Running             4 (125m ago)   2d13h
kube-system   coredns-565d847f94-k94z2                   1/1     Running             4 (125m ago)   2d13h
kube-system   coredns-565d847f94-nt27m                   1/1     Running             4 (125m ago)   2d13h
kube-system   etcd-kubernetes1                           1/1     Running             5 (125m ago)   2d13h
kube-system   kube-apiserver-kubernetes1                 1/1     Running             5 (125m ago)   2d13h
kube-system   kube-controller-manager-kubernetes1        1/1     Running             5 (125m ago)   2d13h
kube-system   kube-proxy-97djs                           1/1     Running             5 (125m ago)   2d13h
kube-system   kube-proxy-d8bzs                           1/1     Running             4 (125m ago)   2d13h
kube-system   kube-scheduler-kubernetes1                 1/1     Running             5 (125m ago)   2d13h
</code></pre>
<p>As you can see the pod is stucked in status ContainerCreating. I tried to delete it:</p>
<pre><code>kubernetes@kubernetes1:/opt/registry$ kubectl get deployments --all-namespaces
NAMESPACE     NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
default       private-repository-k8s    0/1     1            0           2d2h
kube-system   calico-kube-controllers   1/1     1            1           2d14h
kube-system   coredns                   2/2     2            2           2d14h
</code></pre>
<p>Delete command:</p>
<pre><code>kubernetes@kubernetes1:/opt/registry$ kubectl delete -n default deployment private-repository-k8s
deployment.apps &quot;private-repository-k8s&quot; deleted

kubernetes@kubernetes1:/opt/registry$ kubectl get deployments --all-namespaces
NAMESPACE     NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
kube-system   calico-kube-controllers   1/1     1            1           2d14h
kube-system   coredns                   2/2     2            2           2d14h


kubernetes@kubernetes1:/opt/registry$ kubectl create -f private-registry1.yaml
Error from server (AlreadyExists): error when creating &quot;private-registry1.yaml&quot;: persistentvolumes &quot;pv1&quot; already exists
</code></pre>
<p><strong>private-registry1.yaml configuration:</strong></p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv1
spec:
  capacity:
    storage: 256Mi # specify your own size
  volumeMode: Filesystem
  persistentVolumeReclaimPolicy: Retain
  local:
    path: /opt/registry # can be any path
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions: # specify the node label which maps to your control-plane node.
        - key: kubernetes1
          operator: In
          values:
          - controlplane-1
  accessModes:
    - ReadWriteOnce # only 1 node will read/write on the path.
    # - ReadWriteMany # multiple nodes will read/write on the path
</code></pre>
<p>Do you know how I can delete <code>pv1</code>?</p>

Peter Penzov
<p>You can delete the PV using the following two commands:</p>
<p><code>kubectl delete pv &lt;pv_name&gt; --grace-period=0 --force</code></p>
<p>And then deleting the finalizer using:</p>
<p><code>kubectl patch pv &lt;pv_name&gt; -p '{&quot;metadata&quot;: {&quot;finalizers&quot;: null}}'</code></p>
<p>As you have created using a file, you can also use the following command to delete the pv:</p>
<p><code>kubectl delete -f private-registry1.yaml</code></p>
