diff --git a/src/templates/virtual_services-ingress.ctmpl b/src/templates/virtual_services-ingress.ctmpl index 3970f24..40a3d3e 100644 --- a/src/templates/virtual_services-ingress.ctmpl +++ b/src/templates/virtual_services-ingress.ctmpl @@ -17,151 +17,128 @@ metadata: name: {{ $applicationName }}-ingress spec: gateways: - - default-gateway + - default-gateway hosts: - - {{ $publicDomain }} - - "*.{{ $publicDomain }}" + - {{ $publicDomain }} + - "*.{{ $publicDomain }}" http: {{- range $variants := $variants }} {{- $variant := .Key -}} {{- if and (ne $variant "master") (not (keyExists (print $configPath "/" $namespace "/versions/" $variant))) }} {{- if eq $contextRoute "" }} - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - x-variant-id: {{ $variant }} - match: - - - authority: - regex: ({{ $variant }}|{{ $variant |toLower }}).{{ $publicDomain }} - route: - - - destination: - host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local - subset: {{ $variant }} - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - headers: - x-variant-id: - regex: ({{ $variant }}|{{ $variant |toLower }}) - route: - - - destination: - host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local - subset: {{ $variant }} + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + x-variant-id: {{ $variant }} + match: + - authority: + regex: ({{ $variant }}|{{ $variant |toLower }}).{{ $publicDomain }} + route: + - destination: + host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local + subset: {{ $variant }} + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - headers: + x-variant-id: + regex: ({{ $variant }}|{{ $variant |toLower }}) + route: + - destination: + host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local + subset: {{ $variant }} {{- else }} - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - x-variant-id: {{ $variant }} - match: - - - authority: - regex: ({{ $variant }}|{{ $variant |toLower }}).{{ $publicDomain }} - uri: - regex: ^{{ $contextRoute }}(/.*)?$ - {{- if $secondaryRoutes }} - {{- range ($secondaryRoutes | split ",") }} - - - authority: - regex: ({{ $variant }}|{{ $variant |toLower }}).{{ $publicDomain }} - uri: - regex: ^{{ . }}(/.*)?$ - {{- end }} - {{- end }} - route: - - - destination: - host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local - subset: {{ $variant }} - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^{{ $contextRoute }}(/.*)?$ - headers: - x-variant-id: - regex: ({{ $variant }}|{{ $variant | toLower }}) - {{- if $secondaryRoutes }} - {{- range ($secondaryRoutes | split ",") }} - - - uri: - regex: ^{{ . }}(/.*)?$ - headers: - x-variant-id: - regex: ({{ $variant }}|{{ $variant | toLower }}) - {{- end }} - {{- end }} - route: - - - destination: - host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local - subset: {{ $variant }} + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + x-variant-id: {{ $variant }} + match: + - authority: + regex: ({{ $variant }}|{{ $variant |toLower }}).{{ $publicDomain }} + uri: + regex: ^{{ $contextRoute }}(/.*)?$ + {{- if $secondaryRoutes }} + {{- range ($secondaryRoutes | split ",") }} + - authority: + regex: ({{ $variant }}|{{ $variant |toLower }}).{{ $publicDomain }} + uri: + regex: ^{{ . }}(/.*)?$ + {{- end }} + {{- end }} + route: + - destination: + host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local + subset: {{ $variant }} + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^{{ $contextRoute }}(/.*)?$ + headers: + x-variant-id: + regex: ({{ $variant }}|{{ $variant | toLower }}) + {{- if $secondaryRoutes }} + {{- range ($secondaryRoutes | split ",") }} + - uri: + regex: ^{{ . }}(/.*)?$ + headers: + x-variant-id: + regex: ({{ $variant }}|{{ $variant | toLower }}) + {{- end }} + {{- end }} + route: + - destination: + host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local + subset: {{ $variant }} {{- end }} {{- end }} {{- end }} {{- range tree (print $configPath "/" $namespace "/versions/") }} - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^{{ $contextRoute }}/{{ .Key }}(/.*)?$ - route: - - - destination: - host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local - subset: {{ .Key }} + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^{{ $contextRoute }}/{{ .Key }}(/.*)?$ + route: + - destination: + host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local + subset: {{ .Key }} {{- end }} {{- if eq $contextRoute "" }} - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - route: - - - destination: - host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local - subset: master + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + route: + - destination: + host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local + subset: master {{- else }} - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^{{ $contextRoute }}(/.*)?$ - {{- if $secondaryRoutes }} - {{- range ($secondaryRoutes | split ",") }} - - - uri: - regex: ^{{ . }}(/.*)?$ - {{- end }} - {{- end }} - route: - - - destination: - host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local - subset: master + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^{{ $contextRoute }}(/.*)?$ + {{- if $secondaryRoutes }} + {{- range ($secondaryRoutes | split ",") }} + - uri: + regex: ^{{ . }}(/.*)?$ + {{- end }} + {{- end }} + route: + - destination: + host: {{ $applicationName }}.{{ $namespace }}.svc.cluster.local + subset: master {{- end }} {{ end }} {{- end -}} diff --git a/test/expected_outputs/green-proof02/virtual_services-ingress.rendered b/test/expected_outputs/green-proof02/virtual_services-ingress.rendered index a7dd2c4..f54f253 100644 --- a/test/expected_outputs/green-proof02/virtual_services-ingress.rendered +++ b/test/expected_outputs/green-proof02/virtual_services-ingress.rendered @@ -5,25 +5,22 @@ metadata: name: docx-generator-ingress spec: gateways: - - default-gateway + - default-gateway hosts: - - apps.green.wealthwizards.io - - "*.apps.green.wealthwizards.io" + - apps.green.wealthwizards.io + - "*.apps.green.wealthwizards.io" http: - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^/docx-generator(/.*)?$ - route: - - - destination: - host: docx-generator.green.svc.cluster.local - subset: master + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^/docx-generator(/.*)?$ + route: + - destination: + host: docx-generator.green.svc.cluster.local + subset: master --- apiVersion: networking.istio.io/v1alpha3 kind: VirtualService @@ -31,48 +28,40 @@ metadata: name: income-tax-service-ingress spec: gateways: - - default-gateway + - default-gateway hosts: - - income-tax-service.st.wealthwizards.io - - "*.income-tax-service.st.wealthwizards.io" + - income-tax-service.st.wealthwizards.io + - "*.income-tax-service.st.wealthwizards.io" http: - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - x-variant-id: OPS-3353 - match: - - - authority: - regex: (OPS-3353|ops-3353).income-tax-service.st.wealthwizards.io - route: - - - destination: - host: income-tax-service.green.svc.cluster.local - subset: OPS-3353 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - headers: - x-variant-id: - regex: (OPS-3353|ops-3353) - route: - - - destination: - host: income-tax-service.green.svc.cluster.local - subset: OPS-3353 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - route: - - - destination: - host: income-tax-service.green.svc.cluster.local - subset: master + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + x-variant-id: OPS-3353 + match: + - authority: + regex: (OPS-3353|ops-3353).income-tax-service.st.wealthwizards.io + route: + - destination: + host: income-tax-service.green.svc.cluster.local + subset: OPS-3353 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - headers: + x-variant-id: + regex: (OPS-3353|ops-3353) + route: + - destination: + host: income-tax-service.green.svc.cluster.local + subset: OPS-3353 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + route: + - destination: + host: income-tax-service.green.svc.cluster.local + subset: master diff --git a/test/expected_outputs/multipleVersionsNamespace-cluster1/virtual_services-ingress.rendered b/test/expected_outputs/multipleVersionsNamespace-cluster1/virtual_services-ingress.rendered index 6b490e2..c4df71e 100644 --- a/test/expected_outputs/multipleVersionsNamespace-cluster1/virtual_services-ingress.rendered +++ b/test/expected_outputs/multipleVersionsNamespace-cluster1/virtual_services-ingress.rendered @@ -5,84 +5,69 @@ metadata: name: multiple-versions-ingress spec: gateways: - - default-gateway + - default-gateway hosts: - - multipleVersions.example.com - - "*.multipleVersions.example.com" + - multipleVersions.example.com + - "*.multipleVersions.example.com" http: - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - x-variant-id: OPS-335 - match: - - - authority: - regex: (OPS-335|ops-335).multipleVersions.example.com - uri: - regex: ^/multiple-versions(/.*)?$ - route: - - - destination: - host: multiple-versions.multipleVersionsNamespace.svc.cluster.local - subset: OPS-335 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^/multiple-versions(/.*)?$ - headers: - x-variant-id: - regex: (OPS-335|ops-335) - route: - - - destination: - host: multiple-versions.multipleVersionsNamespace.svc.cluster.local - subset: OPS-335 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^/multiple-versions/v1(/.*)?$ - route: - - - destination: - host: multiple-versions.multipleVersionsNamespace.svc.cluster.local - subset: v1 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^/multiple-versions/v2(/.*)?$ - route: - - - destination: - host: multiple-versions.multipleVersionsNamespace.svc.cluster.local - subset: v2 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^/multiple-versions(/.*)?$ - route: - - - destination: - host: multiple-versions.multipleVersionsNamespace.svc.cluster.local - subset: master + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + x-variant-id: OPS-335 + match: + - authority: + regex: (OPS-335|ops-335).multipleVersions.example.com + uri: + regex: ^/multiple-versions(/.*)?$ + route: + - destination: + host: multiple-versions.multipleVersionsNamespace.svc.cluster.local + subset: OPS-335 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^/multiple-versions(/.*)?$ + headers: + x-variant-id: + regex: (OPS-335|ops-335) + route: + - destination: + host: multiple-versions.multipleVersionsNamespace.svc.cluster.local + subset: OPS-335 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^/multiple-versions/v1(/.*)?$ + route: + - destination: + host: multiple-versions.multipleVersionsNamespace.svc.cluster.local + subset: v1 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^/multiple-versions/v2(/.*)?$ + route: + - destination: + host: multiple-versions.multipleVersionsNamespace.svc.cluster.local + subset: v2 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^/multiple-versions(/.*)?$ + route: + - destination: + host: multiple-versions.multipleVersionsNamespace.svc.cluster.local + subset: master diff --git a/test/expected_outputs/saturn-green-proof02/virtual_services-ingress.rendered b/test/expected_outputs/saturn-green-proof02/virtual_services-ingress.rendered index 9757ce4..989ca7f 100644 --- a/test/expected_outputs/saturn-green-proof02/virtual_services-ingress.rendered +++ b/test/expected_outputs/saturn-green-proof02/virtual_services-ingress.rendered @@ -5,25 +5,22 @@ metadata: name: fact-find-service-ingress spec: gateways: - - default-gateway + - default-gateway hosts: - - saturn-green.wealthwizards.io - - "*.saturn-green.wealthwizards.io" + - saturn-green.wealthwizards.io + - "*.saturn-green.wealthwizards.io" http: - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^/fact-find-svc(/.*)?$ - route: - - - destination: - host: fact-find-service.saturn-green.svc.cluster.local - subset: master + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^/fact-find-svc(/.*)?$ + route: + - destination: + host: fact-find-service.saturn-green.svc.cluster.local + subset: master --- apiVersion: networking.istio.io/v1alpha3 kind: VirtualService @@ -31,87 +28,72 @@ metadata: name: fact-find-ui-ingress spec: gateways: - - default-gateway + - default-gateway hosts: - - saturn-green.wealthwizards.io - - "*.saturn-green.wealthwizards.io" + - saturn-green.wealthwizards.io + - "*.saturn-green.wealthwizards.io" http: - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - x-variant-id: OPS-3353 - match: - - - authority: - regex: (OPS-3353|ops-3353).saturn-green.wealthwizards.io - uri: - regex: ^/fact-find(/.*)?$ - - - authority: - regex: (OPS-3353|ops-3353).saturn-green.wealthwizards.io - uri: - regex: ^/fact-find-path1(/.*)?$ - - - authority: - regex: (OPS-3353|ops-3353).saturn-green.wealthwizards.io - uri: - regex: ^/fact-find-path2(/.*)?$ - route: - - - destination: - host: fact-find-ui.saturn-green.svc.cluster.local - subset: OPS-3353 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^/fact-find(/.*)?$ - headers: - x-variant-id: - regex: (OPS-3353|ops-3353) - - - uri: - regex: ^/fact-find-path1(/.*)?$ - headers: - x-variant-id: - regex: (OPS-3353|ops-3353) - - - uri: - regex: ^/fact-find-path2(/.*)?$ - headers: - x-variant-id: - regex: (OPS-3353|ops-3353) - route: - - - destination: - host: fact-find-ui.saturn-green.svc.cluster.local - subset: OPS-3353 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - uri: - regex: ^/fact-find(/.*)?$ - - - uri: - regex: ^/fact-find-path1(/.*)?$ - - - uri: - regex: ^/fact-find-path2(/.*)?$ - route: - - - destination: - host: fact-find-ui.saturn-green.svc.cluster.local - subset: master + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + x-variant-id: OPS-3353 + match: + - authority: + regex: (OPS-3353|ops-3353).saturn-green.wealthwizards.io + uri: + regex: ^/fact-find(/.*)?$ + - authority: + regex: (OPS-3353|ops-3353).saturn-green.wealthwizards.io + uri: + regex: ^/fact-find-path1(/.*)?$ + - authority: + regex: (OPS-3353|ops-3353).saturn-green.wealthwizards.io + uri: + regex: ^/fact-find-path2(/.*)?$ + route: + - destination: + host: fact-find-ui.saturn-green.svc.cluster.local + subset: OPS-3353 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^/fact-find(/.*)?$ + headers: + x-variant-id: + regex: (OPS-3353|ops-3353) + - uri: + regex: ^/fact-find-path1(/.*)?$ + headers: + x-variant-id: + regex: (OPS-3353|ops-3353) + - uri: + regex: ^/fact-find-path2(/.*)?$ + headers: + x-variant-id: + regex: (OPS-3353|ops-3353) + route: + - destination: + host: fact-find-ui.saturn-green.svc.cluster.local + subset: OPS-3353 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - uri: + regex: ^/fact-find(/.*)?$ + - uri: + regex: ^/fact-find-path1(/.*)?$ + - uri: + regex: ^/fact-find-path2(/.*)?$ + route: + - destination: + host: fact-find-ui.saturn-green.svc.cluster.local + subset: master --- apiVersion: networking.istio.io/v1alpha3 kind: VirtualService @@ -119,48 +101,40 @@ metadata: name: income-tax-service-ingress spec: gateways: - - default-gateway + - default-gateway hosts: - - income-tax-service.st.wealthwizards.io - - "*.income-tax-service.st.wealthwizards.io" + - income-tax-service.st.wealthwizards.io + - "*.income-tax-service.st.wealthwizards.io" http: - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - x-variant-id: OPS-335 - match: - - - authority: - regex: (OPS-335|ops-335).income-tax-service.st.wealthwizards.io - route: - - - destination: - host: income-tax-service.saturn-green.svc.cluster.local - subset: OPS-335 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - match: - - - headers: - x-variant-id: - regex: (OPS-335|ops-335) - route: - - - destination: - host: income-tax-service.saturn-green.svc.cluster.local - subset: OPS-335 - - - appendHeaders: - x-envoy-max-retries: "5" - x-envoy-retry-on: connect-failure - x-envoy-upstream-rq-timeout-ms: "0" - route: - - - destination: - host: income-tax-service.saturn-green.svc.cluster.local - subset: master + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + x-variant-id: OPS-335 + match: + - authority: + regex: (OPS-335|ops-335).income-tax-service.st.wealthwizards.io + route: + - destination: + host: income-tax-service.saturn-green.svc.cluster.local + subset: OPS-335 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + match: + - headers: + x-variant-id: + regex: (OPS-335|ops-335) + route: + - destination: + host: income-tax-service.saturn-green.svc.cluster.local + subset: OPS-335 + - appendHeaders: + x-envoy-max-retries: "5" + x-envoy-retry-on: connect-failure + x-envoy-upstream-rq-timeout-ms: "0" + route: + - destination: + host: income-tax-service.saturn-green.svc.cluster.local + subset: master