Introduction#

Github this note shows how to deploy a service (flask app) with https load balancer

  • Account A: request an ACM certificate
  • Account A: create flask-app.yaml
  • Account B: create a route53 cname record

Flask App#

Let create an flask-app.yaml to deploy the web app

apiVersion: v1
kind: Service
metadata:
name: book-app-service
annotations:
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:$REGION:$ACCOUNT_ID:certificate/abc
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
spec:
ports:
- port: 80
targetPort: 8080
name: http
- port: 443
targetPort: 8080
name: https
selector:
app: book-app
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: book-app-deployment
spec:
replicas: 2
selector:
matchLabels:
app: book-app
template:
metadata:
labels:
app: book-app
spec:
containers:
- image: $ACCOUNT_ID.dkr.ecr.ap-southeast-1.amazonaws.com/book-app:latest
name: book-app
ports:
- containerPort: 8080
resources:
limits:
cpu: 100m
requests:
cpu: 100m
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: book-app-hpa
spec:
maxReplicas: 1000
metrics:
- resource:
name: cpu
target:
averageUtilization: 5
type: Utilization
type: Resource
minReplicas: 2
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: book-app-deployment

HTTPS#

To support https load balancer we need to

  • Account A: request an ACM certificate and confirm by email (admin of the registered domain)
  • Account B: create a route53 cname record

TODO: image here

References#