Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

update k8s charts; Use ForwardedHeaders; #2161

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/k8s/helm/apigwms/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
labels:
app: {{ template "apigwms.name" . }}
release: {{ .Release.Name }}
{{ if .Values.inf.mesh.enabled -}}
{{ if .Values.inf.mesh.linkerd -}}
annotations:
linkerd.io/inject: enabled
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions deploy/k8s/helm/apigwms/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.ingress.enabled -}}
{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}}
{{- $ingressPath := include "pathBase" . -}}
{{- $serviceName := .Values.app.svc.mobileshoppingapigw -}}

Expand All @@ -18,7 +18,7 @@ metadata:
{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }}
cert-manager.io/issuer: {{ .Values.inf.tls.issuer }}
{{- end }}
{{- if .Values.inf.mesh.enabled }}
{{- if .Values.inf.mesh.linkerd }}
{{- with .Values.ingress.mesh.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
Expand Down
48 changes: 48 additions & 0 deletions deploy/k8s/helm/apigwms/templates/ingresss-istio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- if .Values.ingress.enabled -}}
{{- if .Values.inf.mesh.istio -}}
{{- $ingressPath := include "pathBase" . -}}
{{- $serviceName := .Values.app.svc.mobileshoppingapigw -}}
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: {{ template "apigwms.fullname" . }}
labels:
app: {{ template "apigwms.name" . }}
chart: {{ template "apigwms.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }}
annotations:
cert-manager.io/issuer: {{ .Values.inf.tls.issuer }}
{{- end }}
{{- if .Values.inf.mesh.istio }}
{{- with .Values.ingress.mesh.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- end }}
spec:
hosts:
{{- range .Values.ingress.hosts }}
- {{ . }}
{{- end }}
gateways:
{{- range .Values.ingress.gateways }}
- {{ . }}
{{- end }}
http:
{{- range .Values.ingress.hosts }}
- route:
- destination:
host: {{ $serviceName }}
port:
number: 80
match:
- uri:
prefix: {{ $ingressPath }}/
- uri:
prefix: {{ $ingressPath }}
rewrite:
uri: /
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion deploy/k8s/helm/apigwws/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
labels:
app: {{ template "apigwws.name" . }}
release: {{ .Release.Name }}
{{ if .Values.inf.mesh.enabled -}}
{{ if .Values.inf.mesh.linkerd -}}
annotations:
linkerd.io/inject: enabled
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions deploy/k8s/helm/apigwws/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.ingress.enabled -}}
{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}}
{{- $ingressPath := include "pathBase" . -}}
{{- $serviceName := .Values.app.svc.webshoppingapigw -}}
apiVersion: networking.k8s.io/v1
Expand All @@ -17,7 +17,7 @@ metadata:
{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }}
cert-manager.io/issuer: {{ .Values.inf.tls.issuer }}
{{- end }}
{{- if .Values.inf.mesh.enabled }}
{{- if .Values.inf.mesh.linkerd }}
{{- with .Values.ingress.mesh.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
Expand Down
48 changes: 48 additions & 0 deletions deploy/k8s/helm/apigwws/templates/ingresss-istio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- if .Values.ingress.enabled -}}
{{- if .Values.inf.mesh.istio -}}
{{- $ingressPath := include "pathBase" . -}}
{{- $serviceName := .Values.app.svc.webshoppingapigw -}}
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: {{ template "apigwws.fullname" . }}
labels:
app: {{ template "apigwws.name" . }}
chart: {{ template "apigwws.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }}
annotations:
cert-manager.io/issuer: {{ .Values.inf.tls.issuer }}
{{- end }}
{{- if .Values.inf.mesh.istio }}
{{- with .Values.ingress.mesh.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- end }}
spec:
hosts:
{{- range .Values.ingress.hosts }}
- {{ . }}
{{- end }}
gateways:
{{- range .Values.ingress.gateways }}
- {{ . }}
{{- end }}
http:
{{- range .Values.ingress.hosts }}
- route:
- destination:
host: {{ $serviceName }}
port:
number: 80
match:
- uri:
prefix: {{ $ingressPath }}/
- uri:
prefix: {{ $ingressPath }}
rewrite:
uri: /
{{- end }}
{{- end }}
{{- end }}
3 changes: 2 additions & 1 deletion deploy/k8s/helm/basket-api/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ data:
urls__IdentityUrl: http://{{ .Values.app.svc.identity }}
all__EventBusConnection: {{ .Values.inf.eventbus.constr }}
all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}"
all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}"
all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}"
all__Redis: "{{ .Values.inf.redis.basket.constr }}"
2 changes: 1 addition & 1 deletion deploy/k8s/helm/basket-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
labels:
app: {{ template "basket-api.name" . }}
release: {{ .Release.Name }}
{{ if .Values.inf.mesh.enabled -}}
{{ if .Values.inf.mesh.linkerd -}}
annotations:
linkerd.io/inject: enabled
{{- end }}
Expand Down
6 changes: 4 additions & 2 deletions deploy/k8s/helm/basket-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ env:
configmap:
- name: ConnectionString
key: basket__ConnectionString
- name: EventBusConnection
- name: ConnectionStrings__EventBus
key: all__EventBusConnection
- name: ApplicationInsights__InstrumentationKey
key: all__InstrumentationKey
- name: AzureServiceBusEnabled
key: all__UseAzureServiceBus
- name: IdentityUrl
- name: Identity__Url
key: urls__IdentityUrl
- name: ConnectionStrings__Redis
key: all__Redis
# values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value)
values:
- name: OrchestratorType
Expand Down
2 changes: 1 addition & 1 deletion deploy/k8s/helm/catalog-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
labels:
app: {{ template "catalog-api.name" . }}
release: {{ .Release.Name }}
{{ if .Values.inf.mesh.enabled -}}
{{ if .Values.inf.mesh.linkerd -}}
annotations:
linkerd.io/inject: enabled
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions deploy/k8s/helm/catalog-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ env:
urls:
# configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap).
configmap:
- name: ConnectionString
- name: ConnectionStrings__CatalogDb
key: catalog__ConnectionString
- name: PicBaseUrl
key: catalog__PicBaseUrl
- name: AzureStorageEnabled
key: catalog__AzureStorageEnabled
- name: ApplicationInsights__InstrumentationKey
key: all__InstrumentationKey
- name: EventBusConnection
- name: ConnectionStrings__EventBus
key: all__EventBusConnection
- name: AzureServiceBusEnabled
key: all__UseAzureServiceBus
Expand Down
16 changes: 11 additions & 5 deletions deploy/k8s/helm/deploy-all-mac.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Param(
[parameter(Mandatory=$false)][string]$aksRg="",
[parameter(Mandatory=$false)][string]$imageTag="latest",
[parameter(Mandatory=$false)][bool]$useLocalk8s=$false,
[parameter(Mandatory=$false)][bool]$useMesh=$false,
[parameter(Mandatory=$false)][bool]$useIstio=$false,
[parameter(Mandatory=$false)][string]$istioGatewayName="istio-system/default-gateway",
[parameter(Mandatory=$false)][bool]$useLinkerd=$false,
[parameter(Mandatory=$false)][string][ValidateSet('Always','IfNotPresent','Never', IgnoreCase=$false)]$imagePullPolicy="Always",
[parameter(Mandatory=$false)][string][ValidateSet('prod','staging','none','custom', IgnoreCase=$false)]$sslSupport = "none",
[parameter(Mandatory=$false)][string]$tlsSecretName = "eshop-tls-custom",
Expand All @@ -23,7 +25,7 @@ function Install-Chart {
Param([string]$chart,[string]$initialOptions, [bool]$customRegistry)
$options=$initialOptions
if ($sslEnabled) {
$options = "$options --set ingress.tls[0].secretName=$tlsSecretName --set ingress.tls[0].hosts=`{$dns`}"
$options = "$options --set ingress.tls[0].secretName=$tlsSecretName --set ingress.tls[0].hosts=``{$dns``}"
if ($sslSupport -ne "custom") {
$options = "$options --set inf.tls.issuer=$sslIssuer"
}
Expand Down Expand Up @@ -90,6 +92,10 @@ if ([string]::IsNullOrEmpty($dns)) {
}
}

if ($useIstio -and $useLinkerd) {
Write-Host "You cannot enable both istio and linkerd." -ForegroundColor Red
exit 1
}
if ($useLocalk8s -and $sslEnabled) {
Write-Host "SSL can'be enabled on local K8s." -ForegroundColor Red
exit 1
Expand Down Expand Up @@ -126,7 +132,7 @@ $gateways = ("apigwms", "apigwws")
if ($deployInfrastructure) {
foreach ($infra in $infras) {
Write-Host "Installing infrastructure: $infra" -ForegroundColor Green
helm install "$appName-$infra" --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set "ingress.hosts={$dns}" $infra
helm install "$appName-$infra" --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set "ingress.hosts={$dns}" --set "ingress.gateways={$istioGatewayName}" $infra
}
}
else {
Expand All @@ -137,14 +143,14 @@ if ($deployCharts) {
foreach ($chart in $charts) {
if ($chartsToDeploy -eq "*" -or $chartsToDeploy.Contains($chart)) {
Write-Host "Installing: $chart" -ForegroundColor Green
Install-Chart $chart "--values app.yaml --values inf.yaml --values $ingressValuesFile --values $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set ingress.hosts=``{$dns``} --set image.tag=$imageTag --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$sslEnabled --set inf.mesh.enabled=$useMesh --set inf.k8s.local=$useLocalk8s" $useCustomRegistry
Install-Chart $chart "--values app.yaml --values inf.yaml --values $ingressValuesFile --values $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set ingress.hosts=``{$dns``} --set ingress.gateways=``{$istioGatewayName``} --set image.tag=$imageTag --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$sslEnabled --set inf.mesh.linkerd=$useLinkerd --set inf.k8s.local=$useLocalk8s --set inf.mesh.istio=$useIstio" $useCustomRegistry
}
}

foreach ($chart in $gateways) {
if ($chartsToDeploy -eq "*" -or $chartsToDeploy.Contains($chart)) {
Write-Host "Installing Api Gateway Chart: $chart" -ForegroundColor Green
Install-Chart $chart "--values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.mesh.enabled=$useMesh --set ingress.hosts=``{$dns``} --set inf.tls.enabled=$sslEnabled" $false
Install-Chart $chart "--values app.yaml --values inf.yaml --values $ingressValuesFile --values $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.mesh.linkerd=$useLinkerd --set ingress.hosts=``{$dns``} --set ingress.gateways=``{$istioGatewayName``} --set inf.tls.enabled=$sslEnabled --set inf.k8s.local=$useLocalk8s --set inf.mesh.istio=$useIstio" $false

}
}
Expand Down
15 changes: 10 additions & 5 deletions deploy/k8s/helm/deploy-all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Param(
[parameter(Mandatory=$false)][string]$aksRg="",
[parameter(Mandatory=$false)][string]$imageTag="latest",
[parameter(Mandatory=$false)][bool]$useLocalk8s=$false,
[parameter(Mandatory=$false)][bool]$useMesh=$false,
[parameter(Mandatory=$false)][bool]$useIstio=$false,
[parameter(Mandatory=$false)][string]$istioGatewayName="istio-system/default-gateway",
[parameter(Mandatory=$false)][bool]$useLinkerd=$false,
[parameter(Mandatory=$false)][string][ValidateSet('Always','IfNotPresent','Never', IgnoreCase=$false)]$imagePullPolicy="Always",
[parameter(Mandatory=$false)][string][ValidateSet('prod','staging','none','custom', IgnoreCase=$false)]$sslSupport = "none",
[parameter(Mandatory=$false)][string]$tlsSecretName = "eshop-tls-custom",
Expand Down Expand Up @@ -89,6 +91,10 @@ if ([string]::IsNullOrEmpty($dns)) {
}
}

if ($useIstio -and $useLinkerd) {
Write-Host "You cannot enable both istio and linkerd." -ForegroundColor Red
exit 1
}
if ($useLocalk8s -and $sslEnabled) {
Write-Host "SSL can'be enabled on local K8s." -ForegroundColor Red
exit 1
Expand Down Expand Up @@ -125,7 +131,7 @@ $gateways = ("apigwms", "apigwws")
if ($deployInfrastructure) {
foreach ($infra in $infras) {
Write-Host "Installing infrastructure: $infra" -ForegroundColor Green
helm install "$appName-$infra" --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set "ingress.hosts={$dns}" $infra
helm install "$appName-$infra" --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set "ingress.hosts={$dns}" --set "ingress.gateways={$istioGatewayName}" $infra
}
}
else {
Expand All @@ -136,15 +142,14 @@ if ($deployCharts) {
foreach ($chart in $charts) {
if ($chartsToDeploy -eq "*" -or $chartsToDeploy.Contains($chart)) {
Write-Host "Installing: $chart" -ForegroundColor Green
Install-Chart $chart "-f app.yaml --values inf.yaml -f $ingressValuesFile -f $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set ingress.hosts={$dns} --set image.tag=$imageTag --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$sslEnabled --set inf.mesh.enabled=$useMesh --set inf.k8s.local=$useLocalk8s" $useCustomRegistry
Install-Chart $chart "-f app.yaml --values inf.yaml -f $ingressValuesFile -f $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set ingress.hosts={$dns} --set ingress.gateways={$istioGatewayName} --set image.tag=$imageTag --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$sslEnabled --set inf.mesh.linkerd=$useLinkerd --set inf.k8s.local=$useLocalk8s --set inf.mesh.istio=$useIstio" $useCustomRegistry
}
}

foreach ($chart in $gateways) {
if ($chartsToDeploy -eq "*" -or $chartsToDeploy.Contains($chart)) {
Write-Host "Installing Api Gateway Chart: $chart" -ForegroundColor Green
Install-Chart $chart "-f app.yaml -f inf.yaml -f $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.mesh.enabled=$useMesh --set ingress.hosts={$dns} --set inf.tls.enabled=$sslEnabled" $false

Install-Chart $chart "-f app.yaml -f inf.yaml -f $ingressValuesFile -f $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.mesh.linkerd=$useLinkerd --set ingress.hosts={$dns} --set ingress.gateways={$istioGatewayName} --set inf.tls.enabled=$sslEnabled --set inf.k8s.local=$useLocalk8s --set inf.mesh.istio=$useIstio" $false
}
}
}
Expand Down
Loading