Basically, I want a create a sidecar container to scan ingress objects in my cluster and copy the generated file to other containers.
How can I achieve this?
Basically, I want a create a sidecar container to scan ingress objects in my cluster and copy the generated file to other containers.
How can I achieve this?
You can write a special Kubernetes program called a controller. This is an ordinary program, running in an ordinary pod, that uses the Kubernetes API to watch some set of objects and modify some other set of objects.
The main loop of a controller that does what you're describing can be pretty straightforward:
Then other pods can mount the ConfigMap like any other ConfigMap, it just happens to be owned by your controller rather than manually maintained.
This process isn't a great match for a "sidecar" container; it runs basically a completely independent process that's not tightly bound to a specific pod. This also avoids trying to manually modify container filesystems, which gives you resiliency in a couple of ways: if a new pod starts up it will automatically get the existing ConfigMap content; if your controller outright fails in some way then pods can keep using the old ConfigMap content until it restarts.