Skip to content

Commit

Permalink
fix(authelia): correctly set the pod strategy (#101)
Browse files Browse the repository at this point in the history
* fix(authelia): correctly set the pod strategy

* fix(authelia): include values.local.yaml

* docs(authelia): add some pod config docs
  • Loading branch information
james-d-elliott authored Oct 2, 2021
1 parent d7209f8 commit 06cf77f
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 20 deletions.
2 changes: 1 addition & 1 deletion charts/authelia/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: authelia
version: 0.5.7
version: 0.5.8
kubeVersion: ">= 1.13.0-0"
description: Authelia is a Single Sign-On Multi-Factor portal for web apps
type: application
Expand Down
26 changes: 26 additions & 0 deletions charts/authelia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,32 @@ This documents the parameters in the chart values. As the chart values are quite
|service.port |The exposed port on the ClusterIP Service |80 |
|service.clusterIP |The ClusterIP to assign to the Service |nil |

## Pod

|Parameter |Description |Default |
|:---------------------------------------:|:-----------------------------------------------------:|:----------------:|
|pod.kind |Configures the kind of pod: StatefulSet, Deployment, DaemonSet|DaemonSet |
|pod.annotations |Adds annotations specifically to the pod |{} |
|pod.labels |Adds labels specifically to the pod |{} |
|pod.replicas |Configures the replicas for Deployment's/statefulSet's |1 |
|pod.revisionHistoryLimit |Configures the revisionHistoryLimit |1 |
|pod.strategy.type |Configures the pods strategy/updateStrategy type |RollingUpdate |
|pod.strategy.rollingUpdate.maxSurge |Configures the pods rolling update max surge |25% |
|pod.strategy.rollingUpdate.maxUnavailable|Configures the pods rolling update max unavailable |25% |
|pod.strategy.rollingUpdate.partition |Configures the pods rolling update partition |1 |
|pod.securityContext.container |Configures the main container's security context |{} |
|pod.securityContext.pod |Configures the pod's security context |{} |
|pod.tolerations |Configures the pods tolerations |[] |
|pod.selectors.nodeSelector |Configures the pod to select nodes based on node labels|{} |
|pod.selectors.affinity.nodeAffinity |Configures the pod to select nodes based affinity |{} |
|pod.selectors.affinity.podAffinity |Configures the pod to select nodes based pods on the node|{} |
|pod.selectors.affinity.podAntiAffinity |Configures the pod to select nodes based pods on the node|{} |
|pod.env |Configures extra env to add to the node |[] |
|pod.resources.limits.cpu |Configures the resource limit for CPU |nil |
|pod.resources.limits.memory |Configures the resource limit for memory |nil |
|pod.resources.requests.cpu |Configures the resource request for CPU |nil |
|pod.resources.requests.memory |Configures the resource request for memory |nil |

## Ingress

To Document.
Expand Down
45 changes: 45 additions & 0 deletions charts/authelia/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,51 @@ Returns the smtp password or a randomly generated one
{{- end -}}
{{- end -}}

{{/*
Returns the rollingUpdate spec
*/}}
{{- define "authelia.rollingUpdate" -}}
{{- $result := dict -}}
{{- if eq "StatefulSet" (include "authelia.pod.kind" .) -}}
{{ $result = dict "partition" 0 }}
{{- if .Values.pod.strategy -}}
{{- if .Values.pod.strategy.rollingUpdate -}}
{{- $_ := set $result "partition" (default 0 .Values.pod.strategy.rollingUpdate.partition) -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{ $result = dict "maxSurge" "25%" "maxUnavailable" "25%" }}
{{- if .Values.pod.strategy -}}
{{- if .Values.pod.strategy.rollingUpdate -}}
{{- $_ := set $result "maxSurge" (default "25%" .Values.pod.strategy.rollingUpdate.maxSurge) "maxUnavailable" (default "25%" .Values.pod.strategy.rollingUpdate.maxUnavailable) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{ toYaml $result | indent 0 }}
{{- end -}}

{{/*
Returns the number of replicas
*/}}
{{- define "authelia.replicas" -}}
{{- if (include "authelia.stateful" .) }}
{{- 1 -}}
{{- else -}}
{{- default 1 .Values.pod.replicas -}}
{{- end -}}
{{- end -}}

{{/*
Returns the pod management policy
*/}}
{{- define "authelia.podManagementPolicy" -}}
{{- if (include "authelia.stateful" .) }}
{{- "Parallel" -}}
{{- else -}}
{{- default "Parallel" .Values.pod.managementPolicy -}}
{{- end -}}
{{- end -}}

{{/*
Returns the ingress hostname
*/}}
Expand Down
31 changes: 14 additions & 17 deletions charts/authelia/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,28 @@ spec:
selector:
matchLabels: {{ include "authelia.matchLabels" . | nindent 6 }}
revisionHistoryLimit: {{ default 5 .Values.pod.revisionHistoryLimit }}
replicas: {{ include "authelia.replicas" . }}
{{- if or (eq "Deployment" $kind) (eq "DaemonSet" $kind) }}
minReadySeconds: {{ default 0 .Values.pod.minReadySeconds }}
{{- end }}
{{- if (eq "Deployment" $kind)}}
replicas: {{ default 1 .Values.pod.replicas }}
{{- with $strategy := .Values.pod.strategy }}
{{- $type := include "authelia.deploymentStrategy" . }}
strategy:
type: {{ include "authelia.deploymentStrategy" . }}
{{- if and $strategy.rollingUpdate (eq (include "authelia.deploymentStrategy" $) "RollingUpdate") }}
rollingUpdate: {{ toYaml $strategy.rollingUpdate | nindent 6 }}
type: {{ $type }}
{{- if eq "RollingUpdate" $type }}
rollingUpdate: {{ (include "authelia.rollingUpdate" .) | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if (eq "DaemonSet" $kind) }}
{{- if (or (eq "DaemonSet" $kind) (eq "StatefulSet" $kind)) }}
{{- $type := include "authelia.deploymentStrategy" . }}
updateStrategy:
type: {{ include "authelia.deploymentStrategy" . }}
type: {{ $type }}
{{- if eq "RollingUpdate" $type }}
rollingUpdate: {{ (include "authelia.rollingUpdate" .) | nindent 6 }}
{{- end }}
{{- end }}
{{- if eq "StatefulSet" $kind }}
{{- if (include "authelia.stateful" .) }}
replicas: 1
podManagementPolicy: Parallel
{{- else }}
replicas: {{ default 1 .Values.pod.replicas }}
podManagementPolicy: {{ default "Parallel" .Values.pod.managementPolicy }}
{{- end }}
podManagementPolicy: {{ include "authelia.podManagementPolicy" . }}
serviceName: {{ default (include "authelia.name" .) .Values.pod.serviceName }}
{{- end }}
{{- if eq "Deployment" $kind }}
Expand Down Expand Up @@ -79,7 +76,7 @@ spec:
{{- if .Values.rbac.enabled }}
serviceAccountName: {{ default (include "authelia.name" .) .Values.rbac.serviceAccountName }}
{{- end }}
{{ if .Values.pod.enableServiceLinks }}
{{- if .Values.pod.enableServiceLinks }}
enableServiceLinks: true
{{- else }}
enableServiceLinks: false
Expand Down
7 changes: 6 additions & 1 deletion charts/authelia/values.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ pod:
replicas: 1
revisionHistoryLimit: 5

updateStrategy: RollingUpdate
strategy:
type: RollingUpdate
# rollingUpdate:
# partition: 1
# maxSurge: 25%
# maxUnavailable: 25%

securityContext:
container: {}
Expand Down
7 changes: 6 additions & 1 deletion charts/authelia/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ pod:
replicas: 1
revisionHistoryLimit: 5

updateStrategy: RollingUpdate
strategy:
type: RollingUpdate
# rollingUpdate:
# partition: 1
# maxSurge: 25%
# maxUnavailable: 25%

securityContext:
container: {}
Expand Down

0 comments on commit 06cf77f

Please sign in to comment.