Skip to content

Commit 6eef1fa

Browse files
committed
Add HorizontalPodAutoscaler and PodDisruptionBudget resources to aws-crossplane blueprint
1 parent 36ebf6d commit 6eef1fa

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

blueprints/aws-alb-crossplane/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ infrastructure:
66
- Application load balancer (ALB).
77
- Security group for ALB, together with ingress and egress rules (for
88
both data and healthchecks).
9-
- ALB target group and listener definitions.
9+
- ALB target group
10+
- ALB listener definitions for both terminating TLS (port 443) and redirecting HTTP (port 80) to HTTPS.
1011

1112
This definition also includes the following Kubernetes infrastructure:
1213

@@ -17,6 +18,8 @@ This definition also includes the following Kubernetes infrastructure:
1718
for propagating Kubernetes endpoints for the Istio ingress gateway
1819
to the AWS ALB target group. This links the Kubernetes internal and
1920
AWS infrastructure.
21+
- Optional HorizontalPodAutoscaler
22+
- Optional PodDisruptionBudget
2023

2124
**Note** the ALB terminates TLS and forwards traffic un-encrypted to
2225
the Istio ingress gateway.

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ spec:
1111
threshold: 2
1212
path: /healthz/ready
1313
port: 15021
14+
hpa:
15+
minReplicas: 1 # optional
16+
maxReplicas: 3 # Optional, will default to minReplicas if minReplicas is defined
17+
averageUtilization: 60
1418
ingressAcls:
1519
cidrs:
1620
- 0.0.0.0/0
21+
pdb:
22+
minAvailable: "1"
23+
maxUnavailable:
1724
tags: []
1825
# Values required by this blueprint without defaults:
1926
# providerConfigName: "example-crossplane-provider-name"
@@ -42,6 +49,7 @@ spec:
4249
namespace: {{ .Gateway.metadata.namespace }}
4350
annotations:
4451
networking.istio.io/service-type: ClusterIP
52+
sidecar.istio.io/proxyCPU: "1"
4553
{{ if .Values.tags }}
4654
{{ toYaml .Values.tags | nindent 4 }}
4755
{{ end }}
@@ -337,6 +345,59 @@ spec:
337345
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
338346
toPort: 15021
339347
type: ingress
348+
hpa: |
349+
{{ if or (get .Values.hpa "minReplicas") (get .Values.hpa "maxReplicas") }}
350+
apiVersion: autoscaling/v2
351+
kind: HorizontalPodAutoscaler
352+
metadata:
353+
labels:
354+
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
355+
name: gw-{{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
356+
namespace: {{ .Gateway.metadata.namespace }}
357+
spec:
358+
scaleTargetRef:
359+
apiVersion: apps/v1
360+
kind: Deployment
361+
name: {{ .Gateway.metadata.name }}-child-istio
362+
{{ if get .Values.hpa "minReplicas" }}
363+
minReplicas: {{ .Values.hpa.minReplicas }}
364+
{{ end }}
365+
{{ if get .Values.hpa "maxReplicas" }}
366+
maxReplicas: {{ .Values.hpa.maxReplicas }}
367+
{{ else }} # Ensure that max >= min
368+
{{ if get .Values.hpa "minReplicas" }}
369+
maxReplicas: {{ .Values.hpa.minReplicas }}
370+
{{ end }}
371+
{{ end }}
372+
metrics:
373+
- type: Resource
374+
resource:
375+
name: cpu
376+
target:
377+
type: Utilization
378+
averageUtilization: {{ .Values.hpa.averageUtilization }}
379+
{{ end }}
380+
pdb: |
381+
{{ if or (get .Values.pdb "minAvailable") (get .Values.pdb "maxUnavailable") }}
382+
apiVersion: policy/v1
383+
kind: PodDisruptionBudget
384+
metadata:
385+
labels:
386+
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
387+
name: gw-{{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
388+
namespace: {{ .Gateway.metadata.namespace }}
389+
spec:
390+
{{ if get .Values.pdb "minAvailable" }}
391+
minAvailable: {{ .Values.pdb.minAvailable }}
392+
{{ else }}
393+
maxUnavailable: {{ .Values.pdb.maxUnavailable }}
394+
{{ end }}
395+
selector:
396+
# Match the generated Deployment by label
397+
matchLabels:
398+
tv2.dk/gw: {{ .Gateway.metadata.namespace }}-{{ .Gateway.metadata.name }}
399+
istio.io/gateway-name: {{ .Gateway.metadata.name }}-child
400+
{{ end }}
340401
341402
# The following are templates used to 'implement' a 'parent' HTTPRoute
342403
httpRouteTemplate:

hack/demo/show-resources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#! /bin/bash
22

3-
kubectl get gateway,lbs,lbtargetgroups,lblisteners,securitygroups,securitygrouprules,targetgroupbindings -A | sed -E 's#(arn:aws:elasticloadbalancing:eu-central-1:)[0-9]+(:[-0-9a-z\/]+)#\11234567890\2#'
3+
kubectl get gateway,lbs,lbtargetgroups,lblisteners,securitygroups,securitygrouprules,targetgroupbindings,hpa,pdb -A | sed -E 's#(arn:aws:elasticloadbalancing:eu-central-1:)[0-9]+(:[-0-9a-z\/]+)#\11234567890\2#'

0 commit comments

Comments
 (0)