【发布时间】:2019-09-12 00:56:17
【问题描述】:
我有一个 eks 集群,我的部署、服务和 loadBalancer 都工作正常。每个服务创建自己的 LoadBalancer,所有服务都启动并运行。我有一个前端服务和 2 个后端服务 这是我的部署和入口文件
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apache-kubernetes
spec:
replicas: 2
selector:
matchLabels:
app: apache-kubernetes
template:
metadata:
labels:
app: apache-kubernetes
spec:
containers:
- name: apache-kubernetes
image: httpd
ports:
- containerPort: 80
env:
- name: MESSAGE
value: Hello Kubernetes!
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hello-apache-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: apache.example.com
- http:
paths:
- path: /
backend:
serviceName: apache-kubernetes
servicePort: 80
我有一个类似的部署和服务 yaml 文件,它部署并创建了一个 nginx Web 服务器。我还运行了以下命令 所有部署都需要以下强制命令。
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
和
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud-generic.yaml
如该网址中所述https://kubernetes.github.io/ingress-nginx/deploy/#aws
然后我运行这两个命令
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/aws/service-l4.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/aws/patch-configmap-l4.yaml
我运行kubectl get all,我看到我的 pod、replicatsets 和部署运行良好,
kubectl get ingress shows
hosts ADDRESS
apache.example.com 216990309c-1626238635.us-east-2.elb.amazonaws.com
nginx.example.com 216990309c-1626238635.us-east-2.elb.amazonaws.com
我期待当我点击 apache.example.com 时——它应该显示“它有效”
并且 Nginx.example.com 应该显示“欢迎 Nginx”
我这样做对吗
浏览器 ==>ALB==>ingresscontroller==>ekscluster
更新 1
当我点击 url 时,我得到 503,但 pod 正在运行
kubectl -n ingress-nginx 记录 nginx-ingress-controller-db5f9d7b5-cwwh2
给我
6 controller.go:781] Error obtaining Endpoints for Service "default/hello-kubernetes": no object matching key "default/hello-kubernetes" in local store
W0911 23:43:02.505451 6 controller.go:781] Error obtaining Endpoints for Service "default/nginx-kubernetes": no object matching key "default/nginx-kubernetes" in local store
W0911 23:43:20.846517 6 controller.go:781] Error obtaining Endpoints for Service "default/hello-kubernetes": no object matching key "default/hello-kubernetes" in local store
W0911 23:43:20.846540 6 controller.go:781] Error obtaining Endpoints for Service "default/nginx-kubernetes": no object matching key "default/nginx-kubernetes" in local store
【问题讨论】:
-
尝试更新您的问题并使其更加清晰。谢谢。
-
您未能指定当您点击这些网址时会发生什么;也就是说,入口控制器是基于虚拟主机的,所以你需要类似于
curl -v -H "host: apache.example.com" http://216990309c-1626238635.us-east-2.elb.amazonaws.com的东西(或者,当然,有 DNS 条目,但我的意思是仅用于测试) -
@Yasen 不清楚哪一部分,我会尽量具体一点
标签: kubernetes nginx-ingress amazon-eks