Skip to content

Commit ee7ae1d

Browse files
author
pospispa
committed
Added Verification Scenario for a Pod that Uses a PVC in Terminating State
The below PR: kubernetes/kubernetes#55873 modified scheduler in such a way that scheduling of a pod that uses a PVC in Terminating state fails. That's why verification of such scenario was added to documentation.
1 parent f0c4425 commit ee7ae1d

File tree

1 file changed

+85
-1
lines changed

1 file changed

+85
-1
lines changed

docs/tasks/administer-cluster/pvc-protection.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ parameters:
3838
type: pd-standard
3939
```
4040
41-
There are two scenarios: a PVC deleted by a user is either in active use or not in active use by a pod.
41+
Verification scenarios follow below.
4242
4343
### Scenario 1: The PVC is not in active use by a pod
4444
@@ -133,6 +133,90 @@ Events:
133133
```
134134
- Wait until the pod status is `Terminated` (either delete the pod or wait until it finishes). Afterwards, check that the PVC is removed.
135135

136+
### Scenario 3: A pod starts using a PVC that is in Terminating state
137+
138+
- Again, create the same PVC.
139+
- Create a first pod that uses the PVC:
140+
141+
```yaml
142+
kind: Pod
143+
apiVersion: v1
144+
metadata:
145+
name: app1
146+
spec:
147+
containers:
148+
- name: test-pod
149+
image: k8s.gcr.io/busybox:1.24
150+
command:
151+
- "/bin/sh"
152+
args:
153+
- "-c"
154+
- "date > /mnt/app1.txt; sleep 600 && exit 0 || exit 1"
155+
volumeMounts:
156+
- name: path-pvc
157+
mountPath: "/mnt"
158+
restartPolicy: "Never"
159+
volumes:
160+
- name: path-pvc
161+
persistentVolumeClaim:
162+
claimName: slzc
163+
```
164+
165+
- Wait until the pod status is `Running`, i.e. the PVC becomes in active use.
166+
- Delete the PVC that is now in active use by a pod and verify that the PVC is not removed but its status is `Terminating`:
167+
168+
```shell
169+
Name: slzc
170+
Namespace: default
171+
StorageClass: slow
172+
Status: Terminating (since Fri, 01 Dec 2017 14:47:55 +0000)
173+
Volume: pvc-803a1f4d-d6a6-11e7-9af0-42010a800002
174+
Labels: <none>
175+
Annotations: pv.kubernetes.io/bind-completed=yes
176+
pv.kubernetes.io/bound-by-controller=yes
177+
volume.beta.kubernetes.io/storage-provisioner=kubernetes.io/gce-pd
178+
Finalizers: [kubernetes.io/pvc-protection]
179+
Capacity: 4Gi
180+
Access Modes: RWO
181+
Events:
182+
Type Reason Age From Message
183+
---- ------ ---- ---- -------
184+
Normal ProvisioningSucceeded 52s persistentvolume-controller Successfully provisioned volume pvc-803a1f4d-d6a6-11e7-9af0-42010a800002 using kubernetes.io/gce-pd
185+
```
186+
187+
- Create a second pod that uses the same PVC:
188+
189+
```
190+
kind: Pod
191+
apiVersion: v1
192+
metadata:
193+
name: app2
194+
spec:
195+
containers:
196+
- name: test-pod
197+
image: gcr.io/google_containers/busybox:1.24
198+
command:
199+
- "/bin/sh"
200+
args:
201+
- "-c"
202+
- "date > /mnt/app1.txt; sleep 600 && exit 0 || exit 1"
203+
volumeMounts:
204+
- name: path-pvc
205+
mountPath: "/mnt"
206+
restartPolicy: "Never"
207+
volumes:
208+
- name: path-pvc
209+
persistentVolumeClaim:
210+
claimName: slzc
211+
```
212+
213+
- Verify that the scheduling of the second pod fails with the below warning:
214+
215+
```
216+
Warning FailedScheduling 18s (x4 over 21s) default-scheduler persistentvolumeclaim "slzc" is being deleted
217+
```
218+
219+
- Wait until the pod status of both pods is `Terminated` (either delete the pods or wait until they finish). Afterwards, check that the PVC is removed.
136220

137221
{% endcapture %}
138222

0 commit comments

Comments
 (0)