Skip to content

Commit

Permalink
Merge pull request #150 from javieragomezo/master
Browse files Browse the repository at this point in the history
Map Pod Annotations to All Pods
  • Loading branch information
debdutdeb authored Jun 14, 2024
2 parents eeaff36 + 058dbba commit 4a6bc8c
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 14 deletions.
30 changes: 23 additions & 7 deletions rocketchat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,25 @@ The following table lists the configurable parameters of the Rocket.Chat chart a
| `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe | `3` |
| `livenessProbe.successThreshold` | Minimum consecutive successes for the probe | `1` |
| `global.tolerations` | common tolerations for all pods (rocket.chat and all microservices) | [] |
| `global.annotations` | common annotations for all pods (rocket.chat and all microservices) | {} |
| `tolerations` | tolerations for main rocket.chat pods (the `meteor` service) | [] |
| `microservices.enabled` | Use [microservices](https://docs.rocket.chat/quick-start/installing-and-updating/micro-services-setup-beta) architecture | `false` |
| `microservices.presence.replicas` | Number of replicas to run for the given service | `1` |
| `microservices.ddpStreamer.replicas` | Idem | `1` |
| `microservices.streamHub.replicas` | Idem | `1` |
| `microservices.accounts.replicas` | Idem | `1` |
| `microservices.authorization.replicas` | Idem | `1` |
| `microservices.nats.replicas` | Idem | `1` |
| `microservices.presence.tolerations` | Pod tolerations | [] |
| `microservices.ddpStreamer.tolerations` | Pod tolerations | [] |
| `microservices.streamHub.tolerations` | Pod tolerations | [] |
| `microservices.ddpStreamer.tolerations` | Pod tolerations | [] |
| `microservices.streamHub.tolerations` | Pod tolerations | [] |
| `microservices.accounts.tolerations` | Pod tolerations | [] |
| `microservices.authorization.tolerations` | Pod tolerations | [] |
| `microservices.nats.replicas` | Idem | `1` |
| `microservices.authorization.tolerations` | Pod tolerations | [] |
| `microservices.presence.annotations` | Pod annotations | {} |
| `microservices.ddpStreamer.annotations` | Pod annotations | {} |
| `microservices.streamHub.annotations` | Pod annotations | {} |
| `microservices.accounts.annotations` | Pod annotations | {} |
| `microservices.authorization.annotations` | Pod annotations | {} |
| `readinessProbe.enabled` | Turn on and off readiness probe | `true` |
| `readinessProbe.initialDelaySeconds` | Delay before readiness probe is initiated | `10` |
| `readinessProbe.periodSeconds` | How often to perform the probe | `15` |
Expand Down Expand Up @@ -206,28 +212,38 @@ By default, this chart creates one MongoDB instance as a Primary in a replicaset

For information on running Rocket.Chat in scaled configurations, see the [documentation](https://rocket.chat/docs/installation/docker-containers/high-availability-install/#guide-to-install-rocketchat-as-ha-with-mongodb-replicaset-as-backend) for more details.

### Adding tolerations
### Adding tolerations and annotations

To add common tolerations to all deployments
To add common tolerations and annotations to all deployments
```yaml
global:
tolerations:
- # here
annotations:
# here
```

Override tolerations for each microservice by adding to respective block's configuration. For example to override the global tolerations for ddp-streamer pods,
Override tolerations or annotations for each microservice by adding to respective block's configuration. For example to override the global tolerations and annotations for ddp-streamer pods,
```yaml
microservices:
ddpStreamer:
tolerations:
- # add here
annotations:
# add here
```

To override tolerations for `meteor` service, or the main rocket.chat deployment, add to the root tolerations key.
```yaml
tolerations:
- # ...
```
To override annotations for `meteor` service, or the main rocket.chat deployment, add to the root podAnnotations key.
```yaml
podAnnotations:
# add here
```


### Manage MongoDB secrets

Expand Down
18 changes: 18 additions & 0 deletions rocketchat/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,21 @@ Usage:
{{- end }}
{{- end }}
{{- end -}}

{{/* Get correct annotations */}}
{{- define "rocketchat.annotations" -}}
{{- $name := .name -}}
{{- $annotations := dict -}}
{{- with .context }}
{{- if eq $name "meteor" }}
{{ $annotations = .Values.podAnnotations}}
{{- else }}
{{ $annotations = get (get .Values.microservices $name) "annotations" }}
{{- end }}
{{- if (and (kindIs "map" $annotations) (gt (len $annotations) 0)) }}
{{- toYaml $annotations}}
{{- else }}
{{- toYaml .Values.global.annotations}}
{{- end }}
{{- end }}
{{- end -}}
10 changes: 3 additions & 7 deletions rocketchat/templates/chat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ spec:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}

annotations:
{{- end }}
annotations:
{{ include "rocketchat.annotations" (dict "name" "meteor" "context" $) | indent 8 }}
checksum/secret: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}


spec:
{{- with .Values.imagePullSecrets }}
Expand Down
2 changes: 2 additions & 0 deletions rocketchat/templates/microservices-account-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ spec:
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
annotations:
{{ include "rocketchat.annotations" (dict "name" "account" "context" $) | indent 8 }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "account" "context" $) | indent 8 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
annotations:
{{ include "rocketchat.annotations" (dict "name" "authorization" "context" $) | indent 8 }}

spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "authorization" "context" $) | indent 8 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ spec:
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
annotations:
{{ include "rocketchat.annotations" (dict "name" "ddpStreamer" "context" $) | indent 8 }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "ddpStreamer" "context" $) | indent 8 }}
Expand Down
2 changes: 2 additions & 0 deletions rocketchat/templates/microservices-presence-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ spec:
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
annotations:
{{ include "rocketchat.annotations" (dict "name" "presence" "context" $) | indent 8 }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "presence" "context" $) | indent 8 }}
Expand Down
2 changes: 2 additions & 0 deletions rocketchat/templates/microservices-stream-hub-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ spec:
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
annotations:
{{ include "rocketchat.annotations" (dict "name" "streamHub" "context" $) | indent 8 }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "streamHub" "context" $) | indent 8 }}
Expand Down

0 comments on commit 4a6bc8c

Please sign in to comment.