Add gateway-api support to http-support.
Showing
2 changed files
with
126 additions
and
62 deletions
1 | namespace: default | ||
2 | istio: | ||
3 | enabled: true | ||
4 | gateway: istio-system/cluster-local-gateway | ||
5 | gatewayAPI: | ||
6 | enabled: false | ||
7 | gateway: gateway | ||
8 | redirect: | ||
9 | - hosts: | ||
10 | - example.com | ||
11 | target: www.example.com | ||
12 | proxy: | ||
13 | - frontend: | ||
14 | host: www.example.com | ||
15 | stub: example.com | ||
16 | backend: | ||
17 | scheme: https | ||
18 | host: www.real.example.com | ||
19 | stub: real.example.com | ||
20 | address: 8.8.8.8 | ||
21 | authority: www.example.com | ||
22 | config: | | ||
23 | server { | ||
24 | server_name www.example.com; | ||
25 | listen 80; | ||
26 | client_max_body_size 5m; | ||
27 | error_log /var/log/nginx/error.log debug; | ||
28 | resolver 10.43.0.10; | ||
29 | |||
30 | location / { | ||
31 | proxy_pass $http_x_backend_scheme://$http_x_backend_address; | ||
32 | proxy_http_version 1.1; | ||
33 | proxy_ssl_name $http_x_backend_host; | ||
34 | proxy_cookie_domain $http_x_backend_stub $http_x_frontend_stub; | ||
35 | proxy_cookie_domain $http_x_backend_host $http_x_frontend_host; | ||
36 | proxy_redirect $http_x_backend_scheme://$http_x_backend_host/ $http_x_backend_scheme://$http_x_frontend_host/; | ||
37 | proxy_set_header x-envoy-internal ""; | ||
38 | proxy_set_header x-request-id ""; | ||
39 | proxy_set_header x-envoy-decorator-operation ""; | ||
40 | proxy_set_header x-envoy-peer-metadata ""; | ||
41 | proxy_set_header x-envoy-peer-metadata-id ""; | ||
42 | proxy_set_header x-envoy-attempt-count ""; | ||
43 | proxy_set_header x-b3-traceid ""; | ||
44 | proxy_set_header x-b3-spanid ""; | ||
45 | proxy_set_header x-b3-sampled ""; | ||
46 | proxy_set_header x-backend-host ""; | ||
47 | proxy_set_header x-backend-stub ""; | ||
48 | proxy_set_header x-backend-address ""; | ||
49 | proxy_set_header x-frontend-host ""; | ||
50 | proxy_set_header x-frontend-stub ""; | ||
51 | |||
52 | proxy_set_header Host $http_x_backend_host; | ||
53 | proxy_set_header Accept-Encoding ""; | ||
54 | sub_filter_types text/css; | ||
55 | sub_filter https://$http_x_backend_host/ "https://$http_x_frontend_host/"; | ||
56 | sub_filter https%3A%2F%2F$http_x_backend_host%2F "https:%3A%2F%2F$http_x_frontend_host%2F"; | ||
57 | sub_filter https:\/\/$http_x_backend_host\/ "https:\/\/$http_x_frontend_host\/"; | ||
58 | sub_filter //$http_x_backend_host/ "//$http_x_frontend_host/"; | ||
59 | sub_filter_once off; | ||
60 | } | ||
61 | } | ||
62 | versions: | ||
63 | raw: 1.1.0 | ||
64 | nginx: 1.21 | ||
65 |
1 | environments: | 1 | bases: |
2 | default: | 2 | - ../common/environments.yaml |
3 | values: | ||
4 | - namespace: default | ||
5 | gateway: istio-system/cluster-local-gateway | ||
6 | redirect: | ||
7 | - hosts: | ||
8 | - example.com | ||
9 | target: www.example.com | ||
10 | proxy: | ||
11 | - frontend: | ||
12 | host: www.example.com | ||
13 | stub: example.com | ||
14 | backend: | ||
15 | scheme: https | ||
16 | host: www.real.example.com | ||
17 | stub: real.example.com | ||
18 | address: 8.8.8.8 | ||
19 | authority: www.example.com | ||
20 | config: | | ||
21 | server { | ||
22 | server_name www.example.com; | ||
23 | listen 80; | ||
24 | client_max_body_size 5m; | ||
25 | error_log /var/log/nginx/error.log debug; | ||
26 | resolver 10.43.0.10; | ||
27 | |||
28 | location / { | ||
29 | proxy_pass $http_x_backend_scheme://$http_x_backend_address; | ||
30 | proxy_http_version 1.1; | ||
31 | proxy_ssl_name $http_x_backend_host; | ||
32 | proxy_cookie_domain $http_x_backend_stub $http_x_frontend_stub; | ||
33 | proxy_cookie_domain $http_x_backend_host $http_x_frontend_host; | ||
34 | proxy_redirect $http_x_backend_scheme://$http_x_backend_host/ $http_x_backend_scheme://$http_x_frontend_host/; | ||
35 | proxy_set_header x-envoy-internal ""; | ||
36 | proxy_set_header x-request-id ""; | ||
37 | proxy_set_header x-envoy-decorator-operation ""; | ||
38 | proxy_set_header x-envoy-peer-metadata ""; | ||
39 | proxy_set_header x-envoy-peer-metadata-id ""; | ||
40 | proxy_set_header x-envoy-attempt-count ""; | ||
41 | proxy_set_header x-b3-traceid ""; | ||
42 | proxy_set_header x-b3-spanid ""; | ||
43 | proxy_set_header x-b3-sampled ""; | ||
44 | proxy_set_header x-backend-host ""; | ||
45 | proxy_set_header x-backend-stub ""; | ||
46 | proxy_set_header x-backend-address ""; | ||
47 | proxy_set_header x-frontend-host ""; | ||
48 | proxy_set_header x-frontend-stub ""; | ||
49 | 3 | ||
50 | proxy_set_header Host $http_x_backend_host; | ||
51 | proxy_set_header Accept-Encoding ""; | ||
52 | sub_filter_types text/css; | ||
53 | sub_filter https://$http_x_backend_host/ "https://$http_x_frontend_host/"; | ||
54 | sub_filter https%3A%2F%2F$http_x_backend_host%2F "https:%3A%2F%2F$http_x_frontend_host%2F"; | ||
55 | sub_filter https:\/\/$http_x_backend_host\/ "https:\/\/$http_x_frontend_host\/"; | ||
56 | sub_filter //$http_x_backend_host/ "//$http_x_frontend_host/"; | ||
57 | sub_filter_once off; | ||
58 | } | ||
59 | } | ||
60 | versions: | ||
61 | raw: 1.1.0 | ||
62 | nginx: 1.21 | ||
63 | --- | 4 | --- |
64 | 5 | ||
65 | repositories: | 6 | repositories: |
... | @@ -78,6 +19,7 @@ releases: | ... | @@ -78,6 +19,7 @@ releases: |
78 | - raw: | 19 | - raw: |
79 | resources: | 20 | resources: |
80 | {{- range $redirect_index, $redirect := .Values.redirect }} | 21 | {{- range $redirect_index, $redirect := .Values.redirect }} |
22 | {{- if .Values.istio.enabled }} | ||
81 | - apiVersion: networking.istio.io/v1alpha3 | 23 | - apiVersion: networking.istio.io/v1alpha3 |
82 | kind: VirtualService | 24 | kind: VirtualService |
83 | metadata: | 25 | metadata: |
... | @@ -86,7 +28,7 @@ releases: | ... | @@ -86,7 +28,7 @@ releases: |
86 | hosts: | 28 | hosts: |
87 | {{- $redirect.hosts | toYaml | nindent 18 }} | 29 | {{- $redirect.hosts | toYaml | nindent 18 }} |
88 | gateways: | 30 | gateways: |
89 | - {{ $.Values.gateway }} | 31 | - {{ $.Values.istio.gateway }} |
90 | http: | 32 | http: |
91 | - match: | 33 | - match: |
92 | - uri: | 34 | - uri: |
... | @@ -95,6 +37,29 @@ releases: | ... | @@ -95,6 +37,29 @@ releases: |
95 | redirectCode: 302 | 37 | redirectCode: 302 |
96 | authority: {{ $redirect.target }} | 38 | authority: {{ $redirect.target }} |
97 | {{- end }} | 39 | {{- end }} |
40 | {{- if .Values.gatewayAPI.enabled }} | ||
41 | - apiVersion: gateway.networking.k8s.io/v1beta1 | ||
42 | kind: HTTPRoute | ||
43 | metadata: | ||
44 | name: http-support-redirect-{{ $redirect_index }}-{{ index $redirect.hosts 0 }} | ||
45 | spec: | ||
46 | parentRefs: | ||
47 | - name: {{ $.Values.gatewayAPI.gateway }} | ||
48 | hostnames: | ||
49 | {{- $redirect.hosts | toYaml | nindent 18 }} | ||
50 | rules: | ||
51 | - matches: | ||
52 | - path: | ||
53 | type: PathPrefix | ||
54 | value: / | ||
55 | filters: | ||
56 | - type: RequestRedirect | ||
57 | requestRedirect: | ||
58 | scheme: https | ||
59 | statusCode: 302 | ||
60 | hostname: {{ $redirect.target }} | ||
61 | {{- end }} | ||
62 | {{- end }} | ||
98 | - apiVersion: v1 | 63 | - apiVersion: v1 |
99 | kind: ConfigMap | 64 | kind: ConfigMap |
100 | metadata: | 65 | metadata: |
... | @@ -116,6 +81,7 @@ releases: | ... | @@ -116,6 +81,7 @@ releases: |
116 | } | 81 | } |
117 | } | 82 | } |
118 | {{- range $proxy_index, $proxy := .Values.proxy }} | 83 | {{- range $proxy_index, $proxy := .Values.proxy }} |
84 | {{- if .Values.istio.enabled }} | ||
119 | - apiVersion: networking.istio.io/v1alpha3 | 85 | - apiVersion: networking.istio.io/v1alpha3 |
120 | kind: VirtualService | 86 | kind: VirtualService |
121 | metadata: | 87 | metadata: |
... | @@ -146,5 +112,38 @@ releases: | ... | @@ -146,5 +112,38 @@ releases: |
146 | x-backend-address: {{ $proxy.backend.address }} | 112 | x-backend-address: {{ $proxy.backend.address }} |
147 | x-backend-scheme: {{ $proxy.backend.scheme }} | 113 | x-backend-scheme: {{ $proxy.backend.scheme }} |
148 | {{- end }} | 114 | {{- end }} |
115 | {{- if .Values.gatewayAPI.enabled }} | ||
116 | - apiVersion: gateway.networking.k8s.io/v1beta1 | ||
117 | kind: HTTPRoute | ||
118 | metadata: | ||
119 | name: http-support-proxy-{{ $proxy_index }}-{{ index $proxy.frontend.host 0 }} | ||
120 | spec: | ||
121 | parentRefs: | ||
122 | - name: {{ $.Values.gatewayAPI.gateway }} | ||
123 | hostnames: | ||
124 | {{- $proxy.hosts | toYaml | nindent 18 }} | ||
125 | rules: | ||
126 | - matches: | ||
127 | - path: | ||
128 | type: PathPrefix | ||
129 | value: / | ||
130 | filters: | ||
131 | - type: RequestHeaderModifier | ||
132 | requestHeaderModifier: | ||
133 | set: | ||
134 | - name: x-frontend-host | ||
135 | value: {{ $proxy.frontend.host }} | ||
136 | - name: x-frontend-stub | ||
137 | value: {{ $proxy.frontend.stub }} | ||
138 | - name: x-backend-host | ||
139 | value: {{ $proxy.backend.host }} | ||
140 | - name: x-backend-stub | ||
141 | value: {{ $proxy.backend.stub }} | ||
142 | - name: x-backend-address | ||
143 | value: {{ $proxy.backend.address }} | ||
144 | - name: x-backend-scheme | ||
145 | value: {{ $proxy.backend.scheme }} | ||
146 | {{- end }} | ||
147 | {{- end }} | ||
149 | 148 | ||
150 | 149 | ... | ... |
-
Please register or sign in to post a comment