Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nodeAffinity for Postgres operator, and add new entry cloud-native-postgresql-v1.22 #2313

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

Daniel-Fan
Copy link
Contributor

@Daniel-Fan Daniel-Fan commented Nov 21, 2024

What this PR does / why we need it:

  • When ODLM configures Postgres operator pod with multiple replicas, ODLM will update overwrite the entire Affinity field for Postgres operator CSV/deployment. So the configuration for Postgres Operator should contain necessary nodeAffinity to ensure pods are distributed on nodes with supported architecture.
  • Add an new entry for cloud-native-postgresql-v1.22 in OperatorConfig, so the Postgres operator requested via cloud-native-postgresql-v1.22 will get the multi replicas configuration as well.

Which issue(s) this PR fixes:
Fixes https://github.ibm.com/IBMPrivateCloud/roadmap/issues/65071

Test

  1. Install dev build of SC2 4.6.x
  2. Patch CS operator CSV with image docker-na-public.artifactory.swg-devops.com/hyc-cloud-private-scratch-docker-local/ibmcom/common-service-operator-amd64:dev and ImagePullPolicy: Always
  3. Edit CommonService CR to configure multiple Postgres operator replicas
    apiVersion: operator.ibm.com/v3
    kind: CommonService
    metadata:
      name: common-service
    spec:
      license:
        accept: false
      operatorConfigs:
        - name: cloud-native-postgresql
          replicas: 2
      operatorNamespace: sc2-dev
      servicesNamespace: sc2-dev
      size: starterset
  4. Create OperandRequest to request cloud-native-postgresql-v1.22
  5. Verify the operator pod affinity section matching with what we defined in OperatorConfig
    ~ oc get pod postgresql-operator-controller-manager-1-22-7-64c7c847d6-l9pgs -ojsonpath='{.spec.affinity}' | jq
    
    {
      "nodeAffinity": {
        "requiredDuringSchedulingIgnoredDuringExecution": {
          "nodeSelectorTerms": [
            {
              "matchExpressions": [
                {
                  "key": "kubernetes.io/arch",
                  "operator": "In",
                  "values": [
                    "amd64",
                    "ppc64le",
                    "s390x"
                  ]
                }
              ]
            }
          ]
        }
      },
      "podAntiAffinity": {
        "preferredDuringSchedulingIgnoredDuringExecution": [
          {
            "podAffinityTerm": {
              "labelSelector": {
                "matchExpressions": [
                  {
                    "key": "app.kubernetes.io/name",
                    "operator": "In",
                    "values": [
                      "cloud-native-postgresql"
                    ]
                  }
                ]
              },
              "topologyKey": "topology.kubernetes.io/zone"
            },
            "weight": 90
          },
          {
            "podAffinityTerm": {
              "labelSelector": {
                "matchExpressions": [
                  {
                    "key": "app.kubernetes.io/name",
                    "operator": "In",
                    "values": [
                      "cloud-native-postgresql"
                    ]
                  }
                ]
              },
              "topologyKey": "kubernetes.io/hostname"
            },
            "weight": 50
          }
        ]
      }
    }

…e-postgresql-v1.22

Signed-off-by: Daniel Fan <fanyuchensx@gmail.com>
Copy link
Contributor

@YCShen1010 YCShen1010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@ibm-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Daniel-Fan, YCShen1010

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Daniel-Fan,YCShen1010]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ibm-ci-bot ibm-ci-bot merged commit cbb4c79 into IBM:release-sc2 Nov 22, 2024
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants