Skip to content
Snippets Groups Projects
Commit baa51676 authored by Andri Joos's avatar Andri Joos :blush:
Browse files

Merge branch 'pv'

parents fdcfe84e fcd54028
No related branches found
No related tags found
No related merge requests found
Pipeline #7709 passed with stages
in 37 seconds
{{- define "common.extra-ingress.ingress" -}} {{- define "common.extra-ingress" -}}
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
...@@ -8,13 +8,14 @@ metadata: ...@@ -8,13 +8,14 @@ metadata:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
labels: labels:
{{- include "common.labels" . | nindent 4 }} {{- include "common.variables.labels" . | nindent 4 }}
spec: spec:
{{- with .Values.ingressClassName }} {{- with .Values.ingressClassName }}
ingressClassName: {{ . | quote }} ingressClassName: {{ . | quote }}
{{- end }} {{- end }}
rules: rules:
{{- (include "common.extra-ingress.rules" .) | nindent 4 }} {{- (include "common.variables.extra-ingress.rules" .) | nindent 4 }}
tls: tls:
{{- (include "common.extra-ingress.tls" .) | nindent 4 }} {{- (include "common.variables.extra-ingress.tls" .) | nindent 4 }}
---
{{- end }} {{- end }}
{{/* {{/*
Create chart name and version as used by the chart label. Create chart name and version as used by the chart label.
*/}} */}}
{{- define "common.chart" -}} {{- define "common.variables.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }} {{- end }}
{{/* {{/*
Common labels Common labels
*/}} */}}
{{- define "common.labels" -}} {{- define "common.variables.labels" -}}
helm.sh/chart: {{ include "common.chart" . }} helm.sh/chart: {{ include "common.variables.chart" . }}
{{- if .Chart.AppVersion }} {{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }} {{- end }}
...@@ -23,7 +23,7 @@ Extra Ingress ...@@ -23,7 +23,7 @@ Extra Ingress
{{/* {{/*
Extra Ingress Rules Extra Ingress Rules
*/}} */}}
{{- define "common.extra-ingress.rules" -}} {{- define "common.variables.extra-ingress.rules" -}}
{{- $rules := list -}} {{- $rules := list -}}
{{- range $name, $rule := .Values.rules -}} {{- range $name, $rule := .Values.rules -}}
{{- $rules = append $rules $rule -}} {{- $rules = append $rules $rule -}}
...@@ -34,7 +34,7 @@ Extra Ingress Rules ...@@ -34,7 +34,7 @@ Extra Ingress Rules
{{/* {{/*
Extra Ingress TLS Extra Ingress TLS
*/}} */}}
{{- define "common.extra-ingress.tls" -}} {{- define "common.variables.extra-ingress.tls" -}}
{{- $tlsDefinitions := list -}} {{- $tlsDefinitions := list -}}
{{- range $name, $tlsDefinition := .Values.tls -}} {{- range $name, $tlsDefinition := .Values.tls -}}
{{- $tlsDefinitions = append $tlsDefinitions $tlsDefinition -}} {{- $tlsDefinitions = append $tlsDefinitions $tlsDefinition -}}
...@@ -49,7 +49,7 @@ Secret ...@@ -49,7 +49,7 @@ Secret
{{/* {{/*
Secret data Secret data
*/}} */}}
{{- define "common.secret.data" -}} {{- define "common.variables.secret.data" -}}
{{- $data := dict -}} {{- $data := dict -}}
{{- range $key, $value := .Values.data -}} {{- range $key, $value := .Values.data -}}
{{- $data = merge $data (dict $key $value) -}} {{- $data = merge $data (dict $key $value) -}}
......
# Only use for static provisioning, dynamic provisioning will provision the pv upon request
{{- define "common.persistentvolume" -}}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.name }}
{{- with .Values.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "common.variables.labels" . | nindent 4 }}
spec:
capacity:
storage: {{ .Values.size }}
{{- with .Values.mountOptions }}
mountOptions:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.accessModes }}
accessModes:
{{- toYaml . | nindent 4 }}
{{- end }}
persistentVolumeReclaimPolicy: {{ .Values.reclaimPolicy | default "Retain" }}
storageClassName: {{ .Values.storageClassName | default "manual" }}
{{- with .Values.claimRefName }}
claimRef:
name: {{ quote . }}
namespace: {{ quote $.Release.Namespace }}
{{- end}}
{{- with .Values.mount }}
{{- toYaml . | nindent 2 }}
{{- end }}
---
{{- end }}
{{- define "common.persistentvolumeclaim" -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.name }}
{{- with .Values.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "common.variables.labels" . | nindent 4 }}
spec:
resources:
requests:
storage: {{ .Values.size }}
{{- with .Values.accessModes }}
accessModes:
{{- toYaml . | nindent 4 }}
{{- end }}
storageClassName: {{ .Values.storageClassName | default "manual" }}
{{- with .Values.volumeName }}
volumeName: {{ . }}
{{- end }}
---
{{- end }}
{{- define "common.secret.secret" -}} {{- define "common.secret" -}}
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: {{ .Values.name | default "secret" | quote }} name: {{ .Values.name | default "secret" | quote }}
{{- with .Values.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "common.variables.labels" . | nindent 4 }}
type: {{ .Values.type | default "Opaque" }} type: {{ .Values.type | default "Opaque" }}
data: data:
{{- (include "common.secret.data" .) | nindent 2 }} {{- (include "common.variables.secret.data" .) | nindent 2 }}
---
{{- end }} {{- end }}
{{- if .Values.extraIngress }} {{- if .Values.extraIngress }}
{{ include "common.extra-ingress.ingress" (merge . (dict "Values" .Values.extraIngress)) }} {{ include "common.extra-ingress" (dict "Values" .Values.extraIngress "Chart" .Chart "Release" .Release) }}
{{- end }} {{- end }}
{{- if .Values.extraIngress }}
{{ include "common.persistentvolumeclaim" (dict "Values" .Values.volumes.persistentVolumeClaims.example "Chart" .Chart "Release" .Release) }}
{{- end }}
{{- if .Values.volumes.persistentVolumes.example }}
{{ include "common.persistentvolume" (dict "Values" .Values.volumes.persistentVolumes.example "Chart" .Chart "Release" .Release) }}
{{- end }}
{{- if .Values.secret }}
{{ include "common.secret.secret" (merge . (dict "Values" .Values.secret)) }}
{{- end }}
{{- if .Values.secrets.secret0 }}
{{ include "common.secret" (dict "Values" .Values.secrets.secret0 "Chart" .Chart "Release" .Release) }}
{{- end }}
{{- if .Values.secrets.secret1 }}
{{ include "common.secret" (dict "Values" .Values.secrets.secret1 "Chart" .Chart "Release" .Release) }}
{{- end }}
...@@ -17,9 +17,42 @@ extraIngress: ...@@ -17,9 +17,42 @@ extraIngress:
- test.com - test.com
secretName: test-tls secretName: test-tls
secret: secrets:
name: example-secret secret0:
type: Generic name: example-secret0
data: data:
username: dXNlcm5hbWU= # Base64-encoded 'username' username: dXNlcm5hbWU= # Base64-encoded 'username'
password: cGFzc3dvcmQ= # Base64-encoded 'password' password: cGFzc3dvcmQ= # Base64-encoded 'password'
secret1:
name: example-secret1
type: Opaque
data:
username: example
password: example
volumes:
persistentVolumes:
example:
name: example
size: 5Gi
mountOptions:
- nfsvers=4.1
accessModes:
- ReadWriteMany
reclaimPolicy: Delete
storageClassName: manual
claimRefName: example
mount:
nfs:
server: 192.168.1.196
path: /example
persistentVolumeClaims:
example:
name: example
size: 5Gi
accessModes:
- ReadWriteMany
storageClassName: manual
volumeName: example
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment