2016-11-28

Tags: kubernetes aws

SSL for AWS ELBs with Kubernetes

NOTE: This is a beta feature of Kubernetes. Use at your own risk.

I want to setup HTTP on port 80 and SSL on port 443 and then route both on TCP to my backend servers in AWS, like so:

Screenshot showing aws elb

To do this with Kubernetes, I need the following service definition:

apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:iam::723765766667:server-certificate/certificate-name"
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
  name: myproject
  labels:
    run: myproject
spec:
  type: LoadBalancer
  ports:
    - name: "http"
      port: 80
      targetPort: 80
      protocol: "TCP"
    - name: "https"
      port: 443
      targetPort: 80
      protocol: "TCP"

Hooray!