Skip to content

Commit

Permalink
fix: Add Afinity where it's needed (#176)
Browse files Browse the repository at this point in the history
This change ensures our workloads are scheduled to nodes we're expecting.
At present, the assumption is that workloads without specific affinity
rules would land on "workers" however, that was wrong. This change ensure
that workloads such as memcached, mariadb, and rabbitmq are always
scheduled to our appropriate workers.

Signed-off-by: Kevin Carter <[email protected]>
  • Loading branch information
cloudnull authored Mar 23, 2024
1 parent 9013dab commit 5dd7f1a
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 9 deletions.
8 changes: 8 additions & 0 deletions kustomize/ingress/external/helm/ingress-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ pod:
default: kubernetes.io/hostname
weight:
default: 10
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: openstack-control-plane
operator: In
values:
- enabled
tolerations:
ingress:
enabled: false
Expand Down
8 changes: 8 additions & 0 deletions kustomize/ingress/grafana/helm/ingress-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ pod:
default: kubernetes.io/hostname
weight:
default: 10
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: openstack-control-plane
operator: In
values:
- enabled
tolerations:
ingress:
enabled: false
Expand Down
8 changes: 8 additions & 0 deletions kustomize/ingress/internal/helm/ingress-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ pod:
default: kubernetes.io/hostname
weight:
default: 10
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: openstack-control-plane
operator: In
values:
- enabled
tolerations:
ingress:
enabled: false
Expand Down
8 changes: 8 additions & 0 deletions kustomize/mariadb-cluster/base/mariadb-galera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ spec:

affinity:
enableAntiAffinity: true
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker

tolerations:
- key: "k8s.mariadb.com/ha"
Expand Down
10 changes: 9 additions & 1 deletion kustomize/mariadb-cluster/base/mariadb-maxscale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:

admin:
port: 8989
guiEnabled: true
guiEnabled: false

config:
params:
Expand Down Expand Up @@ -122,6 +122,14 @@ spec:

affinity:
enableAntiAffinity: true
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker

tolerations:
- key: "k8s.mariadb.com/ha"
Expand Down
18 changes: 18 additions & 0 deletions kustomize/mariadb-operator/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,26 @@ helmCharts:
cert:
certManager:
enabled: true
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker
metrics:
enabled: true
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker
includeCRDs: true
version: 0.27.0
namespace: mariadb-system
9 changes: 9 additions & 0 deletions kustomize/memcached/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,14 @@ helmCharts:
persistence:
enabled: true
size: 10Gi
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker
includeCRDs: true
namespace: openstack
10 changes: 9 additions & 1 deletion kustomize/prometheus-mysql-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ nodeSelector: {}

tolerations: []

affinity: {}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker

podLabels: {}

Expand Down
10 changes: 9 additions & 1 deletion kustomize/prometheus-postgres-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,15 @@ nodeSelector: {}

tolerations: []

affinity: {}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker

annotations: {
prometheus.io/scrape: "true",
Expand Down
10 changes: 9 additions & 1 deletion kustomize/prometheus-rabbitmq-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ nodeSelector: {}

tolerations: []

affinity: {}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker

loglevel: info
rabbitmq:
Expand Down
10 changes: 9 additions & 1 deletion kustomize/prometheus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,15 @@ alertmanager:
## Assign custom affinity rules to the alertmanager instance
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
##
affinity: {}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
Expand Down
5 changes: 3 additions & 2 deletions kustomize/rabbitmq-cluster/base/rabbitmq-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
annotations:
metallb.universe.tf/address-pool: pool1
spec:

replicas: 3
resources:
requests:
Expand Down Expand Up @@ -33,10 +34,10 @@ spec:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: openstack-control-plane
- key: node-role.kubernetes.io/worker
operator: In
values:
- enabled
- worker
# podAntiAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# - labelSelector:
Expand Down
11 changes: 10 additions & 1 deletion kustomize/sealed-secrets/base/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,16 @@ runtimeClassName: ""
## @param affinity [object] Affinity for Sealed Secret pods assignment
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
##
affinity: {}
affinity:
enableAntiAffinity: true
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker
## @param nodeSelector [object] Node labels for Sealed Secret pods assignment
## ref: https://kubernetes.io/docs/user-guide/node-selection/
##
Expand Down
11 changes: 10 additions & 1 deletion kustomize/vault-secrets-operator/base/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ controller:
# values:
# - antarctica-east1
# - antarctica-west1
affinity: {}
affinity:
enableAntiAffinity: true
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker

# Settings related to the kubeRbacProxy container. This container is an HTTP proxy for the
# controller manager which performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
Expand Down

0 comments on commit 5dd7f1a

Please sign in to comment.