feat(helm): added helm chart for movienight
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
MovieNight backend has been deployed.
|
||||
|
||||
Backend:
|
||||
Service: {{ include "movienight.fullname" . }}-backend
|
||||
Port: {{ .Values.backend.service.port }}
|
||||
|
||||
Postgres:
|
||||
{{- if .Values.postgres.url }}
|
||||
Using explicit SPRING_DATASOURCE_URL.
|
||||
{{- else if .Values.postgres.existingSecret.name }}
|
||||
Using secret {{ .Values.postgres.existingSecret.name }}.
|
||||
{{- else if .Values.postgres.cluster.enabled }}
|
||||
CNPG Cluster: {{ include "movienight.postgresClusterName" . }}
|
||||
JDBC URL: {{ include "movienight.postgresJdbcUrl" . }}
|
||||
{{- else }}
|
||||
No Postgres values provided. The app will fall back to its embedded H2 defaults.
|
||||
{{- end }}
|
||||
|
||||
Gateway:
|
||||
{{- if .Values.gateway.enabled }}
|
||||
Gateway: {{ include "movienight.gatewayName" . }}
|
||||
GatewayClass: {{ .Values.gateway.className }}
|
||||
{{- else }}
|
||||
Disabled.
|
||||
{{- end }}
|
||||
@@ -0,0 +1,125 @@
|
||||
{{- define "movienight.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := include "movienight.name" . -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.labels" -}}
|
||||
helm.sh/chart: {{ include "movienight.chart" . }}
|
||||
{{ include "movienight.selectorLabels" . }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- with .Values.global.labels }}
|
||||
{{ toYaml . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "movienight.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.componentLabels" -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $component := .component -}}
|
||||
{{ include "movienight.labels" $root }}
|
||||
app.kubernetes.io/component: {{ $component }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.componentSelectorLabels" -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $component := .component -}}
|
||||
{{ include "movienight.selectorLabels" $root }}
|
||||
app.kubernetes.io/component: {{ $component }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{- default (include "movienight.fullname" .) .Values.serviceAccount.name -}}
|
||||
{{- else -}}
|
||||
{{- default "default" .Values.serviceAccount.name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.gatewayName" -}}
|
||||
{{- if .Values.gateway.name -}}
|
||||
{{- .Values.gateway.name -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-gateway" (include "movienight.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.postgresClusterName" -}}
|
||||
{{- if .Values.postgres.cluster.name -}}
|
||||
{{- .Values.postgres.cluster.name -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-postgres" (include "movienight.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.postgresHost" -}}
|
||||
{{- default (printf "%s-rw" (include "movienight.postgresClusterName" .)) .Values.postgres.cluster.host -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.postgresJdbcUrl" -}}
|
||||
{{- printf "jdbc:postgresql://%s:%v/%s" (include "movienight.postgresHost" .) (default 5432 .Values.postgres.cluster.port) .Values.postgres.cluster.database -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "movienight.postgresEnv" -}}
|
||||
{{- if .Values.postgres.url }}
|
||||
- name: SPRING_DATASOURCE_URL
|
||||
value: {{ .Values.postgres.url | quote }}
|
||||
{{- if .Values.postgres.username }}
|
||||
- name: SPRING_DATASOURCE_USERNAME
|
||||
value: {{ .Values.postgres.username | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgres.password }}
|
||||
- name: SPRING_DATASOURCE_PASSWORD
|
||||
value: {{ .Values.postgres.password | quote }}
|
||||
{{- end }}
|
||||
{{- else if .Values.postgres.existingSecret.name }}
|
||||
- name: SPRING_DATASOURCE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.postgres.existingSecret.name }}
|
||||
key: {{ .Values.postgres.existingSecret.urlKey }}
|
||||
- name: SPRING_DATASOURCE_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.postgres.existingSecret.name }}
|
||||
key: {{ .Values.postgres.existingSecret.usernameKey }}
|
||||
- name: SPRING_DATASOURCE_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.postgres.existingSecret.name }}
|
||||
key: {{ .Values.postgres.existingSecret.passwordKey }}
|
||||
{{- else if .Values.postgres.cluster.enabled }}
|
||||
- name: SPRING_DATASOURCE_URL
|
||||
value: {{ include "movienight.postgresJdbcUrl" . | quote }}
|
||||
- name: SPRING_DATASOURCE_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ required "postgres.cluster.bootstrapSecretName is required when postgres.cluster.enabled=true" .Values.postgres.cluster.bootstrapSecretName }}
|
||||
key: username
|
||||
- name: SPRING_DATASOURCE_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ required "postgres.cluster.bootstrapSecretName is required when postgres.cluster.enabled=true" .Values.postgres.cluster.bootstrapSecretName }}
|
||||
key: password
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,92 @@
|
||||
{{- if .Values.backend.enabled }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "movienight.fullname" . }}-backend
|
||||
labels:
|
||||
{{- include "movienight.componentLabels" (dict "root" . "component" "backend") | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
replicas: {{ .Values.backend.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "movienight.componentSelectorLabels" (dict "root" . "component" "backend") | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "movienight.componentSelectorLabels" (dict "root" . "component" "backend") | nindent 8 }}
|
||||
{{- with .Values.backend.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "movienight.serviceAccountName" . }}
|
||||
{{- with .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.podSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- $postgresEnv := include "movienight.postgresEnv" . | trim }}
|
||||
containers:
|
||||
- name: backend
|
||||
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
|
||||
{{- with .Values.backend.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.backend.service.port }}
|
||||
protocol: TCP
|
||||
{{- if or $postgresEnv .Values.backend.env }}
|
||||
env:
|
||||
{{- if $postgresEnv }}
|
||||
{{- $postgresEnv | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.env }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.envFrom }}
|
||||
envFrom:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.startupProbe }}
|
||||
startupProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.readinessProbe }}
|
||||
readinessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,21 @@
|
||||
{{- if .Values.backend.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "movienight.fullname" . }}-backend
|
||||
labels:
|
||||
{{- include "movienight.componentLabels" (dict "root" . "component" "backend") | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.backend.service.type }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .Values.backend.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "movienight.componentSelectorLabels" (dict "root" . "component" "backend") | nindent 4 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,50 @@
|
||||
{{- if .Values.gateway.enabled }}
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: {{ include "movienight.gatewayName" . }}
|
||||
labels:
|
||||
{{- include "movienight.componentLabels" (dict "root" . "component" "gateway") | nindent 4 }}
|
||||
{{- with .Values.gateway.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.global.annotations .Values.gateway.annotations }}
|
||||
annotations:
|
||||
{{- with .Values.global.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.gateway.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
gatewayClassName: {{ required "gateway.className is required when gateway.enabled=true" .Values.gateway.className | quote }}
|
||||
listeners:
|
||||
{{- if .Values.gateway.http.enabled }}
|
||||
- name: http
|
||||
protocol: HTTP
|
||||
port: {{ .Values.gateway.http.port }}
|
||||
{{- if .Values.gateway.listenerHostname }}
|
||||
hostname: {{ .Values.gateway.listenerHostname | quote }}
|
||||
{{- end }}
|
||||
allowedRoutes:
|
||||
namespaces:
|
||||
from: Same
|
||||
{{- end }}
|
||||
{{- if .Values.gateway.https.enabled }}
|
||||
- name: https
|
||||
protocol: HTTPS
|
||||
port: {{ .Values.gateway.https.port }}
|
||||
{{- if .Values.gateway.listenerHostname }}
|
||||
hostname: {{ .Values.gateway.listenerHostname | quote }}
|
||||
{{- end }}
|
||||
tls:
|
||||
mode: Terminate
|
||||
certificateRefs:
|
||||
- kind: Secret
|
||||
name: {{ required "gateway.https.secretName is required when gateway.https.enabled=true" .Values.gateway.https.secretName }}
|
||||
allowedRoutes:
|
||||
namespaces:
|
||||
from: Same
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,29 @@
|
||||
{{- if and .Values.routes.enabled .Values.gateway.enabled }}
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: {{ include "movienight.fullname" . }}
|
||||
labels:
|
||||
{{- include "movienight.componentLabels" (dict "root" . "component" "route") | nindent 4 }}
|
||||
{{- with .Values.global.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: {{ include "movienight.gatewayName" . }}
|
||||
{{- if .Values.gateway.hostnames }}
|
||||
hostnames:
|
||||
{{- toYaml .Values.gateway.hostnames | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- if and .Values.routes.backend.enabled .Values.backend.enabled }}
|
||||
- matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: {{ .Values.routes.backend.pathPrefix | quote }}
|
||||
backendRefs:
|
||||
- name: {{ include "movienight.fullname" . }}-backend
|
||||
port: {{ .Values.backend.service.port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,36 @@
|
||||
{{- if .Values.postgres.cluster.enabled }}
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: {{ include "movienight.postgresClusterName" . }}
|
||||
labels:
|
||||
{{- include "movienight.componentLabels" (dict "root" . "component" "postgres") | nindent 4 }}
|
||||
{{- with .Values.postgres.cluster.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.global.annotations .Values.postgres.cluster.annotations }}
|
||||
annotations:
|
||||
{{- with .Values.global.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.postgres.cluster.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
instances: {{ .Values.postgres.cluster.instances }}
|
||||
storage:
|
||||
size: {{ .Values.postgres.cluster.storage.size | quote }}
|
||||
{{- if .Values.postgres.cluster.storage.storageClass }}
|
||||
storageClass: {{ .Values.postgres.cluster.storage.storageClass | quote }}
|
||||
{{- end }}
|
||||
bootstrap:
|
||||
initdb:
|
||||
database: {{ .Values.postgres.cluster.database | quote }}
|
||||
owner: {{ .Values.postgres.cluster.owner | quote }}
|
||||
secret:
|
||||
name: {{ required "postgres.cluster.bootstrapSecretName is required when postgres.cluster.enabled=true" .Values.postgres.cluster.bootstrapSecretName }}
|
||||
{{- with .Values.postgres.cluster.extraSpec }}
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,12 @@
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "movienight.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "movienight.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user