[英]AWS ALB Ingress Controller and ingress resource for python app
我已经按照此链接https://kubernetes.io/blog/2019/07/23/get-started-with-kubernetes-using-python/创建了 python 应用程序。 我想配置AWS ALB Ingress Controller/nginx controller
和ingress resource
但我无法理解该文件。 我没有在 ec2-instance 上使用 Kops 的域,想在没有任何域的情况下配置它。 任何帮助,将不胜感激。
部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-python
spec:
selector:
matchLabels:
app: hello-python
template:
metadata:
labels:
app: hello-python
spec:
containers:
- name: hello-python
image: hello-python:latest
ports:
- containerPort: 5000
服务
apiVersion: v1
kind: Service
metadata:
name: hello-python-service
spec:
selector:
app: hello-python
type: NodePort
ports:
- nodePort: 30010
port: 6000
targetPort: 5000
Ingress 通过 nginx 入口控制器将上面的hello-python-service
类的 Service 绑定到 ALB。
它通过将虚拟主机映射到您的服务来实现,以便 nginx 知道如何路由请求。
例子:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: python-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: ingress-controller-nginx
nginx.ingress.kubernetes.io/default-backend: hello-python-service
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: python.trash.net
http:
paths:
- path: /?(.*)
backend:
serviceName: hello-python-service
servicePort: 6000
将生成类Ingress
的资源,如下所示:
python-ingress python.trash.net internal-0358a08f01385b2812-331143124.us-east-2.elb.amazonaws.com 80 10s
发出这样的 curl 请求:
curl -H "Host: python.trash.net" http://internal-0358a08f01385b2812-331143124.us-east-2.elb.amazonaws.com
应该让你从你的 hello python 应用程序得到响应。
这显然取决于您是否在 EKS 集群中部署和配置了 nginx 入口控制器。
入口的关键要点是:它取代了对 LoadBalancer 类型的专用服务的需求,以提供对您的服务的外部访问。 相反,Ingress 通过在 Ingress 的清单文件中配置的虚拟主机将来自集群外部的流量映射到集群中的服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.