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

Support node/pod affinity, tolerations and topologySpreadConstraints that CNPG supports #717

Merged
merged 7 commits into from
Apr 19, 2024

Conversation

nhudson
Copy link
Collaborator

@nhudson nhudson commented Apr 17, 2024

The PR will add a new API field called affinity_configuration that is a type ClusterAffinity and topology_spread_constraints that is type ClusterTopologySpreadConstraints from CNPG. This will allow us to directly support all of the node/pod affinity and toleration types that CNPG supports.

The concept is that the control-plane will set the toleration/affinity when setting up the new instance, which we will just pass on to CNPG using their spec.

apiVersion: coredb.io/v1alpha1
kind: CoreDB
metadata:
  name: test-db-restore
spec:
  affinityConfiguration:
    podAntiAffinityType: preferred
    topologyKey: topology.kubernetes.io/zone
    nodeSelector: tembo.io/provisioner: spot
    tolerations:
      - key: "tembo.io/spot"
        operator: "Equal"
        value: "true"
        effect: "NoSchedule"
  topologySpreadConstraints:
    - maxSkew: <integer>
      minDomains: <integer> # optional
      topologyKey: <string>
      whenUnsatisfiable: <string>
      labelSelector: <object>

This change will move the default setting of affinity of CNPG from cnpg_cluster_from_cdb function into the CoreDB API with our current defaults

    podAntiAffinityType: preferred
    topologyKey: topology.kubernetes.io/zone

This will also do the same for the Pooler API and also the AppService Deployments.

The PlacementConfig does a lot of work specifically around converting the types. So we take in the ClusterAffinity and ClusterTopologySpreadConstraints they get converted into native Kubernetes API's and placed in PlacementConfig. The PlacementConfig has several methods that can convert the types to use with the Pooler or we can use the types directly in a normal Kubernetes Pod or Deployment if we wish.

fixes: PLAT-431

Copy link
Member

@ianstanton ianstanton left a comment

Choose a reason for hiding this comment

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

LGTM once everything is passing 🎉

@nhudson nhudson changed the title Support node affinity and tolerations that CNPG supports Support node/pod affinity, tolerations and topologySpreadConstraints that CNPG supports Apr 18, 2024
@nhudson nhudson merged commit 93276cb into main Apr 19, 2024
15 checks passed
@nhudson nhudson deleted the nhudson/PLAT-431 branch April 19, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants