开发者社区> 问答> 正文

Kubernetes Nginx Ingress找不到服务端点

我在使用Nuberx入口控制器在我的Kubernetes集群中工作时遇到了一些麻烦。我根据https://kubernetes.github.io/ingress-nginx/deploy/创建了nginx-ingress部署,服务,角色等。

我还部署了一个hello-world监听端口的简单应用程序8080

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 secret(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入口控制器使用了类似的服务定义,没有任何问题。

展开
收起
k8s小能手 2019-01-09 14:36:49 8990 0
1 条回答
写回答
取消 提交回答
  • 整合最优质的专家资源和技术资料,问答解疑

    在我的应用程序定义中,name用作我的选择器

    selector:

    matchLabels:
      name: hello-world

    template:

    metadata:
      labels:
        name: hello-world

    而在我的服务中,我正在使用 app

    selector:

    app: hello-world

    更新我的服务后使用app,它工作

    selector:

    matchLabels:
      app: hello-world

    template:

    metadata:
      labels:
        app: hello-world
    2019-07-17 23:25:01
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载

相关镜像