Attach extra volume in multiple running deployments without editing every deployment

Use Case:

We have scenario like to attach extra volume in multiple running deployments without editing every deployment.

We have to edit in one place and the changes needs to reflect in every deployment.

I can’t tell if you mean Deployment in the kubernetes API sense or something more abstract?

Assuming you mean kube - unless you have some custom controller that manages multiple Deployments, I don’t think there is an answer for you, at least not built-in. Each Deployment is a distinct thing, and there isn’t a macro template that controls them all.

You could maybe do something like a mutating admission control webhook which modifies API requests as they arrive, but that doesn’t solve for existing Deployments.

Thanks for your reply.

And also we have deployments like below which is running with the single volume. now we need to attach extra volume to the same.

how can we achieve this without editing the running deployment?

Ex:

apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd-deployment
namespace: httpd-test
labels:
app: httpd_app
spec:
selector:
matchLabels:
app: httpd_app
template:
metadata:
labels:
app: httpd_app
spec:
containers:
- name: httpd-container
image: httpd:latest
ports:
- containerPort: 80
volumeMounts:
- mountPath: “/data/test”
name: my-pv-storage
volumes:
- name: my-pv-storage
persistentVolumeClaim:
claimName: my-pv-claim

If your goal is to change the deployment, you have to edit the deployment. Why is that something you are trying to avoid?