diff --git a/.sync.yml b/.sync.yml index f365dca..4494c83 100644 --- a/.sync.yml +++ b/.sync.yml @@ -13,6 +13,7 @@ docs/antora.yml: entries: - defaults - no_container_limits + - affinity Makefile: includes: diff --git a/Makefile.additional.mk b/Makefile.additional.mk index 24bf7c2..ea38de1 100644 --- a/Makefile.additional.mk +++ b/Makefile.additional.mk @@ -7,3 +7,8 @@ test-nolimits: test .PHONY: test-default test-default: instance = defaults test-default: test + +.PHONY: test-affinity +test-affinity: instance = affinity +test-affinity: test + diff --git a/class/defaults.yml b/class/defaults.yml index e6d31b2..f610081 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -16,6 +16,7 @@ parameters: service_pwd: ?{vaultkv:${customer:name}/${cluster:name}/${_instance}/service_pwd} monitor_pwd: ?{vaultkv:${customer:name}/${cluster:name}/${_instance}/monitor_pwd} replicas: 2 + affinity: {} images: maxscale: image: ghcr.io/appuio/maxscale-docker diff --git a/component/main.jsonnet b/component/main.jsonnet index 4f9f7e4..34260f5 100644 --- a/component/main.jsonnet +++ b/component/main.jsonnet @@ -60,6 +60,7 @@ local deployment = kube.Deployment('maxscale') { replicas: params.replicas, template+: { spec+: { + affinity: params.affinity, containers_+: { maxscale: kube.Container('maxscale') { image: params.images.maxscale.image + ':' + params.images.maxscale.tag, diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index 299583b..e1615a1 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -90,6 +90,27 @@ default:: `?{vaultkv:${customer:name}/${cluster:name}/maxscale/service_pwd}` type:: string default:: `?{vaultkv:${customer:name}/${cluster:name}/maxscale/monitor_pwd}` += Pod Affinity Parameters + +By default, `affinity` is set to `{}` so the pods get no specific affinity. You can override this freely to [choose any pod affinity rules](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/). + +[horizontal] +type:: hash +default:: `{}` + +```yaml +parameters: + maxscale: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node-role.kubernetes.io/controlplane + operator: In + values: + - "false" +``` = Container Resource Parameters diff --git a/tests/affinity.yml b/tests/affinity.yml new file mode 100644 index 0000000..a7898f7 --- /dev/null +++ b/tests/affinity.yml @@ -0,0 +1,38 @@ +# Overwrite parameters here + +# parameters: {...} +--- +parameters: + _instance: maxscale + facts: + distribution: openshift4 + maxscale: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node-role.kubernetes.io/controlplane + operator: In + values: + - "false" + namespace: maxscale-test + master_only_listen_address: 127.0.0.1 + read_write_listen_address: 127.0.0.1 + db1_address: db1.mygalera.test.example.org + db1_port: 3307 + db2_address: db2.mygalera.test.example.org + db2_port: 3307 + db3_address: db3.mygalera.test.example.org + db3_port: 3307 + service_user: maxscale-testservice + monitor_user: maxscale-testmonitor + service_pwd: ?{vaultkv:${customer:name}/${cluster:name}/${_instance}/service_pwd} + monitor_pwd: ?{vaultkv:${customer:name}/${cluster:name}/${_instance}/monitor_pwd} + resources: + limits: + memory: 512Mi + cpu: 1234m + requests: + memory: 1024Mi + cpu: 123m