UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
Commit ce858624 authored by Micah Nagel's avatar Micah Nagel
Browse files

change affinity

parent 159df461
No related branches found
No related tags found
1 merge request!19Modify Affinity
Pipeline #210652 passed
......@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
---
## [0.1.2-bb.0] - 2021-04-05
### Changed
- Modified the way affinity is passed to simplify and standardize
## [0.1.1-bb.3] - 2021-03-25
### Fixed
- Minio virtualservice disabled by default
......
......@@ -2,7 +2,7 @@
apiVersion: v2
name: mattermost
type: application
version: "0.1.1-bb.3"
version: "0.1.2-bb.0"
appVersion: "5.32.1"
description: "Deployment of mattermost"
keywords:
......
......@@ -60,35 +60,16 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 6 }}
{{- if or .Values.antiAffinity .Values.nodeAffinity }}
{{- if .Values.affinity }}
affinity:
{{- if eq .Values.antiAffinity "hard" }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: "kubernetes.io/hostname"
labelSelector:
matchLabels:
app: mattermost
installation.mattermost.com/installation: mattermost
installation.mattermost.com/resource: mattermost
{{- else if eq .Values.antiAffinity "soft" }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app: mattermost
installation.mattermost.com/installation: mattermost
installation.mattermost.com/resource: mattermost
{{- end }}
{{- with .Values.nodeAffinity }}
nodeAffinity:
{{ toYaml . | nindent 8 }}
{{- end }}
{{ toYaml .Values.affinity | nindent 6 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | nindent 6 }}
{{- end }}
database:
external:
secret: {{ .Values.database.secret | default (printf "%s-dbcreds" (include "mattermost.fullname" .)) }}
......
......@@ -58,17 +58,24 @@ resources: {}
# cpu: 250m
# memory: 256Mi
# Available options are "soft" and "hard"
antiAffinity: ""
nodeAffinity: {}
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: type
# operator: In
# values:
# - "mattermost-optimized"
affinity: {}
# podAntiAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# - topologyKey: "kubernetes.io/hostname"
# labelSelector:
# matchLabels:
# dont-schedule-with: mattermost
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: node-type
# operator: In
# values:
# - "mattermost"
nodeSelector: {}
# node-type: mattermost
mattermostEnvs: {}
......
# Node Affinity & Anti-Affinity with Mattermost
Affinity is exposed through values options for the Mattermost deployments. If you want to schedule your Mattermost pods to deploy on specific nodes you can do that through the `nodeAffinity` value and as needed the `antiAffinity` value. Additional info is provided below as well to help in configuring this.
Affinity is exposed through values options for this package. If you want to schedule your pods to deploy on specific nodes you can do that through the `nodeSelector` value and as needed the `affinity` value. Additional info is provided below as well to help in configuring this.
It is good to have a basic knowledge of node affinity and available options to you before customizing Mattermost in this way - the upstream kubernetes documentation [has a good walkthrough of this](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity).
It is good to have a basic knowledge of node affinity and available options to you before customizing in this way - the upstream kubernetes documentation [has a good walkthrough of this](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity).
## Values for NodeSelector
The `nodeSelector` value at the top level can be set to do basic node selection for deployments. See the below example for an example to schedule pods to only nodes with the label `node-type` equal to `mattermost`:
```yaml
nodeSelector:
node-type: mattermost
```
## Values for Affinity
The `nodeAffinity` value at the top level for Mattermost should be used to specify affinity. The format to include follows what you'd specify at a pod level. See the example below for scheduling the Mattermost pods only to nodes with the label `node-type` equal to `mattermost`:
The `affinity` value at the top level should be used to specify affinity. The format to include follows what you'd specify at a pod/deployment level. See the example below for scheduling the operator pods only to nodes with the label `node-type` equal to `mattermost`:
```yaml
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-type
operator: In
values:
- mattermost
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-type
operator: In
values:
- mattermost
```
## Values for Anti-Affinity
The `antiAffinity` value at the top level for Mattermost can be set to either `soft` or `hard` (soft = preferred, hard = required). Setting this will ensure that your Mattermost replicas do not deploy to the same node (or at least try to not deploy to the same node if using soft). See the below example for specifying a hard anti affinity:
The `affinity` value at the top level can be set in the same way to schedule pods based on anti-affinity. See the below example to schedule pods to not be present on the nodes that already have pods with the `dont-schedule-with: mattermost` label:
```yaml
antiAffinity: "hard"
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: "kubernetes.io/hostname"
labelSelector:
matchLabels:
dont-schedule-with: mattermost
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment