diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index b8396e62..5b92fd62 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -2,8 +2,9 @@ apiVersion: v2 name: microservice description: Basic helm chart for deploying microservices on kubernetes with best practices type: application -version: 0.1.5 +version: 0.1.6 appVersion: "0.1.2" maintainers: - name: ashwani-opstree - name: tripathishikha1 + - name: khushimalhoz diff --git a/charts/microservice/examples/deploy-nginx.yaml b/charts/microservice/examples/deploy-nginx.yaml index 20311c45..f458d9f1 100644 --- a/charts/microservice/examples/deploy-nginx.yaml +++ b/charts/microservice/examples/deploy-nginx.yaml @@ -7,11 +7,11 @@ deployment: name: nginx tag: latest pullPolicy: IfNotPresent - livenessProbe: + livenessProbe: httpGet: path: "/" port: http - readinessProbe: + readinessProbe: httpGet: path: "/" port: http @@ -30,4 +30,14 @@ deployment: data: index.html: | Hello! Opstree - \ No newline at end of file + topologySpreadConstraints: + whenUnsatisfiable: "DoNotSchedule" + +# serviceAccount: +# create: true +# annotations: "aws arn link" + +# serviceAccount: +# name: "myserviceaccount" + + diff --git a/charts/microservice/templates/_helpers.tpl b/charts/microservice/templates/_helpers.tpl index 5556c262..8a2c02bb 100644 --- a/charts/microservice/templates/_helpers.tpl +++ b/charts/microservice/templates/_helpers.tpl @@ -51,4 +51,4 @@ Create the name of the service account to use {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 7795ae8d..50b61829 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -19,7 +19,6 @@ spec: strategy: {{- toYaml .Values.deployment.strategy | nindent 4 }} {{- end }} - terminationGracePeriodSeconds: {{ .Values.deployment.terminationGracePeriodSeconds }} selector: matchLabels: {{- include "microservice.selectorLabels" . | nindent 6 }} @@ -38,7 +37,13 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "microservice.serviceAccountName" . }} + {{- if .Values.serviceAccount.create }} + serviceAccountName: {{ include "microservice.serviceAccountName" . }}-sa + {{- end }} + {{- if .Values.serviceAccount.name }} + serviceAccountName: {{ .Values.serviceAccount.name }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.deployment.terminationGracePeriodSeconds }} containers: - name: {{ include "microservice.fullname" . }} image: "{{ .Values.deployment.image.name }}:{{ .Values.deployment.image.tag }}" @@ -100,11 +105,35 @@ spec: nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.deployment.affinity }} + {{- if and .Values.deployment.affinity.enabled (or .Values.deployment.affinity.preferred.enabled .Values.deployment.affinity.required.enabled) }} affinity: - {{- toYaml . | nindent 8 }} + podAntiAffinity: + {{- if .Values.deployment.affinity.preferred.enabled }} + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchLabels: + app: {{ include "microservice.fullname" . }} + topologyKey: {{ .Values.deployment.affinity.topologyKey }} + {{- end }} + {{- if and .Values.deployment.affinity.required.enabled (not .Values.deployment.affinity.preferred.enabled) }} + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + app: {{ include "microservice.fullname" . }} + topologyKey: {{ .Values.deployment.affinity.topologyKey }} + {{- end }} {{- end }} - {{- with .Values.deployment.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} + {{- if .Values.deployment.topologySpreadConstraints.enabled }} + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: {{ .Values.deployment.topologySpreadConstraints.topologyKey }} + whenUnsatisfiable: "{{ .Values.deployment.topologySpreadConstraints.whenUnsatisfiable }}" + labelSelector: + matchLabels: + app: {{ include "microservice.fullname" . }} + {{- if ( eq .Values.deployment.topologySpreadConstraints.whenUnsatisfiable "DoNotSchedule")}} + minDomains: 2 + {{- end }} {{- end }} diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 99757b40..5b7f4265 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -27,7 +27,7 @@ deployment: annotations: {} podAnnotations: {} - terminationGracePeriodSeconds: 30 + terminationGracePeriodSeconds: 60 healthProbes: enabled: true @@ -120,7 +120,19 @@ deployment: tolerations: [] - affinity: {} + affinity: + enabled: true + preferred: + enabled: true + required: + enabled: false + topologyKey: "topology.kubernetes.io/zone" + + topologySpreadConstraints: + enabled: true + # whenUnsatisfiable: "DoNotSchedule" OR "ScheduleAnyway" + whenUnsatisfiable: "ScheduleAnyway" + topologyKey: "topology.kubernetes.io/zone" hpa: enabled: true @@ -138,10 +150,6 @@ service: serviceAccount: create: false - # Automatically mount a ServiceAccount's API credentials? automount: true - # Annotations to add to the service account annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template name: ""