Skip to content

Commit 8aa5782

Browse files
authored
Merge pull request #185 from tv2-oss/feature/https-redirect
Feature/https redirect
2 parents 5fce176 + c52469c commit 8aa5782

File tree

2 files changed

+73
-9
lines changed

2 files changed

+73
-9
lines changed

blueprints/aws-alb-crossplane/gatewayclassblueprint-aws-alb-crossplane.yaml

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ spec:
1414
ingressAcls:
1515
cidrs:
1616
- 0.0.0.0/0
17-
port: 443
1817
tags: []
1918
# Values required by this blueprint without defaults:
2019
# providerConfigName: "example-crossplane-provider-name"
@@ -115,6 +114,33 @@ spec:
115114
{{- toYaml .Values.tags | nindent 6 }}
116115
{{ end }}
117116
targetType: ip
117+
LBListenerRedirHttps: |
118+
apiVersion: elbv2.aws.upbound.io/v1beta1
119+
kind: LBListener
120+
metadata:
121+
labels:
122+
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
123+
name: gw-{{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}-redir
124+
spec:
125+
providerConfigRef:
126+
name: {{ .Values.providerConfigName }}
127+
forProvider:
128+
region: {{ .Values.region }}
129+
port: 80
130+
protocol: HTTP
131+
defaultAction:
132+
- type: redirect
133+
redirect:
134+
- port: "443"
135+
protocol: HTTPS
136+
statusCode: HTTP_301
137+
loadBalancerArnSelector:
138+
matchLabels:
139+
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
140+
{{ if .Values.tags }}
141+
tags:
142+
{{- toYaml .Values.tags | nindent 6 }}
143+
{{ end }}
118144
LBListener: |
119145
apiVersion: elbv2.aws.upbound.io/v1beta1
120146
kind: LBListener
@@ -221,29 +247,53 @@ spec:
221247
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
222248
toPort: 15021
223249
type: egress
224-
SecurityGroupRuleIngress: |
250+
SecurityGroupRuleIngress80: |
251+
apiVersion: ec2.aws.upbound.io/v1beta1
252+
kind: SecurityGroupRule
253+
metadata:
254+
labels:
255+
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
256+
name: gw-{{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}-ingress80
257+
spec:
258+
providerConfigRef:
259+
name: {{ .Values.providerConfigName }}
260+
forProvider:
261+
description: "External traffic towards ALB port 80"
262+
cidrBlocks:
263+
{{ range .Values.ingressAcls.cidrs -}}
264+
- {{ . }}
265+
{{ end }}
266+
fromPort: 80
267+
protocol: tcp
268+
region: {{ .Values.region }}
269+
securityGroupIdSelector:
270+
matchLabels:
271+
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
272+
toPort: 80
273+
type: ingress
274+
SecurityGroupRuleIngress443: |
225275
apiVersion: ec2.aws.upbound.io/v1beta1
226276
kind: SecurityGroupRule
227277
metadata:
228278
labels:
229279
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
230-
name: gw-{{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}-ingress
280+
name: gw-{{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}-ingress443
231281
spec:
232282
providerConfigRef:
233283
name: {{ .Values.providerConfigName }}
234284
forProvider:
235-
description: "External traffic towards ALB"
285+
description: "External traffic towards ALB port 443"
236286
cidrBlocks:
237287
{{ range .Values.ingressAcls.cidrs -}}
238288
- {{ . }}
239289
{{ end }}
240-
fromPort: {{ .Values.ingressAcls.port }}
290+
fromPort: 443
241291
protocol: tcp
242292
region: {{ .Values.region }}
243293
securityGroupIdSelector:
244294
matchLabels:
245295
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
246-
toPort: {{ .Values.ingressAcls.port }}
296+
toPort: 443
247297
type: ingress
248298
SecurityGroupRuleUpstreamIngress80: |
249299
apiVersion: ec2.aws.upbound.io/v1beta1

hack/demo/namespace-gatewayclassconfig.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1+
# Settings owned by infrastructure provider, tenant cannot modify or override
12
apiVersion: gateway.tv2.dk/v1alpha1
23
kind: GatewayClassConfig
34
metadata:
45
name: foo-infra-tenant-defaults
56
namespace: foo-infra
67
spec:
78
override:
8-
certificateArn: $CERTIFICATE_ARN
99
providerConfigName: admin
10-
#tags:
11-
# tenant: foo-tenant
10+
tags:
11+
tenant: foo-tenant
12+
targetRef:
13+
group: ""
14+
kind: Namespace
15+
name: foo-infra
16+
---
17+
# Configuration owned by tenant
18+
apiVersion: gateway.tv2.dk/v1alpha1
19+
kind: GatewayConfig
20+
metadata:
21+
name: foo-infra-tenant-defaults
22+
namespace: foo-infra
23+
spec:
24+
default:
25+
certificateArn: $CERTIFICATE_ARN
1226
targetRef:
1327
group: ""
1428
kind: Namespace

0 commit comments

Comments
 (0)