繁体   English   中英

Microk8s 入口 - defaultBackend

[英]Microk8s ingress - defaultBackend

在我的入口配置中,我更改了默认后端。

spec:
  defaultBackend:
    service:
      name: navigation-service
      port:
        number: 80

当我描述入口时,我得到了

Name:             ingress-nginx
Namespace:        default
Address:          127.0.0.1
Default backend:  navigation-service:80 (10.1.173.59:80)

我试图通过 localhost 访问它,我得到了 404。但是当我 curl 10.1.173.59 时,我得到了我的 static 页面。 所以我的导航服务没问题,默认支持有什么问题吗? 即使我尝试

          - pathType: Prefix
            path: /
            backend:
              service:
                name: navigation-service
                port:
                  number: 80

我有 500 错误。 我做错了什么?

编辑:通过 NodePort 工作,但我需要通过入口访问它。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: navigation-deployment
spec:
  selector:
    matchLabels:
      app: navigation-deployment
  template:
    metadata:
      labels:
        app: navigation-deployment
    spec:
      containers:
        - name: nginx
          image: nginx:1.13.3-alpine
          ports:
            - containerPort: 80
          volumeMounts:
            - mountPath: /usr/share/nginx/html/index.html
              name: nginx-html
            - mountPath: /etc/nginx/conf.d/default.conf
              name: nginx-default
      volumes:
        - name: nginx-html
          hostPath:
            path: /home/x/navigation/index.html
        - name: nginx-default
          hostPath:
            path: /home/x/navigation/default.conf
apiVersion: v1
kind: Service
metadata:
  name: navigation-service
spec:
  type: ClusterIP
  selector:
    app: navigation-deployment
  ports:
    - name: "http"
      port: 80
      targetPort: 80

如果有人遇到这个问题,那么您需要使用 args 运行入口 controller - --default-backend-service=namespace/service_name

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM