Skip to content

Commit

Permalink
feat(helm): update nextjs Chart.yaml version to 1.1.3 and add support…
Browse files Browse the repository at this point in the history
… for extra containers in web-deployment.yaml
  • Loading branch information
masterkain committed Dec 27, 2024
1 parent eb5ed39 commit 716aa7c
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 46 deletions.
2 changes: 1 addition & 1 deletion charts/nextjs/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: nextjs
description: Generic Helm chart for Nextjs apps on Kubernetes
type: application
version: 1.1.2
version: 1.1.3
appVersion: '1.0.0'
keywords:
- nextjs
Expand Down
118 changes: 73 additions & 45 deletions charts/nextjs/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,62 +30,90 @@ spec:
- name: {{ .Values.web.imagePullSecrets }}
{{- end }}
containers:
- name: {{ include "app.web.name" . }}
image: "{{ .Values.web.image }}"
imagePullPolicy: {{ .Values.web.imagePullPolicy }}
envFrom:
- configMapRef:
name: {{ template "app.web-env.name" . }}
- secretRef:
name: {{ template "app.web-env.name" . }}
ports:
- name: http
containerPort: {{ .Values.web.service.port }}
protocol: TCP
{{- if .Values.web.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.web.livenessProbe.httpGet.endpoint }}
port: http
httpHeaders: {{ .Values.web.livenessProbe.httpGet.httpHeaders }}
initialDelaySeconds: {{ .Values.web.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.web.livenessProbe.failureThreshold }}
successThreshold: {{ .Values.web.livenessProbe.successThreshold }}
- name: {{ include "app.web.name" . }}
image: "{{ .Values.web.image }}"
imagePullPolicy: {{ .Values.web.imagePullPolicy }}
envFrom:
- configMapRef:
name: {{ template "app.web-env.name" . }}
- secretRef:
name: {{ template "app.web-env.name" . }}
ports:
- name: http
containerPort: {{ .Values.web.service.port }}
protocol: TCP
{{- if .Values.web.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.web.livenessProbe.httpGet.endpoint }}
port: http
httpHeaders: {{ .Values.web.livenessProbe.httpGet.httpHeaders }}
initialDelaySeconds: {{ .Values.web.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.web.livenessProbe.failureThreshold }}
successThreshold: {{ .Values.web.livenessProbe.successThreshold }}
{{- end }}
{{- if .Values.web.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.web.readinessProbe.httpGet.endpoint }}
port: http
httpHeaders: {{ .Values.web.readinessProbe.httpGet.httpHeaders }}
initialDelaySeconds: {{ .Values.web.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.web.readinessProbe.failureThreshold }}
successThreshold: {{ .Values.web.readinessProbe.successThreshold }}
{{- end }}
resources:
{{- toYaml .Values.web.resources | nindent 12 }}
{{- if .Values.web.cachePersistentVolume.enabled }}
volumeMounts:
- name: next-cache
mountPath: {{ .Values.web.cachePersistentVolume.mountPath }}
{{- end }}
{{- if .Values.web.extraContainers }}
{{- range .Values.web.extraContainers }}
- name: {{ .name | quote }}
image: {{ .image | quote }}
{{- if .command }}
command:
{{- toYaml .command | nindent 12 }}
{{- end }}
{{- if .args }}
args:
{{- toYaml .args | nindent 12 }}
{{- end }}
{{- if .env }}
env:
{{- toYaml .env | nindent 12 }}
{{- end }}
{{- if .resources }}
resources:
{{- toYaml .resources | nindent 12 }}
{{- end }}
{{- if .volumeMounts }}
volumeMounts:
{{- toYaml .volumeMounts | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.web.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.web.readinessProbe.httpGet.endpoint }}
port: http
httpHeaders: {{ .Values.web.readinessProbe.httpGet.httpHeaders }}
initialDelaySeconds: {{ .Values.web.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.web.readinessProbe.failureThreshold }}
successThreshold: {{ .Values.web.readinessProbe.successThreshold }}
{{- end }}
resources:
{{- toYaml .Values.web.resources | nindent 12 }}
{{- if .Values.web.cachePersistentVolume.enabled }}
volumeMounts:
- name: next-cache
mountPath: {{ .Values.web.cachePersistentVolume.mountPath }}
{{- end }}

terminationGracePeriodSeconds: {{ .Values.web.terminationGracePeriodSeconds | default 30 }}
{{- with .Values.web.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.web.affinity }}
{{- with .Values.web.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.web.tolerations }}
{{- end }}
{{- with .Values.web.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

{{- if .Values.web.cachePersistentVolume.enabled }}
volumes:
- name: next-cache
Expand Down
24 changes: 24 additions & 0 deletions charts/nextjs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ web:
maxUnavailable: 0
maxSurge: 1

# optional array of additional containers
extraContainers: []
# Example usage:
# extraContainers:
# - name: inngest-sync-sidecar
# image: curlimages/curl:latest
# command:
# - /bin/sh
# - -c
# - |
# echo "Sidecar waiting for Next.js readiness..."
# # simple poll
# for i in $(seq 1 30); do
# if curl -fsS localhost:3000/api/health; then
# echo "Next.js is ready, calling /api/inngest..."
# curl -X PUT localhost:3000/api/inngest
# echo "Sync done."
# exit 0
# fi
# sleep 2
# done
# echo "Sidecar: Next.js never became ready, giving up."
# exit 1

# not sure about the usefulness of this - we are trying to solve some caching issues with next.js
# so this should be considered experimental.
cachePersistentVolume:
Expand Down

0 comments on commit 716aa7c

Please sign in to comment.