rancher-partner-charts/charts/kasten/k10/templates/v0services.yaml

200 lines
6.5 KiB
YAML
Raw Normal View History

2022-10-07 14:45:01 +00:00
{{/* Template to generate service spec for v0 rest services */}}
{{- $container_port := .Values.service.internalPort -}}
{{- $service_port := .Values.service.externalPort -}}
{{- $aggregated_api_port := .Values.service.aggregatedApiPort -}}
{{- $postfix := default .Release.Name .Values.ingress.urlPath -}}
{{- $colocated_services := include "k10.colocatedServices" . | fromYaml -}}
{{- $exposed_services := include "k10.exposedServices" . | splitList " " -}}
{{- $os_postfix := default .Release.Name .Values.route.path -}}
{{- $main_context := . -}}
{{ $service_list := append (include "k10.restServices" . | splitList " ") "frontend" }}
{{- if not (default .Values.features dict).multicluster -}}
{{- $service_list = without $service_list "mccontrollermanager" -}}
{{- end -}}
{{- range $service_list }}
{{- $exposed_service := (has . $exposed_services) }}
{{- $mc_exposed_service := (and (eq . "mccontrollermanager") (default $.Values.features dict).multicluster) }}
{{ if not (hasKey $colocated_services . ) }}
apiVersion: v1
kind: Service
metadata:
namespace: {{ $.Release.Namespace }}
name: {{ . }}-svc
labels:
{{ include "helm.labels" $ | indent 4 }}
component: {{ . }}
run: {{ . }}-svc
{{ if or $exposed_service (eq . "frontend") $mc_exposed_service }}
annotations:
getambassador.io/config: |
{{- if or $exposed_service (eq . "frontend") }}
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
name: {{ . }}-mapping
{{- if $.Values.route.enabled }}
{{- if eq . "frontend" }}
prefix: /{{ $os_postfix | trimPrefix "/" | trimSuffix "/" }}/
{{- else }}
prefix: /{{ $os_postfix | trimPrefix "/" | trimSuffix "/" }}/{{ . }}-svc/
{{- end }}
{{- else }}
{{- if eq . "frontend" }}
prefix: /{{ $postfix | trimPrefix "/" | trimSuffix "/" }}/
{{- else }}
prefix: /{{ $postfix | trimPrefix "/" | trimSuffix "/" }}/{{ . }}-svc/
{{- end }}
{{- end }}
rewrite: /
service: {{ . }}-svc.{{ $.Release.Namespace }}:{{ $service_port }}
timeout_ms: 30000
hostname: "*"
ambassador_id: [ {{ include "k10.ambassadorId" . }} ]
{{- end }}
{{- $colocatedList := include "get.enabledColocatedSvcList" $main_context | fromYaml }}
{{- range $skip, $secondary := index $colocatedList . }}
{{- $colocConfig := index (include "k10.colocatedServices" . | fromYaml) $secondary }}
{{- if $colocConfig.isExposed }}
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
name: {{ $secondary }}-mapping
prefix: /{{ $postfix }}/{{ $secondary }}-svc/
rewrite: /
service: {{ $colocConfig.primary }}-svc.{{ $.Release.Namespace }}:{{ $colocConfig.port }}
timeout_ms: 30000
hostname: "*"
ambassador_id: [ {{ include "k10.ambassadorId" . }} ]
{{- end }}
{{- end }}
{{- if $mc_exposed_service }}
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
name: {{ . }}-mc-mapping
{{- if $.Values.route.enabled }}
prefix: /{{ $os_postfix | trimPrefix "/" | trimSuffix "/" }}/mc/
{{- else }}
prefix: /{{ $postfix | trimPrefix "/" | trimSuffix "/" }}/mc/
{{- end }}
rewrite: /
service: {{ . }}-svc.{{ $.Release.Namespace }}:{{ include "k10.mcExternalPort" nil }}
bypass_auth: true
timeout_ms: 30000
hostname: "*"
ambassador_id: [ {{ include "k10.ambassadorId" . }} ]
{{- end }}
{{- end }}
spec:
ports:
- name: http
protocol: TCP
port: {{ $service_port }}
targetPort: {{ $container_port }}
{{- if and (eq . "controllermanager") ($.Values.injectKanisterSidecar.enabled) }}
- name: https
protocol: TCP
port: 443
targetPort: {{ $.Values.injectKanisterSidecar.webhookServer.port }}
{{- end }}
{{- $colocatedList := include "get.enabledColocatedSvcList" $main_context | fromYaml }}
{{- range $skip, $secondary := index $colocatedList . }}
{{- $colocConfig := index (include "k10.colocatedServices" . | fromYaml) $secondary }}
- name: {{ $secondary }}
protocol: TCP
port: {{ $colocConfig.port }}
targetPort: {{ $colocConfig.port }}
{{- end }}
{{- if eq . "logging" }}
- name: logging
protocol: TCP
port: 24224
targetPort: 24224
- name: logging-metrics
protocol: TCP
port: 24225
targetPort: 24225
{{- end }}
{{- if eq . "mccontrollermanager" }}
- name: mc-http
protocol: TCP
port: {{ include "k10.mcExternalPort" nil }}
targetPort: {{ include "k10.mcExternalPort" nil }}
{{- end }}
selector:
run: {{ . }}-svc
---
{{ end }}{{/* if not (hasKey $colocated_services $k10_service ) */}}
{{ end -}}{{/* range append (include "k10.restServices" . | splitList " ") "frontend" */}}
{{- range append (include "k10.services" . | splitList " ") "kanister" }}
apiVersion: v1
kind: Service
metadata:
namespace: {{ $.Release.Namespace }}
name: {{ . }}-svc
labels:
{{ include "helm.labels" $ | indent 4 }}
component: {{ . }}
run: {{ . }}-svc
spec:
ports:
{{- if eq . "aggregatedapis" }}
- name: http
port: 443
protocol: TCP
targetPort: {{ $aggregated_api_port }}
{{- else }}
- name: http
protocol: TCP
port: {{ $service_port }}
targetPort: {{ $container_port }}
{{- end }}
{{- $colocatedList := include "get.enabledColocatedSvcList" $main_context | fromYaml }}
{{- range $skip, $secondary := index $colocatedList . }}
{{- $colocConfig := index (include "k10.colocatedServices" . | fromYaml) $secondary }}
- name: {{ $secondary }}
protocol: TCP
port: {{ $colocConfig.port }}
targetPort: {{ $colocConfig.port }}
{{- end }}
selector:
run: {{ . }}-svc
---
{{ end -}}
{{- if or .Values.auth.dex.enabled (eq (include "check.dexAuth" .) "true") }}
apiVersion: v1
kind: Service
metadata:
annotations:
getambassador.io/config: |
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
name: dex-mapping
{{- if $.Values.route.enabled }}
prefix: /{{ $os_postfix | trimPrefix "/" | trimSuffix "/" }}/dex/
{{- else }}
prefix: /{{ $postfix | trimPrefix "/" | trimSuffix "/" }}/dex/
{{- end }}
rewrite: ""
service: dex.{{ $.Release.Namespace }}:8000
timeout_ms: 30000
hostname: "*"
ambassador_id: [ {{ include "k10.ambassadorId" . }} ]
name: dex
namespace: {{ $.Release.Namespace }}
labels:
{{ include "helm.labels" $ | indent 4 }}
component: dex
run: auth-svc
spec:
ports:
- name: http
port: {{ $service_port }}
protocol: TCP
targetPort: 8080
selector:
run: auth-svc
type: ClusterIP
{{ end -}}