首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Kubernetes nginx入口找不到后端服务

Kubernetes nginx入口找不到后端服务
EN

Stack Overflow用户
提问于 2021-12-21 19:58:09
回答 1查看 253关注 0票数 0

我已经通过本地机器的kubectl命令将API部署到AKS上的Kubernetes。但是,nginx入口无法解析后端端点。入口日志有一个错误The service 'hello-world/filter-api' does not have any active endpoint

步骤如下:

在AKS上安装dapr

  • dapr init -k -集global.tag=1.1.2

在AKS上安装nginx入口

应用清单

  • 库贝克尔应用-f .\services\filter.yaml

我试了什么?

  • 验证选择器和标签
  • 遵循提到的麻烦事步骤

我尝试将其部署到带有docker桌面的windows上的本地Kubernetes集群中。这个很好用。我遗漏了什么?

filter.yaml

代码语言:javascript
运行
复制
kind: ConfigMap
apiVersion: v1
metadata:
  name: filter-cm
  namespace: hello-world
  labels:
    app: hello-world
    service: filter
data:
  ASPNETCORE_ENVIRONMENT: Development
  ASPNETCORE_URLS: http://0.0.0.0:80
  PATH_BASE: /filter
  PORT: "80"

---

kind: Deployment
apiVersion: apps/v1
metadata:
  name: filter
  namespace: hello-world
  labels:
    app: hello-world
    service: filter
spec:
  replicas: 1
  selector:
    matchLabels:
      service: filter
  template:
    metadata:
      labels:
        app: hello-world
        service: filter
      annotations:
        dapr.io/enabled: "true"
        dapr.io/app-id: "filter-api"
        dapr.io/app-port: "80"
        dapr.io/config: "dapr-config"
    spec:
      containers:
        - name: filter-api
          image: client/hello-world-filter-api:0.0.1
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              protocol: TCP
          envFrom:
            - configMapRef:
                name: filter-cm
      imagePullSecrets:
        - name: regcred

---

apiVersion: v1
kind: Service
metadata:
  name: filter-api
  namespace: hello-world
  labels:
    app: hello-world
    service: filter
spec:
  type: NodePort
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30001
      protocol: TCP
      name: http
  selector:
    service: filter

---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: filter-ingress
  namespace: hello-world
  labels:
    app: hello-world
    service: filter
spec:
  rules:
  - http:
      paths:
      - path: /filter
        pathType: Prefix
        backend:
          service:
            name: filter-api
            port:
              number: 80
EN

回答 1

Stack Overflow用户

发布于 2022-06-16 10:56:57

在服务选择器中,对服务使用matchLabels查找后端荚。

示例:

代码语言:javascript
运行
复制
selector:
   matchLabels:
     service: filter
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70440965

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档