Skip to content

Commit

Permalink
release chart (#1646)
Browse files Browse the repository at this point in the history
* release chart

Signed-off-by: Michael Kalantar <[email protected]>

* update chart version

Signed-off-by: Michael Kalantar <[email protected]>

* update release chart

Signed-off-by: Michael Kalantar <[email protected]>

* helper for metadata

Signed-off-by: Michael Kalantar <[email protected]>

* kserve canary routemap template

Signed-off-by: Michael Kalantar <[email protected]>

* update release templates

Signed-off-by: Michael Kalantar <[email protected]>

* canary for deployment-istio

Signed-off-by: Michael Kalantar <[email protected]>

* add comment

Signed-off-by: Michael Kalantar <[email protected]>

* remove commented out code

Signed-off-by: Michael Kalantar <[email protected]>

---------

Signed-off-by: Michael Kalantar <[email protected]>
  • Loading branch information
kalantar authored Oct 19, 2023
1 parent bf13530 commit 1dc8ffe
Show file tree
Hide file tree
Showing 41 changed files with 1,571 additions and 807 deletions.
2 changes: 1 addition & 1 deletion charts/controller/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: controller
version: 0.18.1
version: 0.18.2
description: Iter8 controller controller
type: application
keywords:
Expand Down
2 changes: 1 addition & 1 deletion charts/controller/templates/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rules:
{{- end }}
- apiGroups: ["{{- $type.Group -}}"]
resources: ["{{- $type.Resource -}}"]
verbs: ["get", "list", "watch", "patch", "update"]
verbs: ["get", "list", "watch", "patch", "update", "create"]
{{- end }}
- apiGroups: [""]
resources: ["events"]
Expand Down
26 changes: 26 additions & 0 deletions charts/release/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

# generated files need to be ignored
experiment.yaml
21 changes: 21 additions & 0 deletions charts/release/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: release
version: 0.18.1
description: Iter8 supported application release
type: application
keywords:
- Iter8
- traffic
- blue-green
- canary
- mirroring
home: https://iter8.tools
sources:
- https://github.com/iter8-tools/iter8
maintainers:
- name: Michael Kalantar
email: [email protected]
- name: Iter8
email: [email protected]
icon: https://github.com/iter8-tools/iter8/raw/master/mkdocs/docs/images/favicon.png
appVersion: v0.18
12 changes: 12 additions & 0 deletions charts/release/templates/_configmap.weight-config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- define "configmap.weight-config" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .VERSION_NAME }}-weight-config
labels:
iter8.tools/watch: "true"
{{- if .weight }}
annotations:
iter8.tools/weight: "{{ .weight }}"
{{- end }} {{- /* if .weight */}}
{{- end }} {{- /* define "configmap.weight-config" */}}
77 changes: 77 additions & 0 deletions charts/release/templates/_deployment-istio.blue-green.routemap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{{- define "env.deployment-istio.blue-green.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 }}` }}
- destination:
host: {{ template "svc.name" $v }}.{{ $APP_NAMESPACE }}.svc.cluster.local
port:
number: {{ $v.port }}
weight: {{ `{{ index .Weights ` }}{{ print (add1 $i) }}{{ ` }}` }}
headers:
response:
add:
app-version: {{ template "svc.name" $v }}
{{ `{{- end }}` }}
{{- end }}
{{- end }} {{- /* define "env.deployment-istio.blue-green.routemap" */}}
15 changes: 15 additions & 0 deletions charts/release/templates/_deployment-istio.blue-green.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- define "env.deployment-istio.blue-green" }}

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

{{- /* weight-config ConfigMaps */}}
{{- range $i, $v := $versions }}
{{ include "configmap.weight-config" $v }}
---
{{- end }} {{- /* range $i, $v := $versions */}}

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

