Skip to content

Commit

Permalink
Merge pull request #31 from projectsyn/add_affinity_parameter
Browse files Browse the repository at this point in the history
Support configuring affinity
  • Loading branch information
psy-q authored Mar 3, 2022
2 parents 81b4367 + a922919 commit 3d22de6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ docs/antora.yml:
entries:
- defaults
- no_container_limits
- affinity

Makefile:
includes:
Expand Down
5 changes: 5 additions & 0 deletions Makefile.additional.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

1 change: 1 addition & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
38 changes: 38 additions & 0 deletions tests/affinity.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3d22de6

Please sign in to comment.