postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

Support affinity injection in custom resource

Open Conor-Quin opened this issue 7 years ago • 5 comments

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

Conor-Quin avatar Jul 30 '19 15:07 Conor-Quin

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 avatar Aug 07 '19 12:08 lkhomenk

@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}}"
                    ]   
                }]  
                }   
            }]  
            }   
        },
  1. We need to be able to define various other affinities such as podAntiAffinity podAffinity nodeAntiAffinity
  2. Ideally, we want this configuration defined in Pgcluster custom resource so that the crunchy operator can pick it up during the installation process.

NiharDudam avatar Aug 07 '19 19:08 NiharDudam

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.

lkhomenk avatar Aug 07 '19 20:08 lkhomenk

@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?

louiseohalloran avatar Sep 11 '19 09:09 louiseohalloran

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

Conor-Quin avatar Dec 03 '19 11:12 Conor-Quin