Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
224 views
in Technique[技术] by (71.8m points)

kubernetes - Microk8s ingress - defaultBackend

inside my ingress config i changed default backend.

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

When I describe ingress i have got

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

I trying to access it via localhost and i have got 404. However when i curl 10.1.173.59, i have got my static page. So my navigation-service its ok and something is wrong with defaultbacked? Even if i trying

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

I have got 500 error. What im doing wrong?

Edit: Works via NodePort but I need to access it via ingress.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If someone have this problem then you need to run ingress controller with args - --default-backend-service=namespace/service_name


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...