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..26bda319 100644 --- a/charts/microservice/examples/deploy-nginx.yaml +++ b/charts/microservice/examples/deploy-nginx.yaml @@ -30,4 +30,3 @@ deployment: data: index.html: | Hello! Opstree - \ No newline at end of file diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 7795ae8d..040ac3de 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -40,7 +40,7 @@ spec: {{- end }} serviceAccountName: {{ include "microservice.serviceAccountName" . }} containers: - - name: {{ include "microservice.fullname" . }} + - name: {{ include "microservice.fullname" . }}-app image: "{{ .Values.deployment.image.name }}:{{ .Values.deployment.image.tag }}" imagePullPolicy: {{ .Values.deployment.image.pullPolicy }} {{- if .Values.deployment.command }} @@ -100,11 +100,34 @@ 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" . }} + minDomains: 2 {{- end }} + diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 99757b40..3c3b1412 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -120,12 +120,23 @@ deployment: tolerations: [] - affinity: {} + affinity: + enabled: true + preferred: + enabled: true + required: + enabled: false + topologyKey: "topology.kubernetes.io/zone" + + topologySpreadConstraints: + enabled: true + whenUnsatisfiable: "ScheduleAnyway" # Options: "DoNotSchedule", "ScheduleAnyway" + topologyKey: "topology.kubernetes.io/zone" hpa: enabled: true - minReplicas: 1 - maxReplicas: 1 + minReplicas: 2 + maxReplicas: 3 targetCPU: 80 targetMemory: 80 @@ -138,10 +149,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: ""