Skip to content

Commit 37fb82d

Browse files
Add gateway.rules in acaas (#1294)
Signed-off-by: Arnob Kumar Saha <arnob@appscode.com>
1 parent 1548baa commit 37fb82d

17 files changed

Lines changed: 153 additions & 17 deletions

File tree

apis/installer/v1alpha1/ace_acaas_types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type AcaasSpec struct {
5454

5555
Global AcaasGlobalValues `json:"global"`
5656
Ingress AcaasIngress `json:"ingress"`
57-
Gateway AceGateway `json:"gateway"`
57+
Gateway AcaasGateway `json:"gateway"`
5858
}
5959

6060
type AceBilling struct {
@@ -137,6 +137,12 @@ type AcaasIngressTLS struct {
137137
Secret LocalObjectReference `json:"secret"`
138138
}
139139

140+
type AcaasGateway struct {
141+
Enabled bool `json:"enabled"`
142+
*GatewaySpec `json:",inline,omitempty"`
143+
Rules AcaasIngressRules `json:"rules"`
144+
}
145+
140146
type AcaasIngressRules struct {
141147
Blog ExternalService `json:"blog"`
142148
Docs ExternalService `json:"docs"`

apis/installer/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/acaas/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ The following table lists the configurable parameters of the `acaas` chart and t
7979
| gateway.enabled | | <code>false</code> |
8080
| gateway.tls.enabled | | <code>true</code> |
8181
| gateway.tls.secret.name | | <code>"ace-cert"</code> |
82+
| gateway.rules.blog.upstream | | <code>""</code> |
83+
| gateway.rules.docs.upstream | | <code>""</code> |
84+
| gateway.rules.learn.upstream | | <code>""</code> |
85+
| gateway.rules.license.upstream | | <code>""</code> |
86+
| gateway.rules.selfhost.upstream | | <code>""</code> |
8287
| ingress.enabled | | <code>true</code> |
8388
| ingress.className | | <code>"nginx-ace"</code> |
8489
| ingress.tls.enable | | <code>true</code> |

charts/acaas/templates/blog/route.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ spec:
2323
type: PathPrefix
2424
value: /blog
2525
backendRefs:
26-
- group: ""
27-
kind: Service
26+
- group: gateway.envoyproxy.io
27+
kind: Backend
2828
name: blog
29-
namespace: {{ .Release.Namespace }}
3029
port: 443
3130
weight: 1
31+
filters:
32+
- type: URLRewrite
33+
urlRewrite:
34+
hostname: {{ .Values.gateway.rules.blog.upstream }}
3235
{{- end }}

charts/acaas/templates/blog/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if eq (toString .Values.global.platform.deploymentType) "Hosted" }}
1+
{{- if and (eq (toString .Values.global.platform.deploymentType) "Hosted") (index .Values "ingress" "enabled") }}
22
apiVersion: v1
33
kind: Service
44
metadata:

charts/acaas/templates/docs/route.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ spec:
2323
type: PathPrefix
2424
value: /docs
2525
backendRefs:
26-
- kind: Service
26+
- group: gateway.envoyproxy.io
27+
kind: Backend
2728
name: docs
28-
namespace: {{ .Release.Namespace }}
2929
port: 443
30+
weight: 1
31+
filters:
32+
- type: URLRewrite
33+
urlRewrite:
34+
hostname: {{ .Values.gateway.rules.docs.upstream }}
3035
{{- end }}

charts/acaas/templates/docs/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if eq (toString .Values.global.platform.deploymentType) "Hosted" }}
1+
{{- if and (eq (toString .Values.global.platform.deploymentType) "Hosted") (index .Values "ingress" "enabled") }}
22
apiVersion: v1
33
kind: Service
44
metadata:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{{- if and (eq (toString .Values.global.platform.deploymentType) "Hosted") (index .Values "gateway" "enabled") }}
2+
{{- range $name, $rule := .Values.gateway.rules }}
3+
---
4+
# Backend: resolves the external upstream by FQDN so Envoy uses a STRICT_DNS
5+
# cluster instead of Kubernetes EndpointSlices. An ExternalName Service has no
6+
# EndpointSlices, so plain backendRefs -> Service report zero ready endpoints.
7+
# Requires extensionApis.enableBackend: true in the EnvoyGateway config.
8+
apiVersion: gateway.envoyproxy.io/v1alpha1
9+
kind: Backend
10+
metadata:
11+
{{- with $.Values.gateway.annotations }}
12+
annotations:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
name: {{ $name }}
16+
namespace: {{ $.Release.Namespace }}
17+
spec:
18+
endpoints:
19+
- fqdn:
20+
hostname: {{ $rule.upstream }}
21+
port: 443
22+
---
23+
# BackendTLSPolicy: makes Envoy originate TLS to the Backend above. Without it
24+
# Envoy connects in plaintext on 443 and the upstream (which terminates TLS on
25+
# that port) resets the connection with a protocol_error.
26+
apiVersion: gateway.networking.k8s.io/v1alpha3
27+
kind: BackendTLSPolicy
28+
metadata:
29+
{{- with $.Values.gateway.annotations }}
30+
annotations:
31+
{{- toYaml . | nindent 4 }}
32+
{{- end }}
33+
name: {{ $name }}
34+
namespace: {{ $.Release.Namespace }}
35+
spec:
36+
targetRefs:
37+
- group: gateway.envoyproxy.io
38+
kind: Backend
39+
name: {{ $name }}
40+
validation:
41+
hostname: {{ $rule.upstream }}
42+
wellKnownCACertificates: System
43+
{{- end }}
44+
{{- end }}

charts/acaas/templates/learn/route.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ spec:
2323
type: PathPrefix
2424
value: /learn
2525
backendRefs:
26-
- kind: Service
26+
- group: gateway.envoyproxy.io
27+
kind: Backend
2728
name: learn
28-
namespace: {{ .Release.Namespace }}
2929
port: 443
30+
weight: 1
31+
filters:
32+
- type: URLRewrite
33+
urlRewrite:
34+
hostname: {{ .Values.gateway.rules.learn.upstream }}
3035
{{- end }}

charts/acaas/templates/learn/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if eq (toString .Values.global.platform.deploymentType) "Hosted" }}
1+
{{- if and (eq (toString .Values.global.platform.deploymentType) "Hosted") (index .Values "ingress" "enabled") }}
22
apiVersion: v1
33
kind: Service
44
metadata:

0 commit comments

Comments
 (0)