Skip to content

Commit

Permalink
Feat/statefulset polymorphic support (#36)
Browse files Browse the repository at this point in the history
Feat:Add Statefulset in musketeers
  • Loading branch information
aniketgohelimp authored Jun 11, 2023
1 parent fb95801 commit ce39639
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
3 changes: 1 addition & 2 deletions charts/polymorphic-app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 25 additions & 0 deletions charts/polymorphic-app/ci/override-values.yaml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 25 additions & 5 deletions charts/polymorphic-app/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 }}
Expand Down Expand Up @@ -146,7 +152,6 @@ spec:
periodSeconds: {{ .healthcheck.periodSeconds | default $.Values.serviceTemplate.healthcheck.periodSeconds | default "20" }}
{{- end }}
{{- end }}

volumes:
{{- if .volumes }}
{{ toYaml .volumes | indent 8 }}
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -272,4 +290,6 @@ spec:
{{- end }}
{{- end }}
{{- end }}

{{- end }}

0 comments on commit ce39639

Please sign in to comment.