gomods / athens-charts

Helm charts for athens
https://gomods.github.io/athens-charts/
MIT License
10 stars 18 forks source link

[Chart] AWS Load Balancer Controller ssl redirect using annotation #28

Open pshanoop opened 3 years ago

pshanoop commented 3 years ago

Is your feature request related to a problem? Please describe. With current chart, It is not possible to setup ssl-redirect for aws loadbalancer controller ingress.

Describe the solution you'd like Adding a extraPath map value to each hosts. Where serverName and servicePort can be defined will resolve this issue. Values will look like

ingress:
  enabled: true
  annotations:
    alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
    alb.ingress.kubernetes.io/certificate-arn: ACM ARN
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: instance
    kubernetes.io/ingress.class: alb
  # Provide an array of values for the ingress host mapping
  hosts:
    - athens-proxy.host
  extraPaths:
    # This will be added to each hosts
    - service: ssl-redirect
      port: use-annotation
      path: /*

ingress template will then

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    alb.ingress.kubernetes.io/healthcheck-path: /healthz
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/tags: Service=athens-proxy,Environment=k-production
    alb.ingress.kubernetes.io/target-type: instance
    kubernetes.io/ingress.class: alb
  name: athens-proxy
  namespace: devops
spec:
  rules:
  - host: athens-proxy.legalone.io
    http:
      paths:
      - backend:
          serviceName: ssl-redirect
          servicePort: use-annotation
        path: /*
      - backend:
          serviceName: athens-proxy
          servicePort: 80
        path: /

This is a method suggest by aws loadbalancer documentation

pshanoop commented 3 years ago

I noticed I missed the detail about the default path. On nginx / will match all paths, But on ALB it uses glob match, so it needs /* to match all paths.

To solve this I added customPath on my PR.