简体   繁体   English

使用 aws alb 入口控制器在 kubernetes pod 中公开服务

[英]Exposing service in kubernetes pods with aws alb ingress controller

I am new to k8s and exploring more on production grade deployment.我是 k8s 的新手,正在探索更多关于生产级部署的信息。 We have py Django app which is running in (say in 9000) node port.我们有 py Django 应用程序,它在(例如 9000)节点端口中运行。 When I try to expose them using a k8s-service ELB, - it works by running 80 and 443 separately;当我尝试使用 k8s-service ELB 公开它们时,它通过分别运行 80 和 443 来工作; where as 80 to 443 redirection is not supported in AWS classic ELB.其中 AWS 经典 ELB 不支持 80 到 443 重定向。

Then I switched to aws alb ingress controller;然后我切换到 aws alb 入口控制器; the problem i faced was - ALB does not works with node port and only with http and https port.我面临的问题是 - ALB 不适用于节点端口,仅适用于 http 和 https 端口。

Any thoughts would be much appreciated!!任何想法将不胜感激!

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ABC
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/target-type: instance
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/subnets: 'subnet-1, subnet-2'
    alb.ingress.kubernetes.io/security-group: sg-ABC
    alb.ingress.kubernetes.io/healthcheck-path: "/"
    alb.ingress.kubernetes.io/success-codes: "200"
  labels:
    name: ABC
spec:
  rules:
    - http:
        paths:
         - path: /
           backend:
             serviceName: ABC
             servicePort: 80 ```

Thank you @sulabh and @Fahri it works perfect now.谢谢@sulabh 和@Fahri,它现在完美无缺。 I went through the doc again and corrected my mistake.我再次阅读了文档并纠正了我的错误。

Issues was with route path in ALb;问题在于 ALb 中的路由路径;

Setup is like;设置就像;

python-django-uwsgi app in pods and expose it as service in NodePort and use aws ingress controller for ALB; pods 中的 python-django-uwsgi 应用程序,并将其公开为 NodePort 中的服务,并为 ALB 使用 aws 入口控制器;

Cheers!干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM