Oteemo / charts

Helm chart repository
https://oteemo.github.io/charts
MIT License
181 stars 232 forks source link

nodeAffinity/nodeSelector doesn't impact postgres pod #313

Open chrisrobak opened 3 years ago

chrisrobak commented 3 years ago

The values.yml provides both a node selector + node affinity configs:

# Node labels for pod assignment
# Ref: https://kubernetes.io/docs/user-guide/node-selection/
nodeSelector:
  kubelet.kubernetes.io/sonarqube: "true"

and

# Affinity for pod assignment
# Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
       - matchExpressions:
          - key: kubelet.kubernetes.io/sonarqube
            operator: In
            values:
              - "true"

Which work as expected for k8s to schedule the sonarqube pod. However, this is not used / I don't see any affinity or selector configs available for the postgres pod, so the postgres pod will get scheduled on whatever node available in the cluster. The use case for this in my situation is we have the k8s cluster in EKS, and we basically have a few special type of nodes that we don't want random things scheduled on / have security group controls that prohibit communication between certain nodes. If/when the postgres pod gets scheduled on one of these restricted nodes sonarqube breaks. We'd like to either be able to specify the node affinity/anti-affinity or nodeSelector for the postgres pod as well.

I know we could create postgres outside of this chart and use the available vars to point sonarqube to use it instead so we have work arounds but it would be easier to just use the baked in postgres included in the chart and be able to control it's scheduling a bit more. Thanks!

MrSteveSmall commented 2 years ago

Try the following which works for me:

postgresql:
  primary:
    nodeSelector:
      kubelet.kubernetes.io/sonarqube: "true"

This is referenced at the end of the SonarQube configuration section starting at "You can also configure values for the PostgreSQL database via..." which will take you to the postgres configuration parameters. Just be sure to place all postgres parameters under the "postgresql" config section in your values file.

Hope that helps!