Kubernetes alb-ingress-controller to internal nginx ingress

12/18/2019

I have a single ALB which is configured for requests on *.stuff.mydomain.com. I then want it to direct requests to an nginx ingress controller which will route to specific services on sub domains such as a.stuff.mydomain.com and b.stuff.mydomain.com. I only want one actual hardware load balancer.

This is the config I have which results in the following from kubectl. It seems right but yet nothing resolves and I can't find anything in the logs as to why.

12:57 $ kubectl get ingress
NAME                   HOSTS                    ADDRESS          PORTS   AGE
alb-ingress            *.stuff.mydomain.com                       80      34m
b-ingress-service      b.stuff.mydomain.com   172.20.141.241      80      18m
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "alb-ingress"
  namespace: default
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
    alb.ingress.kubernetes.io/success-codes: "404"
    external-dns.alpha.kubernetes.io/hostname: "*.stuff.mydomain.com" 
    alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
    alb.ingress.kubernetes.io/target-type: ip
  labels:
    app: myapp
spec:
  rules:
    - host: "*.stuff.mydomain.com"
      http:
        paths:
          - path: /*
            backend:
             serviceName: ssl-redirect
             servicePort: use-annotation
          - path: /*
            backend:
              serviceName: "ingress-nginx"
              servicePort: 80

---
# nginx service
apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
spec:
  type: ClusterIP
  ports:
  - name: http
    port: 80
    targetPort: 80
    protocol: TCP
  - name: https
    port: 443
    targetPort: 443
    protocol: TCP
  selector:
    app: ingress-nginx


---
# nginx ingress
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: b-ingress-service
  namespace: default
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  rules:
    - host: "b.stuff.mydomain.com"
      http:
        paths:
          - path: /*
            backend:
              serviceName: "myservice"
              servicePort: 80
---
-- rix
kubernetes
kubernetes-ingress
nginx-ingress

0 Answers