Support affinity injection in custom resource
What is the motivation or use case for the feature? Currently, the only way to add affinity strategies to a cluster during deployment is using the pgo cli tool.
Support affinity injection in custom resource so that the operator can read it dynamically and distribute the postgres servers across the k8 nodes accordingly
Describe the solution you'd like Provide custom resource templates to allow for the insertion of affinity policies
affinity rules can be applied into config jsons of cluster_deployment, pgbouncer_template, etc. But I would love to have dynamic configs for cluster. Current approach with pgo-custom-config is really limited. And it's hard to manage multimple DB clusters with different configuration( e.g. affinity, envFrom etc)
@lkhomenk
Currently, affinity.json is hardcoded to use nodeAffinity as per https://github.com/CrunchyData/postgres-operator/blob/master/conf/postgres-operator/affinity.json
Here is the template example
"affinity": {
"nodeAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [{
"weight": 1,
"preference": {
"matchExpressions": [{
"key": "{{.NodeLabelKey}}",
"operator": "{{.OperatorValue}}",
"values": [
"{{.NodeLabelValue}}"
]
}]
}
}]
}
},
- We need to be able to define various other affinities such as
podAntiAffinitypodAffinitynodeAntiAffinity - Ideally, we want this configuration defined in
Pgclustercustom resource so that the crunchy operator can pick it up during the installation process.
We made our edits in cluster-deployment and other resources - removed that Affinity placeholder and hard-coded our affinity. It's not flexible solution at all, but it works. As I've seen from other issues - dynamic config s are kinda in development. But not sure what will be there.
@kssikora @lkhomenk @jmccormick2001 Maybe most of the parts of this problem can be solved by providing the ability to update individual files via a new custom config map instead of using pgo-config config map - which requires us to update all of the files together.
Is this something that can be considered?
This was resolved by allowing to edit individual files in the pgo-config configmap. This change was put in to 4.1.1
PR: https://github.com/CrunchyData/postgres-operator/commit/ee21e61509f43d872e0e9f7e30e92a2c3e17aba8
Closing