Home > Blockchain >  Failing to set range loop of helm in Istio virtual Service HTTP Retry
Failing to set range loop of helm in Istio virtual Service HTTP Retry

Time:09-21

Bug Description

I can smoothly work on adding multiple destinations for canary deployment but when I try adding retry it fails with the custom-built Helm chart. As I can't iterate over it.

This is a problem because Retry is tied to each destination according to that whole should be iterated.

Please find helm chart template below.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: {{ .Values.virtualservice.name }}
  namespace: {{ .Values.namespace }} 
spec:
  hosts:
  - {{ .Values.virtualservice.hosts }} 
  gateways:
  - {{ .Values.virtualservice.gateways }} 
  http:
  - route:
      {{- range $key, $value := .Values.destination }}
    - destination:
        host: {{ $value.host }}
        subset: {{ $value.subset }} 
      weight: {{ $value.weight }}
    retries:
      attempts: {{ $value.retries.attempts }}
      perTryTimeout: {{ $value.retries.perTryTimeout }}
      retryOn: {{ $value.retries.retryOn }}
    timeout: {{ $value.retries.timeout }}
    {{- end }}

Error log

$ helm install asm-helm ./asm-svc-helm-chart -f values.yaml --dry-run
Error: INSTALLATION FAILED: YAML parse error on asmvrtsvc/templates/retry-svc.yaml: error converting YAML to JSON: yaml: line 21: did not find expected key

Version

$ kubectl version --short
Client Version: v1.24.0
Kustomize Version: v4.5.4
Server Version: v1.22.12-gke.300

$ helm version
v3.9.4 gdbc6d8e

Added example for reference

spec:
  hosts:
  - reviews
  http:
  - route:
    - destination:
        host: reviews
        subset: v1
      weight: 75
    retries:
      attempts: 3
      perTryTimeout: 2s
    - destination:
        host: reviews
        subset: v2
      weight: 25
    retries:
      attempts: 3
      perTryTimeout: 2s

CodePudding user response:

According to the schema of Virtual Service, The route field in Virtual Service can have one retries field.

So, the loop should include destination as array.

*: https://istio.io/latest/docs/reference/config/networking/virtual-service/

  • Related