How to delete a persistent volume claim using a resource template? #10478
Unanswered
plopezgarcia
asked this question in
Q&A
Replies: 1 comment
-
This is a basic functional workflow that uses the resource template to create a apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: pvc-resource-deletion-example-
namespace: argo
spec:
templates:
- name: pvc-lifecycle
inputs: {}
outputs: {}
metadata: {}
dag:
tasks:
- name: create-pvc
template: create-pvc
arguments: {}
- name: delete-pvc
template: delete-pvc
arguments:
parameters:
- name: pvc-name
value: pvc-test
dependencies:
- create-pvc
- name: validate-pvc-deletion
template: validate-pvc-deletion
arguments:
parameters:
- name: pvc-name
value: pvc-test
dependencies:
- delete-pvc
- name: create-pvc
inputs: {}
outputs: {}
metadata: {}
resource:
action: create
manifest: |
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-test
namespace: argo
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- name: delete-pvc
inputs:
parameters:
- name: pvc-name
outputs: {}
metadata: {}
resource:
action: delete
manifest: |
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: "{{inputs.parameters.pvc-name}}"
namespace: "argo"
- name: validate-pvc-deletion
inputs:
parameters:
- name: pvc-name
outputs: {}
metadata: {}
script:
name: ""
image: alpine:latest
command:
- sh
- "-c"
resources: {}
source: >
if kubectl get pvc "{{inputs.parameters.pvc-name}}" -n argo >
/dev/null 2>&1; then
echo "PVC '{{inputs.parameters.pvc-name}}' still exists."
exit 1
else
echo "PVC '{{inputs.parameters.pvc-name}}' has been successfully deleted."
exit 0
fi
entrypoint: pvc-lifecycle
arguments: {} Resources
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I came across this problem: #3657 which is basically that the standard garbage collection doesn't work for persistent volume claims created at template level, so they remain there even when the workflow pod that instantiated the template has finished and has been removed using the podGC directive.
The OP claimed to have a solution
Found a way to do it by creating a new resource template to delete the PVCs.
but the code was never posted there and after a lot of tried failures here I am asking for help. In the issue above are my attempts. Can anyone please give a hand? Essentially I would just need the equivalent of this an argo template:"kubectl delete pvc pvc-my-volume -n argo"
(works perfectly from the command line) but I can't seem to figure it out. I thought this would work but doesn't:Thanks a lot in advance!
Beta Was this translation helpful? Give feedback.
All reactions