mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-05 11:06:20 -03:00
working portal generator
This commit is contained in:
@@ -27,10 +27,10 @@ service:
|
||||
enabled: true
|
||||
port: 8080
|
||||
protocol: http
|
||||
autolink:
|
||||
test:
|
||||
enabled: true
|
||||
ports:
|
||||
autolink:
|
||||
test:
|
||||
enabled: true
|
||||
protocol: http
|
||||
port: 8081
|
||||
@@ -55,7 +55,17 @@ ingress:
|
||||
name:
|
||||
port:
|
||||
tls: []
|
||||
|
||||
test:
|
||||
enabled: true
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
service:
|
||||
name:
|
||||
port:
|
||||
tls: []
|
||||
"ixCertificateAuthorities": {}
|
||||
"ixCertificates":
|
||||
"1":
|
||||
@@ -112,13 +122,34 @@ ingress:
|
||||
|
||||
portal:
|
||||
open:
|
||||
enabled: false
|
||||
enabled: true
|
||||
override:
|
||||
protocol:
|
||||
host:
|
||||
port:
|
||||
urlSuffix: ""
|
||||
path: ""
|
||||
path:
|
||||
enabled: true
|
||||
path: "somepath"
|
||||
explicit:
|
||||
enabled: true
|
||||
targetSelector:
|
||||
ingress: ""
|
||||
service: ""
|
||||
ingress: "test"
|
||||
service: "test"
|
||||
port: ""
|
||||
override:
|
||||
enabled: true
|
||||
override:
|
||||
protocol: "http"
|
||||
host: "test.example.com"
|
||||
port: "666"
|
||||
override-explicit:
|
||||
enabled: true
|
||||
override:
|
||||
protocol: "http"
|
||||
host: "test.example.com"
|
||||
port: "666"
|
||||
targetSelector:
|
||||
ingress: "test"
|
||||
service: "test"
|
||||
port: ""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{/* Return the name of the primary ingress object */}}
|
||||
{{- define "tc.v1.common.lib.util.ingress.primary" -}}
|
||||
{{- $ingresses := .ingresses -}}
|
||||
{{- $ingresses := $.Values.ingress -}}
|
||||
|
||||
{{- $enabledIngresses := dict -}}
|
||||
{{- range $name, $ingress := $ingresses -}}
|
||||
|
||||
@@ -11,19 +11,22 @@
|
||||
|
||||
{{/* Create a copy of the portal */}}
|
||||
{{- $objectData := (mustDeepCopy $portal) -}}
|
||||
{{- $override := $objectData.override -}}
|
||||
{{- $targetSelector := $objectData.targetSelector -}}
|
||||
|
||||
{{/* Create defaults */}}
|
||||
{{- $protocol := "https" -}}
|
||||
{{- $host := "$node_ip" -}}
|
||||
{{- $port := "443" -}}
|
||||
{{- $suffix := $objectData.urlSuffix -}}
|
||||
{{- $path := $objectData.path | default "/" -}}
|
||||
{{- $url := "" -}}
|
||||
|
||||
{{/* Get service, default to primary */}}
|
||||
{{- $serviceData := dict "targetSelector" $objectData.targetSelector.service -}}
|
||||
{{- $selectedService := fromYaml ( include "tc.v1.common.lib.helpers.getSelectedServiceValues" (dict "rootCtx" $ "objectData" $serviceData)) }}
|
||||
|
||||
|
||||
{{/* Get service, default to primary */}}
|
||||
{{- $serviceData := dict "targetSelector" $targetSelector.service -}}
|
||||
{{- $selectedService := fromYaml ( include "tc.v1.common.lib.helpers.getSelectedServiceValues" (dict "rootCtx" $ "objectData" $serviceData)) }}
|
||||
|
||||
|
||||
{{/* read loadbalancer IP's for metallb */}}
|
||||
{{- if eq $selectedService.type "LoadBalancer" -}}
|
||||
@@ -36,8 +39,8 @@
|
||||
{{- $selectedPort := "" -}}
|
||||
|
||||
{{/* Fetch port values */}}
|
||||
{{- if $objectData.targetSelector.port -}}
|
||||
{{- $targetPort := $objectData.targetSeleector.port -}}
|
||||
{{- if $targetSelector.port -}}
|
||||
{{- $targetPort := $targetSelector.port -}}
|
||||
{{- else -}}
|
||||
{{- $targetPort := include "tc.v1.common.lib.util.service.ports.primary" $selectedService -}}
|
||||
{{- end -}}
|
||||
@@ -54,11 +57,12 @@
|
||||
{{- $selectedIngress := "" -}}
|
||||
|
||||
{{/* Fetch ingress values */}}
|
||||
{{- if $objectData.targetSelector.ingress -}}
|
||||
{{- $targetIngress := $objectData.targetSelector.ingress -}}
|
||||
{{- if $targetSelector.ingress -}}
|
||||
{{- $targetIngress = $targetSelector.ingress -}}
|
||||
{{- else -}}
|
||||
{{- $targetIngress := include "tc.v1.common.lib.util.ingress.primary" $ -}}
|
||||
{{- $targetIngress = ( include "tc.v1.common.lib.util.ingress.primary" $ ) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $selectedIngress = get $.Values.ingress $targetIngress -}}
|
||||
|
||||
{{/* store host from ingress number */}}
|
||||
@@ -67,27 +71,42 @@
|
||||
{{- with (index $selectedIngress.hosts 0) }}
|
||||
{{- $host = .host -}}
|
||||
{{- end }}
|
||||
|
||||
{{/* Get the port for the ingress entrypoint */}}
|
||||
{{- $namespace := "tc-system" }}
|
||||
{{- if $selectedIngress.ingressClassName }}
|
||||
{{- $namespace := ( printf "ix-%s" $selectedIngress.ingressClassName ) }}
|
||||
{{- end }}
|
||||
{{- $traefikportalhook := lookup "v1" "ConfigMap" $namespace "portalhook" }}
|
||||
|
||||
{{- $entrypoint := "websecure" }}
|
||||
{{- if $selectedIngress.entrypoint }}
|
||||
{{- $entrypoint = $selectedIngress.entrypoint }}
|
||||
{{- end }}
|
||||
|
||||
{{/* TODO: grab ports via portal */}}
|
||||
{{- if $traefikportalhook }}
|
||||
{{- if ( index $traefikportalhook.data $entrypoint ) }}
|
||||
{{- $port = ( index $traefikportalhook.data $entrypoint ) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/* Apply overrides */}}
|
||||
{{- if $objectData.override.protocol -}}
|
||||
{{- $protocol = $objectData.override.protocol -}}
|
||||
{{- if $override.protocol -}}
|
||||
{{- $protocol = $override.protocol -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $objectData.override.host -}}
|
||||
{{- $host = $objectData.override.host -}}
|
||||
{{- if $override.host -}}
|
||||
{{- $host = $override.host -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $objectData.override.port -}}
|
||||
{{- $port = $objectData.override.port -}}
|
||||
{{- if $override.port -}}
|
||||
{{- $port = $override.port -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
|
||||
{{/* sanitise */}}
|
||||
{{- if eq $port "443" -}}
|
||||
{{- $protocol = "https" -}}
|
||||
@@ -97,22 +116,24 @@
|
||||
{{- $protocol = "http" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if or ( eq $protocol "https" ) ( eq $protocol "http" ) -}}
|
||||
{{- if or ( and ( eq $protocol "https" ) ( eq $port "443" ) ) ( and ( eq $protocol "http" ) ( eq $port "80" ) ) -}}
|
||||
{{- $port = "" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $port = toString $port -}}
|
||||
|
||||
{{/* Construct URL*/}}
|
||||
{{- if $port -}}
|
||||
{{- $url = printf "%s://%s:%s/%s" $protocol $host $port $suffix -}}
|
||||
{{- $url = printf "%s://%s:%s%s" $protocol $host $port $path -}}
|
||||
{{- else -}}
|
||||
{{- $url = printf "%s://%s/%s" $protocol $host $suffix -}}
|
||||
{{- $url = printf "%s://%s%s" $protocol $host $path -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* create configmap entry*/}}
|
||||
{{- $portalData := dict "protocol" $protocol "host" $host "port" $port "suffix" $suffix "url" $url -}}
|
||||
{{- $portalData := dict "protocol" $protocol "host" $host "port" $port "path" $path "url" $url -}}
|
||||
|
||||
{{/* construct configmap */}}
|
||||
{{- $objectName := "tcportal" -}}
|
||||
{{- $objectName := ( printf "tcportal-%s" $name ) -}}
|
||||
{{- $configMap := dict "enabled" true "name" $objectName "shortName" $objectName "data" $portalData -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
@@ -123,6 +144,16 @@
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.configmap" (dict "rootCtx" $ "objectData" $configMap) -}}
|
||||
|
||||
{{/* iXportals */}}
|
||||
{{- $useNodeIP := false -}}
|
||||
{{- if eq $host "$node_ip" -}}
|
||||
{{- $useNodeIP = true -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $iXPortalData := dict "portalName" $name "useNodeIP" $useNodeIP "protocol" $protocol "host" $host "port" $port "path" $path "url" $url -}}
|
||||
{{- $iXPortals := append $.Values.iXPortals $iXPortalData -}}
|
||||
{{- $_ := set $.Values "iXPortals" $iXPortals -}}
|
||||
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -267,12 +267,14 @@ portal:
|
||||
protocol:
|
||||
host:
|
||||
port:
|
||||
urlSuffix: ""
|
||||
path: ""
|
||||
targetSelector:
|
||||
ingress: ""
|
||||
service: ""
|
||||
port: ""
|
||||
|
||||
iXPortals: []
|
||||
|
||||
# -- Used to inject our own operator manifests into SCALE
|
||||
manifestManager:
|
||||
enabled: true
|
||||
|
||||
Reference in New Issue
Block a user