REFACTOR(repo): migrate to Helm chart structure
- Add web-app Helm chart in charts/web-app/ - Replace individual deployment/service/ingress YAML with helm-values - Update ArgoCD applications to use Helm chart with values files - Reduces per-app files from 6 to 2 (argocd.yaml + helm-values.yaml) Apps migrated: jaejadle, jaejadle-dev, joossam, joossam-dev, jotion, jovies, portfolio, todo
This commit is contained in:
40
charts/web-app/templates/_helpers.tpl
Normal file
40
charts/web-app/templates/_helpers.tpl
Normal file
@@ -0,0 +1,40 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "web-app.name" -}}
|
||||
{{- default .Chart.Name .Values.name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
*/}}
|
||||
{{- define "web-app.fullname" -}}
|
||||
{{- if .Values.name }}
|
||||
{{- .Values.name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "web-app.labels" -}}
|
||||
app: {{ include "web-app.fullname" . }}
|
||||
app.kubernetes.io/name: {{ include "web-app.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "web-app.selectorLabels" -}}
|
||||
app: {{ include "web-app.fullname" . }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Image name
|
||||
*/}}
|
||||
{{- define "web-app.image" -}}
|
||||
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository .Values.image.tag }}
|
||||
{{- end }}
|
||||
76
charts/web-app/templates/deployment.yaml
Normal file
76
charts/web-app/templates/deployment.yaml
Normal file
@@ -0,0 +1,76 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "web-app.fullname" . }}
|
||||
labels:
|
||||
{{- include "web-app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "web-app.selectorLabels" . | nindent 6 }}
|
||||
strategy:
|
||||
type: {{ .Values.strategy.type }}
|
||||
{{- if eq .Values.strategy.type "RollingUpdate" }}
|
||||
rollingUpdate:
|
||||
maxUnavailable: {{ .Values.strategy.rollingUpdate.maxUnavailable }}
|
||||
maxSurge: {{ .Values.strategy.rollingUpdate.maxSurge }}
|
||||
{{- end }}
|
||||
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "web-app.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ include "web-app.fullname" . }}
|
||||
image: {{ include "web-app.image" . }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: {{ .Values.containerPort }}
|
||||
protocol: TCP
|
||||
{{- with .Values.env }}
|
||||
env:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.envFrom }}
|
||||
envFrom:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- if .Values.healthCheck.enabled }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.healthCheck.path }}
|
||||
port: {{ .Values.containerPort }}
|
||||
initialDelaySeconds: {{ .Values.healthCheck.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.healthCheck.livenessProbe.periodSeconds }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.healthCheck.path }}
|
||||
port: {{ .Values.containerPort }}
|
||||
initialDelaySeconds: {{ .Values.healthCheck.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.healthCheck.readinessProbe.periodSeconds }}
|
||||
{{- end }}
|
||||
restartPolicy: Always
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
22
charts/web-app/templates/external-secret.yaml
Normal file
22
charts/web-app/templates/external-secret.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
{{- if .Values.externalSecret.enabled }}
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: {{ include "web-app.fullname" . }}-secrets
|
||||
spec:
|
||||
refreshInterval: {{ .Values.externalSecret.refreshInterval }}
|
||||
secretStoreRef:
|
||||
name: {{ .Values.externalSecret.secretStoreRef.name }}
|
||||
kind: {{ .Values.externalSecret.secretStoreRef.kind }}
|
||||
target:
|
||||
name: {{ include "web-app.fullname" . }}-secrets
|
||||
creationPolicy: {{ .Values.externalSecret.target.creationPolicy }}
|
||||
deletionPolicy: {{ .Values.externalSecret.target.deletionPolicy }}
|
||||
data:
|
||||
{{- range .Values.externalSecret.data }}
|
||||
- secretKey: {{ .secretKey }}
|
||||
remoteRef:
|
||||
key: {{ .remoteRef.key }}
|
||||
property: {{ .remoteRef.property }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
37
charts/web-app/templates/ingress.yaml
Normal file
37
charts/web-app/templates/ingress.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
{{- if .Values.ingress.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "web-app.fullname" . }}-ingress
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
pathType: {{ .pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ include "web-app.fullname" $ }}
|
||||
port:
|
||||
number: {{ $.Values.service.port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
17
charts/web-app/templates/service.yaml
Normal file
17
charts/web-app/templates/service.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
{{- if .Values.service.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "web-app.fullname" . }}
|
||||
labels:
|
||||
{{- include "web-app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.containerPort }}
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "web-app.selectorLabels" . | nindent 4 }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user