Kubernetes Alb入口控制器到内部Nginx入口

时间:2019-12-18 13:04:14

标签: kubernetes kubernetes-ingress nginx-ingress

我有一个ALB,该ALB是为* .stuff.mydomain.com上的请求配置的。然后,我希望它将请求定向到Nginx入口控制器,该控制器将路由到子域(例如a.stuff.mydomain.com和b.stuff.mydomain.com)上的特定服务。我只想要一个实际的硬件负载平衡器。

这是我拥有的配置,其结果来自kubectl。看起来不错,但是什么都没有解决,我在日志中找不到任何原因。

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
---


0 个答案:

没有答案