From 89f506e85cfaab1632c72abf4a84de191c00cbe3 Mon Sep 17 00:00:00 2001 From: Dishant Pandya Date: Mon, 13 Oct 2025 20:58:11 +0530 Subject: [PATCH 1/2] Create virtualservice.yaml --- templates/virtualservice.yaml | 114 ++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 templates/virtualservice.yaml diff --git a/templates/virtualservice.yaml b/templates/virtualservice.yaml new file mode 100644 index 0000000..d6eb3e8 --- /dev/null +++ b/templates/virtualservice.yaml @@ -0,0 +1,114 @@ +{{- if not $.Values.virtualService.disabled }} # +apiVersion: networking.istio.io/v1beta1 +kind: VirtualService +metadata: + {{- if $.Values.virtualService.name }} + name: {{ $.Values.virtualService.name | quote }} + {{- else if and $.Values.service (hasKey $.Values.service "name") $.Values.service.name }} + name: {{ $.Values.service.name | quote }} + {{- else }} + name: {{ $.Release.Name | quote }} + {{- end }} + labels: + "app.kubernetes.io/name": {{ $.Release.Name | quote }} + "app.kubernetes.io/managed-by": {{ $.Release.Service | quote }} + {{- range $labelName, $labelValue := $.Values.virtualService.labels }} + {{ $labelName | quote }}: {{ $labelValue | quote }} + {{- end }} + annotations: + "helm.sh/chart": "{{ $.Chart.Name }}-{{ $.Chart.Version }}" + {{- range $annotationName, $annotationValue := $.Values.virtualService.annotations }} + {{ $annotationName | quote }}: {{ $annotationValue | quote }} + {{- end }} + +spec: + {{- if $.Values.virtualService.gateways }} + gateways: + {{- range $.Values.virtualService.gateways }} + - {{ . | quote }} + {{- end }} + {{- else }} + gateways: + - "mesh" + {{- end }} + + hosts: + {{- if $.Values.virtualService.hosts }} + {{- range $.Values.virtualService.hosts }} + - {{ . | quote }} + {{- end }} + {{- else }} + - {{ printf "%s.%s.svc.cluster.local" ($.Values.service.name | default $.Release.Name) $.Release.Namespace | quote }} + {{- end }} + + http: + {{- range $ruleIndex, $vsRule := $.Values.virtualService.rules }} + - name: {{ (printf "%s-%d" $.Release.Name $ruleIndex) | quote }} + + {{- if $vsRule.match }} + match: + {{- range $match := $vsRule.match }} + - uri: + {{- if $match.exact }} + exact: {{ $match.exact | quote }} + {{- else if $match.prefix }} + prefix: {{ $match.prefix | quote }} + {{- else if $match.regex }} + regex: {{ $match.regex | quote }} + {{- else }} + prefix: "/" + {{- end }} + {{- end }} + {{- else }} + match: + - uri: + prefix: "/" + {{- end }} + + {{- if $vsRule.rewrite }} + rewrite: + {{- if $vsRule.rewrite.uri }} + uri: {{ $vsRule.rewrite.uri | quote }} + {{- end }} + {{- if $vsRule.rewrite.authority }} + authority: {{ $vsRule.rewrite.authority | quote }} + {{- end }} + {{- end }} + + route: + {{- if $.Values.service.ports }} + {{- range $portMapIndex, $portMap := $.Values.service.ports }} + - destination: + host: {{ $.Values.service.name | default $.Release.Name | quote }} + port: + number: {{ $portMap.port }} + {{- if $vsRule.weight }} + weight: {{ $vsRule.weight }} + {{- end }} + {{- end }} + {{- else }} + - destination: + host: {{ $.Values.service.name | default $.Release.Name | quote }} + port: + number: {{ $vsRule.servicePort | default 80 }} + {{- end }} + + {{- if $vsRule.retries }} + retries: + attempts: {{ $vsRule.retries.attempts | default 3 }} + perTryTimeout: {{ $vsRule.retries.perTryTimeout | default "2s" | quote }} + retryOn: {{ $vsRule.retries.retryOn | default "5xx" | quote }} + {{- end }} + + {{- if $vsRule.timeout }} + timeout: {{ $vsRule.timeout | quote }} + {{- end }} + + {{- if $vsRule.corsPolicy }} + corsPolicy: +{{ toYaml $vsRule.corsPolicy | indent 6 }} + {{- end }} + + {{- end }} + +{{- end }} From e7b610f8cf28cfea2e0a99d7b1a0cedd6bb8cba0 Mon Sep 17 00:00:00 2001 From: Dishant Pandya Date: Tue, 6 Jan 2026 16:01:42 +0530 Subject: [PATCH 2/2] Add virtualService configuration to values.yaml --- values.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/values.yaml b/values.yaml index 3280c2c..5b1a23b 100644 --- a/values.yaml +++ b/values.yaml @@ -31,3 +31,38 @@ volumes: [] # DevSpace CLI will append all pull secrets which are automatically created # More infos on: https://devspace.cloud/docs/cli/image-building/workflow-basics#8-create-image-pull-secret pullSecrets: [] + +virtualService: + disabled: true + +# disabled: false +# name: "my-app-vs" +# gateways: +# - "my-gateway" +# labels: +# environment: "prod" +# annotations: +# owner: "team-x" +# rules: +# - host: "app.example.com" +# serviceName: "my-app" +# servicePort: 8080 +# match: +# - prefix: "/" +# retries: +# attempts: 3 +# perTryTimeout: 2s +# retryOn: "5xx" +# timeout: 10s +# corsPolicy: +# allowOrigins: +# - exact: "https://example.com" +# allowMethods: +# - GET +# - POST +# allowCredentials: true +# - host: "api.example.com" +# serviceName: "my-api" +# servicePort: 8081 +# match: +# - prefix: "/api"