Skip to content

Commit f3f9a8e

Browse files
authored
mirrored release for deployments (#1657)
* mirrored release for deployments Signed-off-by: Michael Kalantar <[email protected]> * bump chart version Signed-off-by: Michael Kalantar <[email protected]> --------- Signed-off-by: Michael Kalantar <[email protected]>
1 parent 545d583 commit f3f9a8e

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

charts/release/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: release
3-
version: 0.18.4
3+
version: 0.18.5
44
description: Iter8 supported application release
55
type: application
66
keywords:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{{- define "env.deployment-istio.mirror.routemap" }}
2+
3+
{{- $APP_NAME := (include "application.name" .) }}
4+
{{- $APP_NAMESPACE := (include "application.namespace" .) }}
5+
{{- $versions := include "normalize.versions.deployment" . | mustFromJson }}
6+
7+
apiVersion: v1
8+
kind: ConfigMap
9+
{{- template "routemap.metadata" . }}
10+
data:
11+
strSpec: |
12+
versions:
13+
{{- range $i, $v := $versions }}
14+
- resources:
15+
- gvrShort: svc
16+
name: {{ template "svc.name" $v }}
17+
namespace: {{ template "svc.namespace" $v }}
18+
- gvrShort: deploy
19+
name: {{ template "deploy.name" $v }}
20+
namespace: {{ template "deploy.namespace" $v }}
21+
- gvrShort: cm
22+
name: {{ $v.VERSION_NAME }}-weight-config
23+
namespace: {{ $v.VERSION_NAMESPACE }}
24+
weight: {{ $v.weight }}
25+
{{- end }} {{- /* range $i, $v := $versions */}}
26+
routingTemplates:
27+
{{ .Values.application.strategy }}:
28+
gvrShort: vs
29+
template: |
30+
apiVersion: networking.istio.io/v1beta1
31+
kind: VirtualService
32+
metadata:
33+
name: {{ $APP_NAME }}
34+
namespace: {{ $APP_NAMESPACE }}
35+
spec:
36+
gateways:
37+
{{- if .Values.gateway }}
38+
- {{ .Values.gateway }}
39+
{{- end }}
40+
- mesh
41+
hosts:
42+
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}
43+
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc
44+
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc.cluster.local
45+
http:
46+
- name: {{ $APP_NAME }}
47+
route:
48+
# primary version
49+
{{- $v := (index $versions 0) }}
50+
- destination:
51+
host: {{ template "svc.name" $v }}.{{ $APP_NAMESPACE }}.svc.cluster.local
52+
port:
53+
number: {{ $v.port }}
54+
{{- if gt (len $versions) 1 }}
55+
{{ `{{- if gt (index .Weights 1) 0 }}` }}
56+
weight: {{ `{{ index .Weights 0 }}` }}
57+
{{ `{{- end }}` }}
58+
{{- end }}
59+
headers:
60+
response:
61+
add:
62+
app-version: {{ template "svc.name" $v }}
63+
# other versions
64+
{{- range $i, $v := (rest $versions) }}
65+
{{ `{{- if gt (index .Weights ` }}{{ print (add1 $i) }}{{ `) 0 }}` }}
66+
mirror:
67+
host: {{ template "svc.name" $v }}.{{ $APP_NAMESPACE }}.svc.cluster.local
68+
port:
69+
number: {{ $v.port }}
70+
mirrorPercentage:
71+
value: {{ `{{ index .Weights ` }}{{ print (add1 $i) }}{{ ` }}` }}
72+
{{ `{{- end }}` }}
73+
{{- end }}
74+
{{- end }} {{- /* define "env.deployment-istio.mirror.routemap" */}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- define "env.deployment-istio.mirror" }}
2+
3+
{{- /* prepare versions for simpler processing */}}
4+
{{- $versions := include "normalize.versions.deployment" . | mustFromJson }}
5+
6+
{{- /* weight-config ConfigMaps except for primary */}}
7+
{{- range $i, $v := (rest $versions) }}
8+
{{ include "configmap.weight-config" $v }}
9+
---
10+
{{- end }} {{- /* range $i, $v := $versions */}}
11+
12+
{{- /* routemap */}}
13+
{{ include "env.deployment-istio.mirror.routemap" . }}
14+
15+
{{- end }} {{- /* define "env.deployment-istio.mirror" */}}

charts/release/templates/_deployment-istio.tpl

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
{{ include "env.deployment-istio.blue-green" . }}
2626
{{- else if eq "canary" .Values.application.strategy }}
2727
{{ include "env.deployment-istio.canary" . }}
28+
{{- else if eq "mirror" .Values.application.strategy }}
29+
{{ include "env.deployment-istio.mirror" . }}
2830
{{- end }} {{- /* if eq ... .Values.application.strategy */}}
2931

3032
{{- end }} {{- /* define "env.deployment-istio" */}}

0 commit comments

Comments
 (0)