Skip to content

Commit

Permalink
feat(charts): Add topologySpreadConstraint to whole stack
Browse files Browse the repository at this point in the history
feat(charts): Add topologySpreadConstraint to whole stack
  • Loading branch information
kubealex authored Nov 25, 2023
2 parents 856c5f7 + 875d3a1 commit 9744331
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 0 deletions.
22 changes: 22 additions & 0 deletions helm-charts/k8s-mediaserver/templates/jackett-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ spec:
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.general.podDistribution "cluster" }}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
weight: 100
{{- else if eq .Values.general.podDistribution "spread" }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
---
### SERVICES
apiVersion: v1
Expand Down
24 changes: 24 additions & 0 deletions helm-charts/k8s-mediaserver/templates/plex-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ metadata:
labels:
{{- include "k8s-mediaserver.labels" . | nindent 4 }}
spec:
strategy:
type: Recreate
replicas: {{ .Values.plex.replicaCount }}
selector:
matchLabels:
Expand Down Expand Up @@ -81,6 +83,28 @@ spec:
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.general.podDistribution "cluster" }}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
weight: 100
{{- else if eq .Values.general.podDistribution "spread" }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
---
### SERVICE
apiVersion: v1
Expand Down
24 changes: 24 additions & 0 deletions helm-charts/k8s-mediaserver/templates/prowlarr-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ metadata:
labels:
{{- include "k8s-mediaserver.labels" . | nindent 4 }}
spec:
strategy:
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down Expand Up @@ -115,6 +117,28 @@ spec:
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.general.podDistribution "cluster" }}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
weight: 100
{{- else if eq .Values.general.podDistribution "spread" }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
---
### SERVICES
apiVersion: v1
Expand Down
22 changes: 22 additions & 0 deletions helm-charts/k8s-mediaserver/templates/radarr-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,28 @@ spec:
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.general.podDistribution "cluster" }}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
weight: 100
{{- else if eq .Values.general.podDistribution "spread" }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
---
### SERVICES
apiVersion: v1
Expand Down
24 changes: 24 additions & 0 deletions helm-charts/k8s-mediaserver/templates/sabnzbd-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ metadata:
labels:
{{- include "k8s-mediaserver.labels" . | nindent 4 }}
spec:
strategy:
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down Expand Up @@ -424,6 +426,28 @@ spec:
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.general.podDistribution "cluster" }}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
weight: 100
{{- else if eq .Values.general.podDistribution "spread" }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
---
### SERVICES
apiVersion: v1
Expand Down
22 changes: 22 additions & 0 deletions helm-charts/k8s-mediaserver/templates/sonarr-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ spec:
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.general.podDistribution "cluster" }}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
weight: 100
{{- else if eq .Values.general.podDistribution "spread" }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
---
### SERVICES
apiVersion: v1
Expand Down
24 changes: 24 additions & 0 deletions helm-charts/k8s-mediaserver/templates/transmission-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ metadata:
labels:
{{- include "k8s-mediaserver.labels" . | nindent 4 }}
spec:
strategy:
type: Recreate
replicas: 1
selector:
matchLabels:
Expand Down Expand Up @@ -191,6 +193,28 @@ spec:
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.general.podDistribution "cluster" }}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
weight: 100
{{- else if eq .Values.general.podDistribution "spread" }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
---
### SERVICES
apiVersion: v1
Expand Down
1 change: 1 addition & 0 deletions helm-charts/k8s-mediaserver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ general:
ingress_host: k8s-mediaserver.k8s.test
plex_ingress_host: k8s-plex.k8s.test
image_tag: latest
podDistribution: cluster # can be "spread" or "cluster"
#UID to run the process with
puid: 1000
#GID to run the process with
Expand Down

0 comments on commit 9744331

Please sign in to comment.