Skip to content

Commit 83c6f62

Browse files
authored
Limited character for name of targetgroup in GatewayClassBlueprint (#221)
* Limited character binding for targetgroup * Update README * add tagging
1 parent ace9eec commit 83c6f62

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

blueprints/aws-alb-crossplane/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ This definition is provided in the following files:
3232
- [`gatewayclassblueprint-crossplane-aws-alb-values.yaml`](../../charts/bifrost-gateway-controller/ci/gatewayclassblueprint-crossplane-aws-alb-values.yaml)
3333
RBAC for bifrost-gateway-controller Helm deployment suited for the `aws-alb-crossplane` blueprint.
3434

35+
### TargetGroup name limit
36+
37+
The `TargetGroup` resource in AWS has a character limit of 32 in AWS. This doesn't leave a lot of room for identifiers in the name. For this reason, the generated name (the format of which is `gw-<NAMESPACE>-<NAME>`) will be cut off at 25 characters, and then appended with the first 6 characters of the SHA1 of the entire name. This should ensure uniqueness of names, while also forcing conforming to the 32 character limit.
38+
39+
Because of this method, the name of `TargetGroups` might not always contain the full `name` and `namespace` of the corresponding Kubernetes resource. For this reason, these resources in AWS will also be tagged with `bifrost-gateway-controller/targetgroup_name` and `bifrost-gateway-controller/targetgroup_namespace`.
40+
3541
## Compatibility
3642

3743
This blueprint use AWS Crossplane resources through the [Upbound AWS

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ spec:
9999
metadata:
100100
labels:
101101
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
102-
name: gw-{{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
102+
name: {{ printf "gw-%s-%s" .Gateway.metadata.namespace .Gateway.metadata.name | substr 0 25}}-{{ printf "%s-%s" .Gateway.metadata.namespace .Gateway.metadata.name | sha1sum | substr 0 6 }}
103103
spec:
104104
providerConfigRef:
105105
name: {{ .Values.providerConfigName }}
106106
forProvider:
107-
name: gw-{{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
107+
name: {{ printf "gw-%s-%s" .Gateway.metadata.namespace .Gateway.metadata.name | substr 0 25}}-{{ printf "%s-%s" .Gateway.metadata.namespace .Gateway.metadata.name | sha1sum | substr 0 6 }}
108108
region: {{ .Values.region }}
109109
vpcId: {{ .Values.vpcId }}
110110
healthCheck:
@@ -116,10 +116,12 @@ spec:
116116
port: {{ .Values.healthCheck.port | quote }}
117117
port: 80
118118
protocol: HTTP
119-
{{ if .Values.tags }}
120119
tags:
120+
bifrost-gateway-controller/targetgroup_name: {{ .Gateway.metadata.name }}
121+
bifrost-gateway-controller/targetgroup_namespace: {{ .Gateway.metadata.namespace }}
122+
{{ if .Values.tags }}
121123
{{- toYaml .Values.tags | nindent 6 }}
122-
{{ end }}
124+
{{ end }}
123125
targetType: ip
124126
LBListenerRedirHttps: |
125127
apiVersion: elbv2.aws.upbound.io/v1beta1

hack/demo/delete-gw-cluster-resources.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ NS=$1
44
GWNAME=$2
55

66
NAME=gw-${NS}-${GWNAME}
7+
TARGETGROUPNAME="$(echo "gw-${NS}-${GWNAME}" | cut -b1-25)-$(echo -n "${NS}-${GWNAME}" | openssl sha1 | cut -b1-6)"
78

89
kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-upstream15021
910
kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-upstream80
@@ -13,6 +14,6 @@ kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-ingress80
1314
kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-ingress443
1415
kubectl delete lblistener.elbv2.aws.upbound.io/${NAME}
1516
kubectl delete lblistener.elbv2.aws.upbound.io/${NAME}-redir
16-
kubectl delete lbtargetgroup.elbv2.aws.upbound.io/${NAME}
17+
kubectl delete lbtargetgroup.elbv2.aws.upbound.io/${TARGETGROUPNAME}
1718
kubectl delete lb.elbv2.aws.upbound.io/${NAME}
1819
kubectl delete securitygroup.ec2.aws.upbound.io/${NAME}

0 commit comments

Comments
 (0)