【发布时间】:2019-10-21 18:33:07
【问题描述】:
我有一个我想要的 EKS 集群: - 每个集群 1 个负载均衡器, - 指向正确命名空间和正确服务的入口规则。
我的部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
namespace: default
spec:
replicas: 3
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: IMAGENAME
ports:
- containerPort: 8000
name: hello-world
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: bleble
namespace: default
spec:
replicas: 3
selector:
matchLabels:
app: bleble
template:
metadata:
labels:
app: bleble
spec:
containers:
- name: bleble
image: IMAGENAME
ports:
- containerPort: 8000
name: bleble
这些部署的服务:
apiVersion: v1
kind: Service
metadata:
name: hello-world-svc
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8000
selector:
app: hello-world
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
name: bleble-svc
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8000
selector:
app: bleble
type: NodePort
我的负载均衡器:
kind: Service
apiVersion: v1
metadata:
name: ingress-nginx
namespace: ingress-nginx
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
externalTrafficPolicy: Local
type: LoadBalancer
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
ports:
- name: http
port: 80
targetPort: http
我的入口:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: simple-fanout-example
namespace : default
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: internal-lb.aws.com
http:
paths:
- path: /bleble
backend:
serviceName: bleble-svc
servicePort: 80
- path: /hello-world
backend:
serviceName: hello-world-svc
servicePort: 80
我已经用这个设置了 Nginx 入口控制器:kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.24.1/deploy/mandatory.yaml
我不确定为什么我得到一个服务暂时不可用的 503 服务和另一个服务的一个 502...我猜这是端口或命名空间的问题?在指南中,他们没有为部署定义命名空间...
每个资源都可以正确创建,我认为入口实际上是在工作,但对去哪里感到困惑。
感谢您的帮助!
【问题讨论】:
-
我尝试在我的 LB 中使用“Cluster”而不是“Local”,它返回 400 Not found
-
你用什么命令来查询你的服务?
-
@Fei 到底是哪个服务?
-
你提到你得到 503 / 502。你是怎么得到的?通过浏览器/Curl/其他命令?
-
哦,我是通过浏览 lb 地址 + /nameservice 得到的。我和 curl 一样
标签: kubernetes kubernetes-ingress nginx-ingress amazon-eks