Reputation: 3723
I would like to add a volume to a container using the patch API (not apply)
This patch isn't working:
spec:
template:
spec:
volumes:
- name: cep-debug-dir
persistentVolumeClaim:
claimName: cep-pvc-debug
containers:
name: cep
- mountPath: /debug
name: cep-debug-dir
volumeMounts:
- mountPath: /debug
name: cep-debug-dir
My use case is to extend the deployment yaml adding a mounted volume for development and in general have a polymorphic deployment without repeating yaml code and having to maintain changes in two files.
p.s I'm using config map and if I could use an if to mount the volume conditionally it would bee cool.
Upvotes: 0
Views: 5766
Reputation: 3723
I printed the deployment json and used / edited the fields in json format and the patch worked In terminal
kubectl patch deploy cep --patch "$(cat cep-deploy-patch.yaml)"
file:
{
"spec": {
"template": {
"spec": {
"containers": [{
"name": "cep",
"volumeMounts": [{
"mountPath": "/debug",
"name": "cep-debug-dir"
}]
}],
"volumes": [{
"name": "cep-debug-dir",
"persistentVolumeClaim": {
"claimName": "cep-pvc-debug"
}
}]
}
}
}
}
Upvotes: 1