From ce39639fa61d89272927505f4af56b681442f10a Mon Sep 17 00:00:00 2001 From: aniketgohelimp <123355145+aniketgohelimp@users.noreply.github.com> Date: Sun, 11 Jun 2023 21:04:43 +0530 Subject: [PATCH] Feat/statefulset polymorphic support (#36) Feat:Add Statefulset in musketeers --- charts/polymorphic-app/Chart.yaml | 3 +- .../polymorphic-app/ci/override-values.yaml | 25 ++++++++++++++++ charts/polymorphic-app/templates/service.yaml | 30 +++++++++++++++---- 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 charts/polymorphic-app/ci/override-values.yaml diff --git a/charts/polymorphic-app/Chart.yaml b/charts/polymorphic-app/Chart.yaml index d67a945..e69654c 100644 --- a/charts/polymorphic-app/Chart.yaml +++ b/charts/polymorphic-app/Chart.yaml @@ -4,6 +4,5 @@ description: A Helm chart for deploying any custom applications, specifically po maintainers: - name: improwised type: application - -version: 1.1.0 +version: 1.2.0 appVersion: 1.0.0 diff --git a/charts/polymorphic-app/ci/override-values.yaml b/charts/polymorphic-app/ci/override-values.yaml new file mode 100644 index 0000000..d4210af --- /dev/null +++ b/charts/polymorphic-app/ci/override-values.yaml @@ -0,0 +1,25 @@ +services: +- name: demo + image: + repository: nginx + tag: latest + healthcheck: + enabled: false + volumeMounts: + - name: data + mountPath: /data + type: StatefulSet + args: [] + env: [] + envFrom: [] + nodeSelector: {} + tolerations: [] + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: ["ReadWriteOnce"] + # storageClassName: "" + resources: + requests: + storage: 1Gi diff --git a/charts/polymorphic-app/templates/service.yaml b/charts/polymorphic-app/templates/service.yaml index b1aa4b7..7529cc5 100644 --- a/charts/polymorphic-app/templates/service.yaml +++ b/charts/polymorphic-app/templates/service.yaml @@ -1,7 +1,7 @@ {{- range .Values.services }} --- apiVersion: {{ include "deployment.apiVersion" $ }} -kind: Deployment +kind: {{ if eq .type "StatefulSet"}}StatefulSet{{- else }}Deployment{{- end }} metadata: name: "{{ $.Release.Name }}-{{ .name | default $.Values.serviceTemplate.name }}-svc" labels: @@ -12,12 +12,18 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: + {{ if .type }} + {{- else }} strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 50% maxSurge: 100% + {{- end }} replicas: {{ .minReplicaCount | default $.Values.serviceTemplate.minReplicaCount }} + {{ if eq .type "StatefulSet"}} + serviceName: "{{ $.Release.Name }}-{{ .name | default $.Values.serviceTemplate.name }}-svc" + {{- end }} selector: matchLabels: {{- include "polymorphic-app.selectorLabels" $ | nindent 6 }} @@ -146,7 +152,6 @@ spec: periodSeconds: {{ .healthcheck.periodSeconds | default $.Values.serviceTemplate.healthcheck.periodSeconds | default "20" }} {{- end }} {{- end }} - volumes: {{- if .volumes }} {{ toYaml .volumes | indent 8 }} @@ -178,7 +183,17 @@ spec: tolerations: {{ toYaml . | indent 8 }} {{- end }} - +{{- if .volumeClaimTemplates }} + volumeClaimTemplates: + +{{ toYaml .volumeClaimTemplates | indent 8 }} + {{- end }} + {{- if $.Values.volumeClaimTemplates }} +{{ toYaml $.Values.volumeClaimTemplates | indent 8 }} + {{- end }} + {{- if $.Values.serviceTemplate.volumeClaimTemplates }} +{{ toYaml $.Values.serviceTemplate.volumeClaimTemplates | indent 8 }} + {{- end }} {{- if .autoscaling | default $.Values.serviceTemplate.autoscaling }} --- apiVersion: autoscaling/v2beta2 @@ -191,7 +206,7 @@ metadata: spec: scaleTargetRef: apiVersion: apps/v1 - kind: Deployment + kind: {{ if eq .type "StatefulSet"}}StatefulSet{{- else }}Deployment{{- end }} name: "{{ $.Release.Name }}-{{ .name | default $.Values.serviceTemplate.name }}-svc" minReplicas: {{ .minReplicaCount | default $.Values.serviceTemplate.minReplicaCount }} maxReplicas: {{ .maxReplicaCount | default $.Values.serviceTemplate.maxReplicaCount }} @@ -225,7 +240,10 @@ metadata: {{- end }} spec: type: {{ .service.type | default $.Values.serviceTemplate.service.type }} - ports: + {{- if .service.ClusterIP }} + ClusterIP: {{ .service.ClusterIP }} + {{- end}} + ports: {{- with (.service.ports | default $.Values.serviceTemplate.service.ports) }} {{ toYaml . | nindent 4 }} {{- end }} @@ -272,4 +290,6 @@ spec: {{- end }} {{- end }} {{- end }} + {{- end }} +