mirror of
https://github.com/truenas/charts.git
synced 2026-06-16 23:19:15 +08:00
initial portal work
This commit is contained in:
38
library/common/1.0.0/templates/class/_portal.tpl
Normal file
38
library/common/1.0.0/templates/class/_portal.tpl
Normal file
@@ -0,0 +1,38 @@
|
||||
{{- define "ix.v1.common.class.portal" -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
---
|
||||
apiVersion: {{- include "ix.v1.common.capabilities.configMap.apiVersion" . -}}
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: portal
|
||||
{{- $labels := (default dict (include "ix.v1.common.labels" $root | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.util.labels.render" (dict "root" $root "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- $annotations := (default dict (include "ix.v1.common.annotations" $root | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.util.annotations.render" (dict "root" $root "annotations" $annotations) | trim) }}
|
||||
annotations:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
{{- range $svcName, $svc := $root.Values.service }}
|
||||
{{- if $svc.enabled -}}
|
||||
{{- $svcValues := $svc -}}
|
||||
{{- range $portName, $port := $svc.ports }}
|
||||
{{- if (mustHas $port.protocol (list "HTTP" "HTTPS")) -}}
|
||||
{{- $portalProtocol := include "ix.v1.common.portal.protocol" (dict "svcType" $svc.type "svcName" $svcName "portName" $portName "port" $port "root" $root) | trim }}
|
||||
{{- $portalHost := include "ix.v1.common.portal.host" (dict "svcType" $svc.type "svcName" $svcName "portName" $portName "port" $port "root" $root) | trim }}
|
||||
{{- $portalPort := include "ix.v1.common.portal.port" (dict "svcType" $svc.type "svcName" $svcName "portName" $portName "port" $port "root" $root) | trim }}
|
||||
{{- $portalPath := include "ix.v1.common.portal.path" (dict "svcType" $svc.type "svcName" $svcName "portName" $portName "port" $port "root" $root) | trim }}
|
||||
{{ printf "protocol-%v-%v" $svcName $portName }}: {{ $portalProtocol }}
|
||||
{{ printf "host-%v-%v" $svcName $portName }}: {{ $portalHost }}
|
||||
{{ printf "path-%v-%v" $svcName $portName }}: {{ $portalPath }}
|
||||
{{ printf "port-%v-%v" $svcName $portName }}: {{ $portalPort }}
|
||||
{{ printf "url-%v-%v" $svcName $portName }}: {{ printf "%v://%v:%v%v" $portalProtocol $portalHost $portalPort $portalPath }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
25
library/common/1.0.0/templates/lib/portal/_host.tpl
Normal file
25
library/common/1.0.0/templates/lib/portal/_host.tpl
Normal file
@@ -0,0 +1,25 @@
|
||||
{{- define "ix.v1.common.portal.host" -}}
|
||||
{{- $svcType := .svcType -}}
|
||||
{{- $svcName := .svcName -}}
|
||||
{{- $portName := .portName -}}
|
||||
{{- $port := .port -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
{{- $portalHost := "$node_ip" -}}
|
||||
|
||||
{{/* If ingress is added at any point, here is the place to implement */}}
|
||||
|
||||
{{/* Check if there are any overrides in .Values.portal */}}
|
||||
{{- range $name, $portalSvc := $root.Values.portal -}}
|
||||
{{- if eq $svcName $name -}}
|
||||
{{- range $name, $portalPort := $portalSvc -}}
|
||||
{{- if eq $portName $name -}}
|
||||
{{- with $portalPort.host -}}
|
||||
{{- $portalHost = (tpl . $root) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{ $portalHost }}
|
||||
{{- end -}}
|
||||
25
library/common/1.0.0/templates/lib/portal/_path.tpl
Normal file
25
library/common/1.0.0/templates/lib/portal/_path.tpl
Normal file
@@ -0,0 +1,25 @@
|
||||
{{- define "ix.v1.common.portal.path" -}}
|
||||
{{- $svcType := .svcType -}}
|
||||
{{- $svcName := .svcName -}}
|
||||
{{- $portName := .portName -}}
|
||||
{{- $port := .port -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
{{- $portalPath := "/" -}}
|
||||
|
||||
{{/* If ingress is added at any point, here is the place to implement */}}
|
||||
|
||||
{{/* Check if there are any overrides in .Values.portal */}}
|
||||
{{- range $name, $portalSvc := $root.Values.portal -}}
|
||||
{{- if eq $svcName $name -}}
|
||||
{{- range $name, $portalPort := $portalSvc -}}
|
||||
{{- if eq $portName $name -}}
|
||||
{{- with $portalPort.path -}}
|
||||
{{- $portalPath = (tpl . $root) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{ $portalPath }}
|
||||
{{- end -}}
|
||||
33
library/common/1.0.0/templates/lib/portal/_port.tpl
Normal file
33
library/common/1.0.0/templates/lib/portal/_port.tpl
Normal file
@@ -0,0 +1,33 @@
|
||||
{{- define "ix.v1.common.portal.port" -}}
|
||||
{{- $svcType := .svcType -}}
|
||||
{{- $svcName := .svcName -}}
|
||||
{{- $portName := .portName -}}
|
||||
{{- $port := .port -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
{{- $portalPort := 443 -}}
|
||||
|
||||
{{- if $root.Values.hostNetwork -}}
|
||||
{{- $portalPort = (default $port.port $port.targetPort) -}}
|
||||
{{- else if eq $svcType "NodePort" -}}
|
||||
{{- $portalPort = $port.nodePort -}}
|
||||
{{- else if eq $svcType "LoadBalancer" -}}
|
||||
{{- $portalPort = $port.port -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* If ingress is added at any point, here is the place to implement */}}
|
||||
|
||||
{{/* Check if there are any overrides in .Values.portal */}}
|
||||
{{- range $name, $portalSvc := $root.Values.portal -}}
|
||||
{{- if eq $svcName $name -}}
|
||||
{{- range $name, $portalPort := $portalSvc -}}
|
||||
{{- if eq $portName $name -}}
|
||||
{{- with $portalPort.port -}}
|
||||
{{- $portalPort = (tpl . $root) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{ $portalPort }}
|
||||
{{- end -}}
|
||||
31
library/common/1.0.0/templates/lib/portal/_protocol.tpl
Normal file
31
library/common/1.0.0/templates/lib/portal/_protocol.tpl
Normal file
@@ -0,0 +1,31 @@
|
||||
{{- define "ix.v1.common.portal.protocol" -}}
|
||||
{{- $svcType := .svcType -}}
|
||||
{{- $svcName := .svcName -}}
|
||||
{{- $portName := .portName -}}
|
||||
{{- $port := .port -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
{{- $portalProtocol := "http" -}}
|
||||
|
||||
{{- if $port.protocol -}}
|
||||
{{- if (has $port.protocol (list "HTTP" "HTTPS")) -}}
|
||||
{{ $portalProtocol = ($port.protocol | lower) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* If ingress is added at any point, here is the place to implement */}}
|
||||
|
||||
{{/* Check if there are any overrides in .Values.portal */}}
|
||||
{{- range $name, $portalSvc := $root.Values.portal -}}
|
||||
{{- if eq $svcName $name -}}
|
||||
{{- range $name, $portalPort := $portalSvc -}}
|
||||
{{- if eq $portName $name -}}
|
||||
{{- with $portalPort.protocol -}}
|
||||
{{- $portalProtocol = (tpl . $root) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{ $portalProtocol }}
|
||||
{{- end -}}
|
||||
@@ -21,4 +21,6 @@
|
||||
{{- include "ix.v1.common.spawner.service" . | nindent 0 -}}
|
||||
|
||||
{{- include "ix.v1.common.spawner.pvc" . | nindent 0 -}}
|
||||
|
||||
{{- include "ix.v1.common.spawner.portal" . | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
7
library/common/1.0.0/templates/spawner/_portal.tpl
Normal file
7
library/common/1.0.0/templates/spawner/_portal.tpl
Normal file
@@ -0,0 +1,7 @@
|
||||
{{- define "ix.v1.common.spawner.portal" -}}
|
||||
{{- if .Values.portal -}}
|
||||
{{- if .Values.portal.enabled -}}
|
||||
{{- include "ix.v1.common.class.portal" (dict "root" $) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -147,6 +147,16 @@ global:
|
||||
annotations: {}
|
||||
labels: {}
|
||||
|
||||
portal:
|
||||
# Whether to generate portal configMaps
|
||||
enabled: true
|
||||
# main:
|
||||
# main:
|
||||
# path: /somepath
|
||||
# port: 123
|
||||
# protocol: http
|
||||
# host: blabla
|
||||
|
||||
nameOverride: ""
|
||||
|
||||
fullnameOverride: ""
|
||||
|
||||
Reference in New Issue
Block a user