Skip to content

Commit

Permalink
Merge pull request #9 from ripienaar/broker_affinity
Browse files Browse the repository at this point in the history
support pod afinity for brokers
  • Loading branch information
ripienaar authored Jun 19, 2020
2 parents 59d95c5 + 92859e8 commit 3d3d9ac
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/broker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: broker
version: 0.0.4
version: 0.0.5
appVersion: 0.14.0
description: Choria Network Broker
keywords:
Expand Down
31 changes: 31 additions & 0 deletions charts/broker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,37 @@ At start the broker will auto enroll with a Cert Manager managed Certificate Aut
Please follow the steps outlined in [README.md](../README.md) to create the initial environment
and add the Choria Helm Repository.

## Pod Affinity

Generally you'd want to run more than one instance of the broker, it does not need to be an odd number,
and if you do you'd want to ensure the brokers run on different underlying nodes.

```yaml
broker:
clusterSize: 3

podAffinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- broker
topologyKey: "kubernetes.io/hostname"
```
Above will create 3 broker instances and spread them across your kubernetes nodes.
```nohighlight
$ kubectl get pod -o wide -n choria
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
broker-0 1/1 Running 0 2m22s 10.2.2.14 knode1 <none> <none>
broker-1 1/1 Running 0 2m29s 10.2.0.244 knode2 <none> <none>
broker-2 1/1 Running 0 2m43s 10.2.1.82 knode3 <none> <none>
```

## Values

|Variable|Description|Default|
Expand Down
6 changes: 5 additions & 1 deletion charts/broker/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ spec:
labels:
app: broker
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}

spec:
{{- if .Values.podAffinity }}
affinity:
{{ toYaml .Values.podAffinity | indent 8 }}
{{- end }}
serviceAccount: choria-csraccess
serviceAccountName: choria-csraccess
{{- if .Values.image.pullSecret }}
Expand Down
3 changes: 3 additions & 0 deletions charts/broker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ securityContext:
# additional annotations to apply to pods
podAnnotations: {}

# adds custom affinity rules to the pods
podAffinity: {}

# additional labels to apply to pods
podLabels: {}

Expand Down

0 comments on commit 3d3d9ac

Please sign in to comment.