{{- end }} {{- /* define "env.deployment-istio.blue-green" */}}
84 changes: 84 additions & 0 deletions charts/release/templates/_deployment-istio.canary.routemap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{{- define "env.deployment-istio.canary.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 }}
{{- end }}
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:
# non-primary versions
{{- range $i, $v := (rest $versions) }}
{{- /* continue only if candidate is ready (weight > 0) */}}
{{ `{{- if gt (index .Weights ` }}{{ print (add1 $i) }}{{ `) 0 }}` }}
- name: {{ template "svc.name" $v }}
match:
{{- /* A match may have several ORed clauses */}}
{{- range $j, $m := $v.match }}
{{- /* include any other header requirements */}}
{{- if (hasKey $m "headers") }}
- headers:
{{ toYaml (pick $m "headers").headers | indent 18 }}
{{- end }} {{- /* if (hasKey $m "headers") */}}
{{- /* include any other (non-header) requirements */}}
{{- if gt (omit $m "headers" | keys | len) 0 }}
{{ toYaml (omit $m "headers") | indent 16 }}
{{- end }} {{- /* if gt (omit $m "headers" | keys | len) 0 */}}
{{- end }} {{- /* range $j, $m := $v.match */}}
route:
- destination:
host: {{ template "svc.name" $v }}.{{ $APP_NAMESPACE }}.svc.cluster.local
port:
number: {{ $v.port }}
headers:
response:
add:
app-version: {{ template "svc.name" $v }}
{{ `{{- end }}` }}
{{- end }} {{- /* range $i, $v := (rest $versions) */}}
# primary version (default)
{{- $v := (index $versions 0) }}
- name: {{ template "svc.name" $v }}
route:
- destination:
host: {{ template "svc.name" $v }}.{{ $APP_NAMESPACE }}.svc.cluster.local
port:
number: {{ $v.port }}
headers:
response:
add:
app-version: {{ template "svc.name" $v }}

{{- end }} {{- /* define "env.deployment-istio.canary.routemap" */}}
6 changes: 6 additions & 0 deletions charts/release/templates/_deployment-istio.canary.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{- define "env.deployment-istio.canary" }}

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

{{- end }} {{- /* define "env.deployment-istio.canary" */}}
21 changes: 21 additions & 0 deletions charts/release/templates/_deployment-istio.none.routemap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- define "env.deployment-istio.none.routemap" }}

{{- $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 }}
{{- end }}

{{- end }} {{- /* define "env.deployment-istio.none.routemap" */}}
6 changes: 6 additions & 0 deletions charts/release/templates/_deployment-istio.none.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{- define "env.deployment-istio.none" }}

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

{{- end }} {{- /* define "env.deployment-istio.none" */}}
15 changes: 15 additions & 0 deletions charts/release/templates/_deployment-istio.service.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- define "env.deployment-istio.service" }}

{{- $APP_NAME := (include "application.name" .) }}
{{- $APP_NAMESPACE := (include "application.namespace" .) }}

apiVersion: v1
kind: Service
metadata:
name: {{ $APP_NAME }}
namespace: {{ $APP_NAMESPACE }}
spec:
externalName: istio-ingressgateway.istio-system.svc.cluster.local
sessionAffinity: None
type: ExternalName
{{- end }} {{- /* define "env.deployment-istio.service" */}}
30 changes: 30 additions & 0 deletions charts/release/templates/_deployment-istio.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- define "env.deployment-istio" }}

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

{{- range $i, $v := $versions }}
{{- /* Deployment */}}
{{ include "env.deployment.version.deployment" $v }}
---
{{- /* Service */}}
{{ include "env.deployment.version.service" $v }}
---
{{- end }} {{- /* range $i, $v := $versions */}}

{{- /* Service */}}
{{ include "env.deployment-istio.service" . }}
---

{{- /* routemap (and other strategy specific objects) */}}
{{- if not .Values.application.strategy }}
{{ include "env.deployment-istio.none" . }}
{{- else if eq "none" .Values.application.strategy }}
{{ include "env.deployment-istio.none" . }}
{{- else if eq "blue-green" .Values.application.strategy }}
{{ include "env.deployment-istio.blue-green" . }}
{{- else if eq "canary" .Values.application.strategy }}
{{ include "env.deployment-istio.canary" . }}
{{- end }} {{- /* if eq ... .Values.application.strategy */}}

{{- end }} {{- /* define "env.deployment-istio" */}}
25 changes: 25 additions & 0 deletions charts/release/templates/_deployment.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- define "env.deployment" }}

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

{{- range $i, $v := $versions }}

{{- /* Deployment */}}
{{ include "env.deployment.version.deployment" $v }}
---
{{- /* Service */}}
{{ include "env.deployment.version.service" $v }}
---
{{- end }} {{- /* range $i, $v := $versions */}}

{{- /* routemap (and other strategy specific objects) */}}
{{- if not .Values.application.strategy }}
{{ include "env.deployment-istio.none" . }}
{{- else if eq "none" .Values.application.strategy }}
{{ include "env.deployment-istio.none" . }}
{{- else }}
{{- printf "unknown or invalid application strategy (%s) for environment (%s)" .Values.application.strategy .Values.environment | fail }}
{{- end }} {{- /* if eq ... .Values.application.strategy */}}

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

0 comments on commit 1dc8ffe

Please sign in to comment.