我在我的Kubernetes集群中使用 Nginx Ingress Controller 遇到了些问题。根据 https://kubernetes.github.io/ingress-nginx/deploy/ 的指南创建了nginx-ingress的部署、服务和角色等。同时我还部署了一个简单的监听端口为
8080
的hello-world
应用。apiVersion: apps/v1
kind: DaemonSet
metadata:
name: hello-world
namespace: default
spec:
selector:
matchLabels:
name: hello-world
template:
metadata:
labels:
name: hello-world
spec:
containers:
- name: hello-world
image: myrepo/hello-world
resources:
requests:
memory: 200Mi
cpu: 150m
limits:
cpu: 300m
ports:
- name: http
containerPort: 8080
protocol: TCP
并为其创建了一个服务
kind: Service
apiVersion: v1
metadata:
namespace: default
name: hello-world
spec:
selector:
app: hello-world
ports:
- name: server
port: 8080
最后,按照说明创建了一个TLS密钥(my-tls-secret
)并部署了nginx入口。例如:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: hello-world
namespace: default
spec:
rules:
- host: hello-world.mydomain.com
http:
paths:
- path: /
backend:
serviceName: hello-world
servicePort: server
tls:
- hosts:
- hello-world.mydomain.com
secretName: my-tls-cert
然而,我无法访问我的应用程序,并且在日志中看到以下信息:
W0103 19:11:15.712062 6 controller.go:826] Service "default/hello-world" does not have any active Endpoint.
I0103 19:11:15.712254 6 controller.go:172] Configuration changes detected, backend reload required.
I0103 19:11:15.864774 6 controller.go:190] Backend successfully reloaded.
我不确定为什么它会显示 Service "default/hello-world" does not have any active Endpoint
。我已经使用类似的服务定义用于 traefik ingress 控制器,没有遇到任何问题。
希望我在 nginx ingress 中漏掉了一些显而易见的地方。非常感谢您能提供任何帮助!