200 lines
6.5 KiB
YAML
200 lines
6.5 KiB
YAML
{{/* 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 "get.enabledColocatedServices" . | fromYaml -}}
|
|
{{- $exposed_services := include "get.enabledExposedServices" . | splitList " " -}}
|
|
{{- $os_postfix := default .Release.Name .Values.route.path -}}
|
|
{{- $main_context := . -}}
|
|
{{ $service_list := append (include "get.enabledRestServices" . | splitList " ") "frontend" }}
|
|
{{- range $service_list }}
|
|
{{- $exposed_service := (has . $exposed_services) }}
|
|
{{- $mc_exposed_service := (eq . "controllermanager") }}
|
|
{{ 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 not $.Values.gateway.next_gen }}
|
|
{{- 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 "get.enabledColocatedServices" $main_context | fromYaml) $secondary }}
|
|
{{- if (has $secondary $exposed_services) }}
|
|
---
|
|
apiVersion: getambassador.io/v3alpha1
|
|
kind: Mapping
|
|
name: {{ $secondary }}-mapping
|
|
prefix: /{{ $postfix | trimPrefix "/" | trimSuffix "/" }}/{{ $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 }}
|
|
timeout_ms: 30000
|
|
hostname: "*"
|
|
ambassador_id: [ {{ include "k10.ambassadorId" . }} ]
|
|
{{- end }}
|
|
{{- 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 "get.enabledColocatedServices" $main_context | 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 . "controllermanager" }}
|
|
- 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 "get.enabledRestServices" . | splitList " ") "frontend" */}}
|
|
{{- range append (include "get.enabledServices" . | 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 "get.enabledColocatedServices" . | 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:
|
|
{{- if not $.Values.gateway.next_gen }}
|
|
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" . }} ]
|
|
{{- end }}
|
|
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 -}}
|