Skip to content

Commit

Permalink
feat(charts): Add topologySpreadConstraint to whole stack
Browse files Browse the repository at this point in the history
  • Loading branch information
InputObject2 committed Nov 22, 2023
1 parent 6e4a870 commit 875d3a1
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 1 deletion.
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
26 changes: 25 additions & 1 deletion 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 @@ -111,10 +113,32 @@ spec:
configMap:
defaultMode: 493
name: init-prowlarr-cm
{{- with merge .Values.prowlarr.container.nodeSelector .Values.general.nodeSelector }}
{{- with merge .Values.prowlarr.container.nodeSelector .Values.general.nodeSelector }}
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 875d3a1

Please sign in to comment.