mirror of
https://github.com/TeamPiped/Piped-Kubernetes.git
synced 2024-08-14 23:57:15 +00:00
Progress
This commit is contained in:
parent
73ac9b4437
commit
52ed0d9374
41 changed files with 2439 additions and 269 deletions
49
charts/apps/piped/templates/ytproxy/deployment.yaml
Normal file
49
charts/apps/piped/templates/ytproxy/deployment.yaml
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
{{- if .Values.ytproxy.enabled -}}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "ytproxy.names.fullname" . }}
|
||||
{{- with (merge (.Values.ytproxy.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge (.Values.ytproxy.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
revisionHistoryLimit: {{ .Values.ytproxy.revisionHistoryLimit }}
|
||||
replicas: {{ .Values.ytproxy.replicas }}
|
||||
{{- $strategy := default "Recreate" .Values.ytproxy.strategy }}
|
||||
{{- if and (ne $strategy "Recreate") (ne $strategy "RollingUpdate") }}
|
||||
{{- fail (printf "Not a valid strategy type for Deployment (%s)" $strategy) }}
|
||||
{{- end }}
|
||||
strategy:
|
||||
type: {{ $strategy }}
|
||||
{{- with .Values.ytproxy.rollingUpdate }}
|
||||
{{- if and (eq $strategy "RollingUpdate") (or .surge .unavailable) }}
|
||||
rollingUpdate:
|
||||
{{- with .unavailable }}
|
||||
maxUnavailable: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .surge }}
|
||||
maxSurge: {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "ytproxy.labels.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with include ("ytproxy.podAnnotations") . }}
|
||||
annotations:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "ytproxy.labels.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ytproxy.controller.pod" . | nindent 6 }}
|
||||
{{- end }}
|
||||
54
charts/apps/piped/templates/ytproxy/lib/_container.tpl
Normal file
54
charts/apps/piped/templates/ytproxy/lib/_container.tpl
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{{- /* The main container included in the controller */ -}}
|
||||
{{- define "ytproxy.controller.mainContainer" -}}
|
||||
- name: {{ include "ytproxy.names.fullname" . }}
|
||||
image: {{ printf "%s:%s" .Values.ytproxy.image.repository (default .Chart.AppVersion .Values.ytproxy.image.tag) | quote }}
|
||||
imagePullPolicy: {{ .Values.ytproxy.image.pullPolicy }}
|
||||
{{- with .Values.ytproxy.command }}
|
||||
command:
|
||||
{{- if kindIs "string" . }}
|
||||
- {{ . }}
|
||||
{{- else }}
|
||||
{{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.ytproxy.args }}
|
||||
args:
|
||||
{{- if kindIs "string" . }}
|
||||
- {{ . }}
|
||||
{{- else }}
|
||||
{{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.ytproxy.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.lifecycle }}
|
||||
lifecycle:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.termination.messagePath }}
|
||||
terminationMessagePath: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.termination.messagePolicy }}
|
||||
terminationMessagePolicy: {{ . }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Values.ytproxy.env }}
|
||||
env:
|
||||
{{- get (fromYaml (include "ytproxy.controller.env_vars" $)) "env" | toYaml | nindent 4 -}}
|
||||
{{- end }}
|
||||
{{- if or .Values.ytproxy.envFrom .Values.ytproxy.secret }}
|
||||
envFrom:
|
||||
{{- with .Values.envFrom }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.secret }}
|
||||
- secretRef:
|
||||
name: {{ include "ytproxy.names.fullname" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- include "ytproxy.controller.probes" . | trim | nindent 2 }}
|
||||
ports:
|
||||
{{- include "ytproxy.controller.ports" . | trim | nindent 4 }}
|
||||
{{- end -}}
|
||||
43
charts/apps/piped/templates/ytproxy/lib/_env_vars.tpl
Normal file
43
charts/apps/piped/templates/ytproxy/lib/_env_vars.tpl
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{{/*
|
||||
Environment variables used by containers.
|
||||
*/}}
|
||||
{{- define "ytproxy.controller.env_vars" -}}
|
||||
{{- $values := merge .Values.ytproxy.env .Values.common_env -}}
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.env -}}
|
||||
{{- $values = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $values -}}
|
||||
{{- $result := list -}}
|
||||
{{- range $k, $v := . -}}
|
||||
{{- $name := $k -}}
|
||||
{{- $value := $v -}}
|
||||
{{- if kindIs "int" $name -}}
|
||||
{{- $name = required "environment variables as a list of maps require a name field" $value.name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if kindIs "map" $value -}}
|
||||
{{- if hasKey $value "value" -}}
|
||||
{{- $envValue := $value.value | toString -}}
|
||||
{{- $result = append $result (dict "name" $name "value" (tpl $envValue $)) -}}
|
||||
{{- else if hasKey $value "valueFrom" -}}
|
||||
{{- $result = append $result (dict "name" $name "valueFrom" $value.valueFrom) -}}
|
||||
{{- else -}}
|
||||
{{- $result = append $result (dict "name" $name "valueFrom" $value) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if not (kindIs "map" $value) -}}
|
||||
{{- if kindIs "string" $value -}}
|
||||
{{- $result = append $result (dict "name" $name "value" (tpl $value $)) -}}
|
||||
{{- else if or (kindIs "float64" $value) (kindIs "bool" $value) -}}
|
||||
{{- $result = append $result (dict "name" $name "value" ($value | toString)) -}}
|
||||
{{- else -}}
|
||||
{{- $result = append $result (dict "name" $name "value" $value) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- toYaml (dict "env" $result) | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
19
charts/apps/piped/templates/ytproxy/lib/_ingress.tpl
Normal file
19
charts/apps/piped/templates/ytproxy/lib/_ingress.tpl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{{/*
|
||||
Renders the ingress objects required.
|
||||
*/}}
|
||||
{{- define "ytproxy.classes.ingress" -}}
|
||||
{{- /* Generate named services as required */ -}}
|
||||
{{- range $name, $service := .Values.ytproxy.service }}
|
||||
{{- if $service.enabled -}}
|
||||
{{- $serviceValues := $service -}}
|
||||
|
||||
{{/* set the default nameOverride to the service name */}}
|
||||
{{- if and (not $serviceValues.nameOverride) (ne $name (include "ytproxy.service.primary" $)) -}}
|
||||
{{- $_ := set $serviceValues "nameOverride" $name -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}}
|
||||
{{- include "ytproxy.classes.service" $ }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
111
charts/apps/piped/templates/ytproxy/lib/_names.tpl
Normal file
111
charts/apps/piped/templates/ytproxy/lib/_names.tpl
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
{{/* Expand the name of the chart */}}
|
||||
{{- define "ytproxy.names.name" -}}
|
||||
{{- $globalNameOverride := "" -}}
|
||||
{{- if hasKey .Values "global" -}}
|
||||
{{- $globalNameOverride = (default $globalNameOverride .Values.global.nameOverride) -}}
|
||||
{{- end -}}
|
||||
{{- default .Chart.Name (default .Values.nameOverride $globalNameOverride) | trunc 50 | trimSuffix "-" -}}-ytproxy
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "ytproxy.names.fullname" -}}
|
||||
{{- $name := include "ytproxy.names.name" . -}}
|
||||
{{- $globalFullNameOverride := "" -}}
|
||||
{{- if hasKey .Values "global" -}}
|
||||
{{- $globalFullNameOverride = (default $globalFullNameOverride .Values.global.fullnameOverride) -}}
|
||||
{{- end -}}
|
||||
{{- if or .Values.fullnameOverride $globalFullNameOverride -}}
|
||||
{{- $name = default .Values.fullnameOverride $globalFullNameOverride -}}
|
||||
{{- else -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- $name = .Release.Name -}}
|
||||
{{- else -}}
|
||||
{{- $name = printf "%s-%s" .Release.Name $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- trunc 50 $name | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/* Create chart name and version as used by the chart label */}}
|
||||
{{- define "ytproxy.names.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 50 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Create the name of the ServiceAccount to use */}}
|
||||
{{- define "ytproxy.names.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{- default (include "ytproxy.names.fullname" .) .Values.serviceAccount.name -}}
|
||||
{{- else -}}
|
||||
{{- default "default" .Values.serviceAccount.name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Return the properly cased version of the controller type */}}
|
||||
{{- define "ytproxy.names.controllerType" -}}
|
||||
{{- if eq .Values.controller.type "deployment" -}}
|
||||
{{- print "Deployment" -}}
|
||||
{{- else if eq .Values.controller.type "daemonset" -}}
|
||||
{{- print "DaemonSet" -}}
|
||||
{{- else if eq .Values.controller.type "statefulset" -}}
|
||||
{{- print "StatefulSet" -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Not a valid controller.type (%s)" .Values.controller.type) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* web labels shared across objects */}}
|
||||
{{- define "ytproxy.labels" -}}
|
||||
helm.sh/chart: {{ include "ytproxy.names.chart" . }}
|
||||
{{ include "ytproxy.labels.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- with .Values.global.labels }}
|
||||
{{- range $k, $v := . }}
|
||||
{{- $name := $k }}
|
||||
{{- $value := tpl $v $ }}
|
||||
{{ $name }}: {{ quote $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Selector labels shared across objects */}}
|
||||
{{- define "ytproxy.labels.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "ytproxy.names.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/* Common annotations shared across objects */}}
|
||||
{{- define "ytproxy.annotations" -}}
|
||||
{{- with .Values.global.annotations }}
|
||||
{{- range $k, $v := . }}
|
||||
{{- $name := $k }}
|
||||
{{- $value := tpl $v $ }}
|
||||
{{ $name }}: {{ quote $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Determine the Pod annotations used in the controller */}}
|
||||
{{- define "ytproxy.podAnnotations" -}}
|
||||
{{- if .Values.podAnnotations -}}
|
||||
{{- tpl (toYaml .Values.podAnnotations) . | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $configMapsFound := false -}}
|
||||
{{- range $name, $configmap := .Values.configmap -}}
|
||||
{{- if $configmap.enabled -}}
|
||||
{{- $configMapsFound = true -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $configMapsFound -}}
|
||||
{{- printf "checksum/config: %v" (include ("ytproxy.configmap") . | sha256sum) | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
105
charts/apps/piped/templates/ytproxy/lib/_pod.tpl
Normal file
105
charts/apps/piped/templates/ytproxy/lib/_pod.tpl
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
{{- /*
|
||||
The pod definition included in the controller.
|
||||
*/ -}}
|
||||
{{- define "ytproxy.controller.pod" -}}
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "ytproxy.names.serviceAccountName" . }}
|
||||
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
|
||||
{{- with .Values.podSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.priorityClassName }}
|
||||
priorityClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.runtimeClassName }}
|
||||
runtimeClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.schedulerName }}
|
||||
schedulerName: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.hostNetwork }}
|
||||
hostNetwork: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.hostname }}
|
||||
hostname: {{ . }}
|
||||
{{- end }}
|
||||
{{- if .Values.dnsPolicy }}
|
||||
dnsPolicy: {{ .Values.dnsPolicy }}
|
||||
{{- else if .Values.hostNetwork }}
|
||||
dnsPolicy: ClusterFirstWithHostNet
|
||||
{{- else }}
|
||||
dnsPolicy: ClusterFirst
|
||||
{{- end }}
|
||||
{{- with .Values.dnsConfig }}
|
||||
dnsConfig:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
enableServiceLinks: {{ .Values.enableServiceLinks }}
|
||||
{{- with .Values.termination.gracePeriodSeconds }}
|
||||
terminationGracePeriodSeconds: {{ . }}
|
||||
{{- end }}
|
||||
{{- if .Values.initContainers }}
|
||||
initContainers:
|
||||
{{- $initContainers := list }}
|
||||
{{- range $index, $key := (keys .Values.initContainers | uniq | sortAlpha) }}
|
||||
{{- $container := get $.Values.initContainers $key }}
|
||||
{{- if not $container.name -}}
|
||||
{{- $_ := set $container "name" $key }}
|
||||
{{- end }}
|
||||
{{- if $container.env -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "env" $container.env) -}}
|
||||
{{- $newEnv := fromYaml (include "common.controller.env_vars" $) -}}
|
||||
{{- $_ := unset $.ObjectValues "env" -}}
|
||||
{{- $_ := set $container "env" $newEnv.env }}
|
||||
{{- end }}
|
||||
{{- $initContainers = append $initContainers $container }}
|
||||
{{- end }}
|
||||
{{- tpl (toYaml $initContainers) $ | nindent 2 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
{{- include "ytproxy.controller.mainContainer" . | nindent 2 }}
|
||||
{{- with .Values.additionalContainers }}
|
||||
{{- $additionalContainers := list }}
|
||||
{{- range $name, $container := . }}
|
||||
{{- if not $container.name -}}
|
||||
{{- $_ := set $container "name" $name }}
|
||||
{{- end }}
|
||||
{{- if $container.env -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "env" $container.env) -}}
|
||||
{{- $newEnv := fromYaml (include "ytproxy.controller.env_vars" $) -}}
|
||||
{{- $_ := set $container "env" $newEnv.env }}
|
||||
{{- $_ := unset $.ObjectValues "env" -}}
|
||||
{{- end }}
|
||||
{{- $additionalContainers = append $additionalContainers $container }}
|
||||
{{- end }}
|
||||
{{- tpl (toYaml $additionalContainers) $ | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with (include "ytproxy.controller.volumes" . | trim) }}
|
||||
volumes:
|
||||
{{- nindent 2 . }}
|
||||
{{- end }}
|
||||
{{- with .Values.hostAliases }}
|
||||
hostAliases:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.topologySpreadConstraints }}
|
||||
topologySpreadConstraints:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
36
charts/apps/piped/templates/ytproxy/lib/_ports.tpl
Normal file
36
charts/apps/piped/templates/ytproxy/lib/_ports.tpl
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{{/*
|
||||
Ports included by the controller.
|
||||
*/}}
|
||||
{{- define "ytproxy.controller.ports" -}}
|
||||
{{- $ports := list -}}
|
||||
{{- range .Values.ytproxy.service -}}
|
||||
{{- if .enabled -}}
|
||||
{{- range $name, $port := .ports -}}
|
||||
{{- $_ := set $port "name" $name -}}
|
||||
{{- $ports = mustAppend $ports $port -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/* export/render the list of ports */}}
|
||||
{{- if $ports -}}
|
||||
{{- range $_ := $ports }}
|
||||
{{- if .enabled }}
|
||||
- name: {{ .name }}
|
||||
{{- if and .targetPort (kindIs "string" .targetPort) }}
|
||||
{{- fail (printf "Our charts do not support named ports for targetPort. (port name %s, targetPort %s)" .name .targetPort) }}
|
||||
{{- end }}
|
||||
containerPort: {{ .targetPort | default .port }}
|
||||
{{- if .protocol }}
|
||||
{{- if or ( eq .protocol "HTTP" ) ( eq .protocol "HTTPS" ) ( eq .protocol "TCP" ) }}
|
||||
protocol: TCP
|
||||
{{- else }}
|
||||
protocol: {{ .protocol }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
33
charts/apps/piped/templates/ytproxy/lib/_probes.tpl
Normal file
33
charts/apps/piped/templates/ytproxy/lib/_probes.tpl
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{{/*
|
||||
Probes selection logic.
|
||||
*/}}
|
||||
{{- define "ytproxy.controller.probes" -}}
|
||||
{{- $primaryService := get .Values.backend.service (include "ytproxy.service.primary" .) -}}
|
||||
{{- $primaryPort := "" -}}
|
||||
{{- if $primaryService -}}
|
||||
{{- $primaryPort = get $primaryService.ports (include "ytproxy.classes.service.ports.primary" (dict "serviceName" (include "ytproxy.service.primary" .) "values" $primaryService)) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $probeName, $probe := .Values.probes }}
|
||||
{{- if $probe.enabled -}}
|
||||
{{- "" | nindent 0 }}
|
||||
{{- $probeName }}Probe:
|
||||
{{- if $probe.custom -}}
|
||||
{{- $probe.spec | toYaml | nindent 2 }}
|
||||
{{- else }}
|
||||
{{- if and $primaryService $primaryPort -}}
|
||||
{{- "tcpSocket:" | nindent 2 }}
|
||||
{{- if $primaryPort.targetPort }}
|
||||
{{- printf "port: %v" $primaryPort.targetPort | nindent 4 }}
|
||||
{{- else}}
|
||||
{{- printf "port: %v" $primaryPort.port | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- printf "initialDelaySeconds: %v" $probe.spec.initialDelaySeconds | nindent 2 }}
|
||||
{{- printf "failureThreshold: %v" $probe.spec.failureThreshold | nindent 2 }}
|
||||
{{- printf "timeoutSeconds: %v" $probe.spec.timeoutSeconds | nindent 2 }}
|
||||
{{- printf "periodSeconds: %v" $probe.spec.periodSeconds | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
186
charts/apps/piped/templates/ytproxy/lib/_service.tpl
Normal file
186
charts/apps/piped/templates/ytproxy/lib/_service.tpl
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
{{/*
|
||||
Renders the Service objects required by the chart.
|
||||
*/}}
|
||||
{{- define "ytproxy.service" -}}
|
||||
{{- /* Generate named services as required */ -}}
|
||||
{{- range $name, $service := .Values.ytproxy.service }}
|
||||
{{- if $service.enabled -}}
|
||||
{{- $serviceValues := $service -}}
|
||||
|
||||
{{/* set the default nameOverride to the service name */}}
|
||||
{{- if and (not $serviceValues.nameOverride) (ne $name (include "ytproxy.service.primary" $)) -}}
|
||||
{{- $_ := set $serviceValues "nameOverride" $name -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}}
|
||||
{{- include "ytproxy.classes.service" $ }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Return the primary service object
|
||||
*/}}
|
||||
{{- define "ytproxy.service.primary" -}}
|
||||
{{- $enabledServices := dict -}}
|
||||
{{- range $name, $service := .Values.ytproxy.service -}}
|
||||
{{- if $service.enabled -}}
|
||||
{{- $_ := set $enabledServices $name . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $result := "" -}}
|
||||
{{- range $name, $service := $enabledServices -}}
|
||||
{{- if and (hasKey $service "primary") $service.primary -}}
|
||||
{{- $result = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not $result -}}
|
||||
{{- $result = keys $enabledServices | first -}}
|
||||
{{- end -}}
|
||||
{{- $result -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the primary port for a given Service object.
|
||||
*/}}
|
||||
{{- define "ytproxy.classes.service.ports.primary" -}}
|
||||
{{- $enabledPorts := dict -}}
|
||||
{{- range $name, $port := .values.ports -}}
|
||||
{{- if $port.enabled -}}
|
||||
{{- $_ := set $enabledPorts $name . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq 0 (len $enabledPorts) }}
|
||||
{{- fail (printf "No ports are enabled for service \"%s\"!" .serviceName) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $result := "" -}}
|
||||
{{- range $name, $port := $enabledPorts -}}
|
||||
{{- if and (hasKey $port "primary") $port.primary -}}
|
||||
{{- $result = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not $result -}}
|
||||
{{- $result = keys $enabledPorts | first -}}
|
||||
{{- end -}}
|
||||
{{- $result -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
This saves the name of the service in a global variable
|
||||
*/}}
|
||||
{{- define "ytproxy.servicename" -}}
|
||||
{{- $values := .Values.ytproxy.service -}}
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.service -}}
|
||||
{{- $values = . -}}
|
||||
{{- end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- $serviceName := include "ytproxy.names.fullname" . -}}
|
||||
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
|
||||
{{- $serviceName = printf "%v-%v" $serviceName $values.nameOverride -}}
|
||||
{{ end -}}
|
||||
{{ $serviceName }}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/*
|
||||
This template serves as a blueprint for all Service objects that are created
|
||||
within the web.
|
||||
*/}}
|
||||
{{- define "ytproxy.classes.service" -}}
|
||||
{{- $values := .Values.ytproxy.service -}}
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.service -}}
|
||||
{{- $values = . -}}
|
||||
{{- end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- $serviceName := include "ytproxy.names.fullname" . -}}
|
||||
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
|
||||
{{- $serviceName = printf "%v-%v" $serviceName $values.nameOverride -}}
|
||||
{{ end -}}
|
||||
{{- $svcType := $values.type | default "" -}}
|
||||
{{- $primaryPort := get $values.ports (include "ytproxy.classes.service.ports.primary" (dict "values" $values)) }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: piped-ytproxy
|
||||
{{- with (merge ($values.labels | default dict) (include "ytproxy.labels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- with (merge ($values.annotations | default dict) (include "ytproxy.annotations" $ | fromYaml)) }}
|
||||
{{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if (or (eq $svcType "ClusterIP") (empty $svcType)) }}
|
||||
type: ClusterIP
|
||||
{{- if $values.clusterIP }}
|
||||
clusterIP: {{ $values.clusterIP }}
|
||||
{{end}}
|
||||
{{- else if eq $svcType "LoadBalancer" }}
|
||||
type: {{ $svcType }}
|
||||
{{- if $values.loadBalancerIP }}
|
||||
loadBalancerIP: {{ $values.loadBalancerIP }}
|
||||
{{- end }}
|
||||
{{- if $values.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges:
|
||||
{{ toYaml $values.loadBalancerSourceRanges | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- else }}
|
||||
type: {{ $svcType }}
|
||||
{{- end }}
|
||||
{{- if $values.externalTrafficPolicy }}
|
||||
externalTrafficPolicy: {{ $values.externalTrafficPolicy }}
|
||||
{{- end }}
|
||||
{{- if $values.sessionAffinity }}
|
||||
sessionAffinity: {{ $values.sessionAffinity }}
|
||||
{{- if $values.sessionAffinityConfig }}
|
||||
sessionAffinityConfig:
|
||||
{{ toYaml $values.sessionAffinityConfig | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{- with $values.externalIPs }}
|
||||
externalIPs:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if $values.publishNotReadyAddresses }}
|
||||
publishNotReadyAddresses: {{ $values.publishNotReadyAddresses }}
|
||||
{{- end }}
|
||||
{{- if $values.ipFamilyPolicy }}
|
||||
ipFamilyPolicy: {{ $values.ipFamilyPolicy }}
|
||||
{{- end }}
|
||||
{{- with $values.ipFamilies }}
|
||||
ipFamilies:
|
||||
{{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
{{- range $name, $port := $values.ports }}
|
||||
{{- if $port.enabled }}
|
||||
- port: {{ $port.port }}
|
||||
targetPort: {{ $port.targetPort | default $name }}
|
||||
{{- if $port.protocol }}
|
||||
{{- if or ( eq $port.protocol "HTTP" ) ( eq $port.protocol "HTTPS" ) ( eq $port.protocol "TCP" ) }}
|
||||
protocol: TCP
|
||||
{{- else }}
|
||||
protocol: {{ $port.protocol }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
name: {{ $name }}
|
||||
{{- if (and (eq $svcType "NodePort") (not (empty $port.nodePort))) }}
|
||||
nodePort: {{ $port.nodePort }}
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "ytproxy.labels.selectorLabels" . | nindent 4 }}
|
||||
{{- end }}
|
||||
64
charts/apps/piped/templates/ytproxy/lib/_volumes.tpl
Normal file
64
charts/apps/piped/templates/ytproxy/lib/_volumes.tpl
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{{/*
|
||||
Volumes included by the controller.
|
||||
*/}}
|
||||
{{- define "ytproxy.controller.volumes" -}}
|
||||
{{- range $index, $persistence := .Values.persistence }}
|
||||
{{- if $persistence.enabled }}
|
||||
- name: {{ $index }}
|
||||
{{- if eq (default "pvc" $persistence.type) "pvc" }}
|
||||
{{- $pvcName := (include "common.names.fullname" $) -}}
|
||||
{{- if $persistence.existingClaim }}
|
||||
{{- /* Always prefer an existingClaim if that is set */}}
|
||||
{{- $pvcName = $persistence.existingClaim -}}
|
||||
{{- else -}}
|
||||
{{- /* Otherwise refer to the PVC name */}}
|
||||
{{- if $persistence.nameOverride -}}
|
||||
{{- if not (eq $persistence.nameOverride "-") -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $persistence.nameOverride) -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $index) -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ $pvcName }}
|
||||
{{- else if or (eq $persistence.type "configMap") (eq $persistence.type "secret") }}
|
||||
{{- $objectName := (required (printf "name not set for persistence item %s" $index) $persistence.name) }}
|
||||
{{- $objectName = tpl $objectName $ }}
|
||||
{{- if eq $persistence.type "configMap" }}
|
||||
configMap:
|
||||
name: {{ $objectName }}
|
||||
{{- else }}
|
||||
secret:
|
||||
secretName: {{ $objectName }}
|
||||
{{- end }}
|
||||
{{- with $persistence.defaultMode }}
|
||||
defaultMode: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $persistence.items }}
|
||||
items:
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- else if eq $persistence.type "emptyDir" }}
|
||||
{{- $emptyDir := dict -}}
|
||||
{{- with $persistence.medium -}}
|
||||
{{- $_ := set $emptyDir "medium" . -}}
|
||||
{{- end -}}
|
||||
{{- with $persistence.sizeLimit -}}
|
||||
{{- $_ := set $emptyDir "sizeLimit" . -}}
|
||||
{{- end }}
|
||||
emptyDir: {{- $emptyDir | toYaml | nindent 4 }}
|
||||
{{- else if eq $persistence.type "hostPath" }}
|
||||
hostPath:
|
||||
path: {{ required "hostPath not set" $persistence.hostPath }}
|
||||
{{- with $persistence.hostPathType }}
|
||||
type: {{ . }}
|
||||
{{- end }}
|
||||
{{- else if eq $persistence.type "custom" }}
|
||||
{{- toYaml $persistence.volumeSpec | nindent 2 }}
|
||||
{{- else }}
|
||||
{{- fail (printf "Not a valid persistence.type (%s)" .Values.persistence.type) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
1
charts/apps/piped/templates/ytproxy/service.yaml
Normal file
1
charts/apps/piped/templates/ytproxy/service.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
{{ include "ytproxy.service" . | nindent 0 }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue