Skip to content

Commit

Permalink
mirrored release for deployments (#1657)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
kalantar authored Dec 13, 2023
1 parent 545d583 commit f3f9a8e
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/release/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: release
version: 0.18.4
version: 0.18.5
description: Iter8 supported application release
type: application
keywords:
Expand Down
74 changes: 74 additions & 0 deletions charts/release/templates/_deployment-istio.mirror.routemap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{{- define "env.deployment-istio.mirror.routemap" }}

{{- $APP_NAME := (include "application.name" .) }}
{{- $APP_NAMESPACE := (include "application.namespace" .) }}
{{- $versions := include "normalize.versions.deployment" . | mustFromJson }}

apiVersion: v1
kind: ConfigMap
{{- template "routemap.metadata" . }}
data:
strSpec: |
versions:
{{- range $i, $v := $versions }}
- resources:
- gvrShort: svc
name: {{ template "svc.name" $v }}
namespace: {{ template "svc.namespace" $v }}
- gvrShort: deploy
name: {{ template "deploy.name" $v }}
namespace: {{ template "deploy.namespace" $v }}
- gvrShort: cm
name: {{ $v.VERSION_NAME }}-weight-config
namespace: {{ $v.VERSION_NAMESPACE }}
weight: {{ $v.weight }}
{{- end }} {{- /* range $i, $v := $versions */}}
routingTemplates:
{{ .Values.application.strategy }}:
gvrShort: vs
template: |
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: {{ $APP_NAME }}
namespace: {{ $APP_NAMESPACE }}
spec:
gateways:
{{- if .Values.gateway }}
- {{ .Values.gateway }}
{{- end }}
- mesh
hosts:
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc.cluster.local
http:
- name: {{ $APP_NAME }}
route:
# primary version
{{- $v := (index $versions 0) }}
- destination:
host: {{ template "svc.name" $v }}.{{ $APP_NAMESPACE }}.svc.cluster.local
port:
number: {{ $v.port }}
{{- if gt (len $versions) 1 }}
{{ `{{- if gt (index .Weights 1) 0 }}` }}
weight: {{ `{{ index .Weights 0 }}` }}
{{ `{{- end }}` }}
{{- end }}
headers:
response:
add:
app-version: {{ template "svc.name" $v }}
# other versions
{{- range $i, $v := (rest $versions) }}
{{ `{{- if gt (index .Weights ` }}{{ print (add1 $i) }}{{ `) 0 }}` }}
mirror:
host: {{ template "svc.name" $v }}.{{ $APP_NAMESPACE }}.svc.cluster.local
port:
number: {{ $v.port }}
mirrorPercentage:
value: {{ `{{ index .Weights ` }}{{ print (add1 $i) }}{{ ` }}` }}
{{ `{{- end }}` }}
{{- end }}
{{- end }} {{- /* define "env.deployment-istio.mirror.routemap" */}}
15 changes: 15 additions & 0 deletions charts/release/templates/_deployment-istio.mirror.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- define "env.deployment-istio.mirror" }}

{{- /* prepare versions for simpler processing */}}
{{- $versions := include "normalize.versions.deployment" . | mustFromJson }}

{{- /* weight-config ConfigMaps except for primary */}}
{{- range $i, $v := (rest $versions) }}
{{ include "configmap.weight-config" $v }}
---
{{- end }} {{- /* range $i, $v := $versions */}}

{{- /* routemap */}}
{{ include "env.deployment-istio.mirror.routemap" . }}

{{- end }} {{- /* define "env.deployment-istio.mirror" */}}
2 changes: 2 additions & 0 deletions charts/release/templates/_deployment-istio.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
{{ include "env.deployment-istio.blue-green" . }}
{{- else if eq "canary" .Values.application.strategy }}
{{ include "env.deployment-istio.canary" . }}
{{- else if eq "mirror" .Values.application.strategy }}
{{ include "env.deployment-istio.mirror" . }}
{{- end }} {{- /* if eq ... .Values.application.strategy */}}

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

0 comments on commit f3f9a8e

Please sign in to comment.