Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/217 #234

Merged
merged 4 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion charts/microservice/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 13 additions & 3 deletions charts/microservice/examples/deploy-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ deployment:
name: nginx
tag: latest
pullPolicy: IfNotPresent
livenessProbe:
livenessProbe:
httpGet:
path: "/"
port: http
readinessProbe:
readinessProbe:
httpGet:
path: "/"
port: http
Expand All @@ -30,4 +30,14 @@ deployment:
data:
index.html: |
Hello! Opstree

topologySpreadConstraints:
whenUnsatisfiable: "DoNotSchedule"

# serviceAccount:
# create: true
# annotations: "aws arn link"

# serviceAccount:
# name: "myserviceaccount"


2 changes: 1 addition & 1 deletion charts/microservice/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ Create the name of the service account to use
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{- end }}
43 changes: 36 additions & 7 deletions charts/microservice/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ spec:
strategy:
{{- toYaml .Values.deployment.strategy | nindent 4 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.deployment.terminationGracePeriodSeconds }}
selector:
matchLabels:
{{- include "microservice.selectorLabels" . | nindent 6 }}
Expand All @@ -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 }}"
Expand Down Expand Up @@ -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 }}
20 changes: 14 additions & 6 deletions charts/microservice/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ deployment:
annotations: {}
podAnnotations: {}

terminationGracePeriodSeconds: 30
terminationGracePeriodSeconds: 60

healthProbes:
enabled: true
Expand Down Expand Up @@ -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
Expand All @@ -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: ""
Loading