Skip to content

Commit

Permalink
Add StatefulSet support
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Dec 20, 2023
1 parent d0f5858 commit c459aea
Show file tree
Hide file tree
Showing 10 changed files with 727 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/spell-ignore-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ ConfigMap
valueFrom
mountPath
devicePath
backoff
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ jobs:
version: ${{ matrix.helm }}
- run: helm dependency update .
- run: helm lint .
if: matrix.helm == 'latest'
- run: helm lint --values=tests/values.yaml .
if: matrix.helm == 'latest'

- name: Setup k3s/k3d
run: c2cciutils-k8s-install
Expand Down
2 changes: 1 addition & 1 deletion templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data:
{{- end }}
{{- range $serviceName, $serviceDefinition := .Values.services }}
{{- if or (eq $serviceDefinition.enabled true) ( and (hasKey $serviceDefinition "template") $serviceDefinition.template) }}
{{- if and (hasKey $serviceDefinition "service") (hasKey $serviceDefinition.service "name") }}
{{- if ( default $serviceDefinition.service dict ).name }}
SERVICE_{{ $serviceName | upper }}_NAME: {{ $serviceDefinition.service.name }}
{{- else }}
SERVICE_{{ $serviceName | upper }}_NAME: {{ include "common.fullname" ( dict "root" $ "service" $serviceDefinition "serviceName" $serviceName ) }}
Expand Down
94 changes: 91 additions & 3 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,105 @@
{{- if eq $serviceDefinition.enabled true }}
---
apiVersion: apps/v1
kind: Deployment
kind: {{ ( default $serviceDefinition.type "Deployment" ) }}
metadata:
name: {{ include "common.fullname" ( dict "root" $ "service" $serviceDefinition "serviceName" $serviceName ) }}
{{- include "common.metadata" ( dict "root" $ "service" $serviceDefinition "serviceName" $serviceName ) | nindent 2 }}
spec:
replicas: {{ $serviceDefinition.replicaCount | default 1 }}
{{- if eq ( default $serviceDefinition.type "Deployment" ) "Deployment" }}
{{- if $serviceDefinition.replicaCount }}
replicas: {{ $serviceDefinition.replicaCount }}
{{- end }}
{{- if $serviceDefinition.replicas }}
replicas: {{ $serviceDefinition.replicas }}
{{- end }}
revisionHistoryLimit: {{ $.Values.global.revisionHistoryLimit | default 0 }}
strategy:
type: RollingUpdate
type: {{ ( default $serviceDefinition.strategy dict ).type | default "RollingUpdate" }}
{{- with ( default $serviceDefinition.strategy dict ).rollingUpdate }}
rollingUpdate: {{ toYaml . | nindent 8 }}
{{- end }}
{{- if $serviceDefinition.progressDeadlineSeconds }}
progressDeadlineSeconds: {{ $serviceDefinition.progressDeadlineSeconds }}
{{- end }}
{{- if $serviceDefinition.minReadySeconds }}
minReadySeconds: {{ $serviceDefinition.minReadySeconds }}
{{- end }}
{{- if $serviceDefinition.paused }}
paused: {{ $serviceDefinition.paused }}
{{- end }}
selector:
matchLabels: {{- include "common.selectorLabels" ( dict "root" $ "service" $serviceDefinition "serviceName" $serviceName ) | nindent 6 }}
{{- end }}
{{- if eq ( default $serviceDefinition.type "Deployment" ) "StatefulSet" }}
{{- if $serviceDefinition.serviceName }}
serviceName: {{ $serviceDefinition.serviceName }}
{{- end }}
{{- if $serviceDefinition.replicaCount }}
replicas: {{ $serviceDefinition.replicaCount }}
{{- end }}
{{- if $serviceDefinition.replicas }}
replicas: {{ $serviceDefinition.replicas }}
{{- end }}
{{- if $serviceDefinition.minReadySeconds }}
minReadySeconds: {{ $serviceDefinition.minReadySeconds }}
{{- end }}
{{- if $serviceDefinition.podManagementPolicy }}
podManagementPolicy: {{ $serviceDefinition.podManagementPolicy }}
{{- end }}
{{- if $serviceDefinition.ordinals }}
ordinals: {{ $serviceDefinition.ordinals }}
{{- end }}
selector:
matchLabels: {{- include "common.selectorLabels" ( dict "root" $ "service" $serviceDefinition "serviceName" $serviceName ) | nindent 6 }}
{{- with $serviceDefinition.persistentVolumeClaimRetentionPolicy }}
persistentVolumeClaimRetentionPolicy: {{ . }}
{{- end }}
{{- with $serviceDefinition.updateStrategy }}
updateStrategy: {{ toYaml . | nindent 6 }}
{{- end }}
{{- with $serviceDefinition.volumeClaimTemplates }}
volumeClaimTemplates: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- if eq ( default $serviceDefinition.type "Deployment" ) "Job" }}
{{- if $serviceDefinition.backoffLimit }}
backoffLimit: {{ $serviceDefinition.backoffLimit }}
{{- end }}
{{- if $serviceDefinition.completions }}
completions: {{ $serviceDefinition.completions }}
{{- end }}
{{- if $serviceDefinition.parallelism }}
parallelism: {{ $serviceDefinition.parallelism }}
{{- end }}
{{- if $serviceDefinition.completionMode }}
completionMode: {{ $serviceDefinition.completionMode }}
{{- end }}
{{- if $serviceDefinition.backoffLimitPerIndex }}
backoffLimitPerIndex: {{ $serviceDefinition.backoffLimitPerIndex }}
{{- end }}
{{- if $serviceDefinition.maxFailedIndexes }}
maxFailedIndexes: {{ $serviceDefinition.maxFailedIndexes }}
{{- end }}
{{- if $serviceDefinition.activeDeadlineSeconds }}
activeDeadlineSeconds: {{ $serviceDefinition.activeDeadlineSeconds }}
{{- end }}
{{- if $serviceDefinition.ttlSecondsAfterFinished }}
ttlSecondsAfterFinished: {{ $serviceDefinition.ttlSecondsAfterFinished }}
{{- end }}
{{- if $serviceDefinition.suspend }}
suspend: {{ $serviceDefinition.suspend }}
{{- end }}
{{- if $serviceDefinition.podReplacementPolicy }}
podReplacementPolicy: {{ $serviceDefinition.podReplacementPolicy }}
{{- end }}
{{- with $serviceDefinition.podFailurePolicy }}
podFailurePolicy: {{ toYaml . | nindent 6 }}
{{- end }}
{{- with $serviceDefinition.selector }}
selector: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
template:
metadata: {{- include "common.podMetadata" ( dict "root" $ "service" $serviceDefinition "serviceName" $serviceName ) | nindent 6 }}
spec:
Expand Down
2 changes: 1 addition & 1 deletion templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
http:
paths:
{{- range $serviceName, $serviceDefinition := $.Values.services }}
{{- if and (eq $serviceDefinition.enabled true) (eq $serviceDefinition.ingress.enabled true) }}
{{- if and ( eq $serviceDefinition.enabled true ) ( eq ( default ( default $serviceDefinition.ingress dict ).enabled false ) true ) }}
- path: "{{ $serviceDefinition.ingress.path }}"
pathType: Prefix
backend:
Expand Down
2 changes: 1 addition & 1 deletion templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- range $serviceName, $serviceDefinition := .Values.services }}
{{- if eq $serviceDefinition.enabled true }}
{{- if and (eq $serviceDefinition.enabled true) $serviceDefinition.service }}
---
apiVersion: v1
kind: Service
Expand Down
Loading

0 comments on commit c459aea

Please sign in to comment.