cloudnative-pg / cnpg-i-machinery

CloudNativePG Interface Machinery
Apache License 2.0
2 stars 3 forks source link

[Feature]: Helper to inject postgres socket directory #10

Open ringerc opened 4 months ago

ringerc commented 4 months ago

Is there an existing issue already for this feature request/idea?

What problem is this feature going to solve? Why should it be added?

Since many plugins that inject sidecars into postgres pods will want to communicate with postgres, a helper for injecting the pg socket volume mount would be useful.

Describe the solution you'd like

A helper method that finds the scratch-data Volume in the target Pod and injects a VolumeMount for it into a specified Container, expected to be a sidecar managed by the plugin. It should accept the path at which the socket directory should be mounted.

The VolumeMount should specify a SubMount of run so only the postgres socket directory gets mounted.

Something like

        corev1.VolumeMount{
            {
                Name:      "scratch-data",
                ReadOnly:  false,
                MountPath: "/var/run/postgresql",
                // postgres socket dir is in /run/run on the cnp pod
                SubPath:   config.PgSocketSubVolumeName,
       }

While this is trivial to implement in a plugin, the helper will know the correct socket volume name scratch-data which is not exposed in CNPG as a constant anywhere. It's also going to be common enough it just makes sense to add.

Describe alternatives you've considered

I just added it in my plugin code, it's trivial, but seems like something common enough to be worth doing in a helper.

Additional context

No response

Are you willing to actively contribute to this feature?

Yes

Code of Conduct