我是K8S的新手,所以请温柔一点。我有一个测试hello world Flask应用程序,我想在EKS上部署它。我正在使用AWS负载平衡控制器插件使用下面的链接。最后,当我检查部署时,它显示没有任何问题,如链接所述。https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html
当我应用下面的三个文件时,它们都正确应用,我看到pod up,但在入口上我没有看到外部IP地址,无法访问我的Flask应用程序。
我的目标是让AWS创建一个虚拟DNS名称,然后我可以将我的公共DNS名称作为CNAM条目指向它。此外,入口应该在端口80,然后应该转发到端口5000 Flask应用程序内部。
我错过了什么?有人能告诉我正确的方向吗?
ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: "flask-test-ingress"
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
labels:
app: hello-world
spec:
rules:
- host: testing.somesite.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: "hello-world-service"
port:
number: 80
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
selector:
matchLabels:
app: hello-world
replicas: 2
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: gitlab.privaterepo.com:5050/jmartinez/flask_helloworld:v4
ports:
- containerPort: 5000
protocol: TCP
imagePullSecrets:
- name: regcred
service.yaml
apiVersion: v1
kind: Service
metadata:
name: hello-world-service
spec:
selector:
app: hello-world
type: NodePort
ports:
- protocol: "TCP"
port: 80
targetPort: 5000
nodePort: 30000
终于修好了。当我意识到ALB不是自动创建时,我研究并找到了解决方案。我必须从注释中删除ingress.class值并删除主机。现在我的入口如下所示。在删除旧入口并重新应用这个入口后,我等了大约10分钟,我的hello world应用程序现在正在运行。
ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: "flask-test-ingress"
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
labels:
app: hello-world
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: "hello-world-service"
port:
number: 80