Skip to content

Commit

Permalink
Leverage Helm values in templates
Browse files Browse the repository at this point in the history
- A number of variables exist in values.yaml that are not leveraged at
all in the deployment templates, such as:
    - Resources
    - Service Account
    - Affinity
    - Tolerations
    - Security Context

- Updated the templates to leverage values that were already possible,
as well as adding support for image.version
  • Loading branch information
yaraskm committed Oct 17, 2023
1 parent 2e5e05a commit c8edfe5
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 18 deletions.
7 changes: 7 additions & 0 deletions k8s/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Set the image tag to use.
*/}}
{{- define "warp.imageVersion" -}}
{{- default .Chart.AppVersion .Values.image.version -}}
{{- end -}}

{{/*
Common labels
*/}}
Expand Down
20 changes: 19 additions & 1 deletion k8s/helm/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
restartPolicy: Never
containers:
- name: {{ include "warp.fullname" . }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
image: "{{ .Values.image.repository }}:{{ include "warp.imageVersion" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "{{ .Values.warpConfiguration.operationToBenchmark }}"
Expand All @@ -31,7 +31,25 @@ spec:
value: {{ .Values.warpConfiguration.s3AccessKey | quote }}
- name: WARP_SECRET_KEY
value: {{ .Values.warpConfiguration.s3SecretKey | quote }}
{{- if .Values.serverResources }}
resources: {{- toYaml .Values.serverResources | nindent 12 }}
{{- end }}
{{- if .Values.securityContext }}
securityContext: {{- toYaml .Values.securityContext | nindent 12 }}
{{- end }}
{{- if .Values.serviceAccount.create }}
serviceAccountName: {{ include "warp.serviceAccountName" . }}
{{- end }}
{{- if .Values.podSecurityContext }}
securityContext: {{- .Values.podSecurityContext | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity: {{- .Values.affinity | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector: {{- .Values.nodeSelector | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations: {{- .Values.tolerations | toYaml | nindent 8 }}
{{- end }}
backoffLimit: 4
19 changes: 17 additions & 2 deletions k8s/helm/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,31 @@ spec:
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
image: "{{ .Values.image.repository }}:{{ include "warp.imageVersion" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- client
ports:
- name: http
containerPort: 7761
containerPort: {{ .Values.service.port }}
{{- if .Values.clientResources }}
resources: {{- toYaml .Values.clientResources | nindent 12 }}
{{- end }}
{{- if .Values.securityContext }}
securityContext: {{- toYaml .Values.securityContext | nindent 12 }}
{{- end }}
{{- if .Values.serviceAccount.create }}
serviceAccountName: {{ include "warp.serviceAccountName" . }}
{{- end }}
{{- if .Values.podSecurityContext }}
securityContext: {{- .Values.podSecurityContext | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity: {{- .Values.affinity | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector: {{- .Values.nodeSelector | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations: {{- .Values.tolerations | toYaml | nindent 8 }}
{{- end }}
33 changes: 18 additions & 15 deletions k8s/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ replicaCount: 4
image:
repository: minio/warp
pullPolicy: IfNotPresent
# Set version to use a specific release of Warp
# version: latest

imagePullSecrets: []
nameOverride: ""
Expand Down Expand Up @@ -52,30 +54,31 @@ serviceAccount:
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
# name:

podSecurityContext: {}
# fsGroup: 2000
securityContext:
readOnlyRootFilesystem: true

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
podSecurityContext:
runAsNonRoot: true
runAsUser: 1001
fsGroup: 1001

service:
port: 7761

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
serverResources: {}
# limits:
# cpu: 500m
# memory: 512Mi
# requests:
# cpu: 100m
# memory: 128Mi

clientResources: {}
# limits:
# cpu: 4
# memory: 512Mi
# requests:
# cpu: 100m
# memory: 128Mi
Expand Down

0 comments on commit c8edfe5

Please sign in to comment.