Skip to content

Commit

Permalink
Add the ability to set up custom podAntiAffinity (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
VyacheslavSemin authored Jan 23, 2024
1 parent 843f0d2 commit 6cc47e4
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ The `helm delete` command removes all the Kubernetes components associated with
| `docservice.podAnnotations` | Map of annotations to add to the Docservice deployment pods | `rollme: "{{ randAlphaNum 5 \| quote }}"` |
| `docservice.replicas` | Docservice replicas quantity. If the `docservice.autoscaling.enabled` parameter is enabled, it is ignored | `2` |
| `docservice.updateStrategy.type` | Docservice deployment update strategy type | `Recreate` |
| `docservice.customPodAntiAffinity` | Prohibiting the scheduling of Docservice Pods relative to other Pods containing the specified labels on the same node | `{}` |
| `docservice.podAffinity` | Defines [Pod affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity) rules for Docservice Pods scheduling by nodes relative to other Pods | `{}` |
| `docservice.nodeAffinity` | Defines [Node affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity) rules for Docservice Pods scheduling by nodes | `{}` |
| `docservice.initContainers` | Defines containers that run before docservice and proxy containers in the Docservice deployment pod. For example, a container that changes the owner of the PersistentVolume | `[]` |
Expand Down Expand Up @@ -471,6 +472,7 @@ The `helm delete` command removes all the Kubernetes components associated with
| `converter.updateStrategy.type` | Converter deployment update strategy type | `RollingUpdate` |
| `converter.updateStrategy.rollingUpdate.maxUnavailable` | Maximum number of Converter Pods unavailable during the update process. Used only when `converter.updateStrategy.type=RollingUpdate` | `25%` |
| `converter.updateStrategy.rollingUpdate.maxSurge` | Maximum number of Converter Pods created over the desired number of Pods. Used only when `converter.updateStrategy.type=RollingUpdate` | `25%` |
| `converter.customPodAntiAffinity` | Prohibiting the scheduling of Converter Pods relative to other Pods containing the specified labels on the same node | `{}` |
| `converter.podAffinity` | Defines [Pod affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity) rules for Converter Pods scheduling by nodes relative to other Pods | `{}` |
| `converter.nodeAffinity` | Defines [Node affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity) rules for Converter Pods scheduling by nodes | `{}` |
| `converter.initContainers` | Defines containers that run before docservice and proxy containers in the Docservice deployment pod. For example, a container that changes the owner of the PersistentVolume | `[]` |
Expand All @@ -491,6 +493,7 @@ The `helm delete` command removes all the Kubernetes components associated with
| `example.enabled` | Enables the installation of Example | `false` |
| `example.podAnnotations` | Map of annotations to add to the example pod | `rollme: "{{ randAlphaNum 5 \| quote }}"` |
| `example.updateStrategy.type` | Example StatefulSet update strategy type | `RollingUpdate` |
| `example.customPodAntiAffinity` | Prohibiting the scheduling of Example Pod relative to other Pods containing the specified labels on the same node | `{}` |
| `example.podAffinity` | Defines [Pod affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity) rules for Example Pod scheduling by nodes relative to other Pods | `{}` |
| `example.nodeAffinity` | Defines [Node affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity) rules for Example Pod scheduling by nodes | `{}` |
| `example.image.repository` | Example container image name | `onlyoffice/docs-example` |
Expand Down
9 changes: 6 additions & 3 deletions templates/deployments/converter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
{{- end }}
affinity:
podAntiAffinity:
{{- if eq .Values.podAntiAffinity.type "soft" }}
{{- if eq .Values.podAntiAffinity.type "soft" }}
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
Expand All @@ -52,7 +52,7 @@ spec:
- converter
topologyKey: {{ .Values.podAntiAffinity.topologyKey }}
weight: {{ .Values.podAntiAffinity.weight }}
{{- else if eq .Values.podAntiAffinity.type "hard" }}
{{- else if eq .Values.podAntiAffinity.type "hard" }}
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
Expand All @@ -61,7 +61,10 @@ spec:
values:
- converter
topologyKey: {{ .Values.podAntiAffinity.topologyKey }}
{{- end }}
{{- end }}
{{- with .Values.converter.customPodAntiAffinity }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.converter.podAffinity }}
podAffinity:
{{- toYaml . | nindent 10 }}
Expand Down
9 changes: 6 additions & 3 deletions templates/deployments/docservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
# app: docservice
affinity:
podAntiAffinity:
{{- if eq .Values.podAntiAffinity.type "soft" }}
{{- if eq .Values.podAntiAffinity.type "soft" }}
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
Expand All @@ -59,7 +59,7 @@ spec:
- docservice
topologyKey: {{ .Values.podAntiAffinity.topologyKey }}
weight: {{ .Values.podAntiAffinity.weight }}
{{- else if eq .Values.podAntiAffinity.type "hard" }}
{{- else if eq .Values.podAntiAffinity.type "hard" }}
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
Expand All @@ -68,7 +68,10 @@ spec:
values:
- docservice
topologyKey: {{ .Values.podAntiAffinity.topologyKey }}
{{- end }}
{{- end }}
{{- with .Values.docservice.customPodAntiAffinity }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.docservice.podAffinity }}
podAffinity:
{{- toYaml . | nindent 10 }}
Expand Down
6 changes: 5 additions & 1 deletion templates/statefulset/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ spec:
{{- if .Values.podSecurityContext.enabled }}
securityContext: {{- toYaml .Values.podSecurityContext.example | nindent 8 }}
{{- end }}
{{- if or .Values.example.podAffinity .Values.example.nodeAffinity }}
{{- if or .Values.example.customPodAntiAffinity .Values.example.podAffinity .Values.example.nodeAffinity }}
affinity:
{{- with .Values.example.customPodAntiAffinity }}
podAntiAffinity:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.example.podAffinity }}
podAffinity:
{{- toYaml . | nindent 10 }}
Expand Down
42 changes: 36 additions & 6 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ docservice:
## docservice.updateStrategy.type Docservice deployment update strategy type
updateStrategy:
type: Recreate
## docservice.customPodAntiAffinity Prohibiting the scheduling of Docservice Pods relative to other Pods containing the specified labels on the same node
## Example:
## customPodAntiAffinity:
## requiredDuringSchedulingIgnoredDuringExecution:
## - labelSelector:
## matchExpressions:
## - key: app
## operator: In
## values:
## - converter
## topologyKey: kubernetes.io/hostname
customPodAntiAffinity: {}
## Pod affinity rules for Docservice Pods scheduling by nodes relative to other Pods
## Pod affinity allow you to constrain which nodes Docservice Pods can be scheduled on based on the labels of Pods already running on that node
## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity
Expand All @@ -346,7 +358,6 @@ docservice:
## values:
## - store
## topologyKey: topology.kubernetes.io/zone
##
podAffinity: {}
## Node affinity rules for Docservice Pods scheduling by nodes
## Node affinity allow you to constrain which nodes Docservice Pod can be scheduled on based on node labels
Expand All @@ -362,7 +373,6 @@ docservice:
## values:
## - name1
## - name2
##
nodeAffinity: {}
## Horizontal Pod Autoscaling parameters
## Horizontal Pod Autoscaling is used for autoscaling of the Docservice deployment
Expand Down Expand Up @@ -651,6 +661,18 @@ converter:
maxUnavailable: 25%
## converter.updateStrategy.rollingUpdate.maxSurge Maximum number of Converter Pods created over the desired number of Pods
maxSurge: 25%
## converter.customPodAntiAffinity Prohibiting the scheduling of Converter Pods relative to other Pods containing the specified labels on the same node
## Example:
## customPodAntiAffinity:
## requiredDuringSchedulingIgnoredDuringExecution:
## - labelSelector:
## matchExpressions:
## - key: app
## operator: In
## values:
## - docservice
## topologyKey: kubernetes.io/hostname
customPodAntiAffinity: {}
## Pod affinity rules for Converter Pods scheduling by nodes relative to other Pods
## Pod affinity allow you to constrain which nodes Converter Pod can be scheduled on based on the labels of Pods already running on that node
## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity
Expand All @@ -666,7 +688,6 @@ converter:
## values:
## - database
## topologyKey: kubernetes.io/hostname
##
podAffinity: {}
## Node affinity rules for Converter Pods scheduling by nodes
## Node affinity allow you to constrain which nodes Converter Pod can be scheduled on based on node labels
Expand All @@ -681,7 +702,6 @@ converter:
## values:
## - zone1
## - zone2
##
nodeAffinity: {}
## Horizontal Pod Autoscaling parameters
## Horizontal Pod Autoscaling is used for autoscaling of the Converter deployment
Expand Down Expand Up @@ -792,6 +812,18 @@ example:
## example.updateStrategy.type Example StatefulSet update strategy type
updateStrategy:
type: RollingUpdate
## example.customPodAntiAffinity Prohibiting the scheduling of Example Pod relative to other Pods containing the specified labels on the same node
## Example:
## customPodAntiAffinity:
## requiredDuringSchedulingIgnoredDuringExecution:
## - labelSelector:
## matchExpressions:
## - key: app
## operator: In
## values:
## - docservice
## topologyKey: kubernetes.io/hostname
customPodAntiAffinity: {}
## Pod affinity rules for Example Pod scheduling by nodes relative to other Pods
## Pod affinity allow you to constrain which nodes Example Pod can be scheduled on based on the labels of Pods already running on that node
## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity
Expand All @@ -815,7 +847,6 @@ example:
## values:
## - database
## topologyKey: kubernetes.io/hostname
##
podAffinity: {}
## Node affinity rules for Example Pod scheduling by nodes
## Node affinity allow you to constrain which nodes Example Pod can be scheduled on based on node labels
Expand All @@ -839,7 +870,6 @@ example:
## values:
## - zone1
## - zone2
##
nodeAffinity: {}
## Example container image parameters
image:
Expand Down

0 comments on commit 6cc47e4

Please sign in to comment.