Skip to content

Commit

Permalink
add release templates for gateway api
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kalantar <[email protected]>
  • Loading branch information
kalantar committed Oct 31, 2023
1 parent a94a2ca commit d968247
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 2 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.2
version: 0.18.3
description: Iter8 controller controller
type: application
keywords:
Expand Down
4 changes: 4 additions & 0 deletions charts/controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ resourceTypes:
Group: networking.istio.io
Version: v1beta1
Resource: virtualservices
httproute:
Group: gateway.networking.k8s.io
Version: v1beta1
Resource: httproutes

### log level. Must be one of trace, debug, info, warning, error
logLevel: info
Expand Down
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.1
version: 0.18.2
description: Iter8 supported application release
type: application
keywords:
Expand Down
68 changes: 68 additions & 0 deletions charts/release/templates/_deployment-gtw.blue-green.routemap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{- define "env.deployment-gtw.blue-green.routemap" }}

{{- $APP_NAME := (include "application.name" .) }}
{{- $APP_NAMESPACE := (include "application.namespace" .) }}
{{- $versions := include "normalize.versions.deployment" . | mustFromJson }}
{{- $APP_PORT := pluck "port" (dict "port" 80) $.Values.application | first }}

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: httproute
template: |
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: {{ $APP_NAME }}
namespace: {{ $APP_NAMESPACE }}
spec:
hostnames:
- {{ $APP_NAME }}
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc.cluster.local
parentRefs:
- group: ""
kind: Service
name: {{ $APP_NAME }}
port: {{ $APP_PORT }}
{{- if .Values.gateway }}
- name: {{ .Values.gateway }}
{{- end }}
rules:
- backendRefs:
{{- range $i, $v := $versions }}
- group: ""
kind: Service
name: {{ template "svc.name" $v }}
port: {{ $v.port }}
{{- if gt (len $versions) 1 }}
{{ `{{- if gt (index .Weights 1) 0 }}` }}
weight: {{ `{{ index .Weights ` }}{{ print $i }}{{ ` }}` }}
{{ `{{- end }}` }}
{{- end }}
filters:
- type: ResponseHeaderModifier
responseHeaderModifier:
add:
- name: app-version
value: {{ template "svc.name" $v }}
{{- end }} {{- /* range $i, $v := $versions */}}
{{- end }} {{- /* define "env.deployment-gtw.blue-green.routemap" */}}
15 changes: 15 additions & 0 deletions charts/release/templates/_deployment-gtw.blue-green.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- define "env.deployment-gtw.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-gtw.blue-green.routemap" . }}

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

{{- $APP_NAME := (include "application.name" .) }}
{{- $APP_NAMESPACE := (include "application.namespace" .) }}
{{- $versions := include "normalize.versions.deployment" . | mustFromJson }}
{{- $APP_PORT := pluck "port" (dict "port" 80) $.Values.application | first }}

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 }} {{- /* range $i, $v := $versions */}}
routingTemplates:
{{ .Values.application.strategy }}:
gvrShort: httproute
template: |
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: {{ $APP_NAME }}
namespace: {{ $APP_NAMESPACE }}
spec:
hostnames:
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc.cluster.local
parentRefs:
- group: ""
kind: Service
name: {{ $APP_NAME }}
port: {{ $APP_PORT }}
{{- if .Values.gateway }}
- name: {{ .Values.gateway }}
{{- end }}
rules:
# non-primary versions
{{- range $i, $v := (rest $versions) }}
- matches:
{{- toYaml $v.matches | nindent 14 }}
backendRefs:
- group: ""
kind: Service
name: {{ template "svc.name" $v }}
port: {{ $v.port }}
filters:
- type: ResponseHeaderModifier
responseHeaderModifier:
add:
- name: app-version
value: {{ template "svc.name" $v }}
{{- end }} {{- /* range $i, $v := (rest $versions) */}}
# primary version (default)
{{- $v := (index $versions 0) }}
- backendRefs:
- group: ""
kind: Service
name: {{ template "svc.name" $v }}
port: {{ $v.port }}
filters:
- type: ResponseHeaderModifier
responseHeaderModifier:
add:
- name: app-version
value: {{ template "svc.name" $v }}
{{- end }} {{- /* define "env.deployment-gtw.canary.routemap" */}}
6 changes: 6 additions & 0 deletions charts/release/templates/_deployment-gtw.canary.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{- define "env.deployment-gtw.canary" }}

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

{{- end }} {{- /* define "env.deployment-gtw.canary" */}}
21 changes: 21 additions & 0 deletions charts/release/templates/_deployment-gtw.none.routemap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- define "env.deployment-gtw.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-gtw.none.routemap" */}}
6 changes: 6 additions & 0 deletions charts/release/templates/_deployment-gtw.none.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{- define "env.deployment-gtw.none" }}

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

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

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

apiVersion: v1
kind: Service
metadata:
name: {{ $APP_NAME }}
namespace: {{ $APP_NAMESPACE }}
spec:
selector:
app: {{ $APP_NAME }}
ports:
- port: 80
{{- end }} {{- /* define "env.deployment-gtw.service" */}}
30 changes: 30 additions & 0 deletions charts/release/templates/_deployment-gtw.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- define "env.deployment-gtw" }}

{{- /* 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-gtw.service" . }}
---

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

{{- end }} {{- /* define "env.deployment-gtw" */}}
2 changes: 2 additions & 0 deletions charts/release/templates/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
{{- /* Different processing based on .Values.environment */}}
{{- if eq "deployment" .Values.environment }}
{{- include "env.deployment" . }}
{{- else if eq "deployment-gtw" .Values.environment }}
{{- include "env.deployment-gtw" . }}
{{- else if eq "deployment-istio" .Values.environment }}
{{- include "env.deployment-istio" . }}
{{- else if eq "kserve-modelmesh-istio" .Values.environment }}
Expand Down

0 comments on commit d968247

Please sign in to comment.