Denn
Denn

Reputation: 487

Kubernetes Ingress deployment not loading properly on bare metal

I have deployed a nginx ingress in my baremetal k8s cluster - using metallb. Previously I did it with the

apiVersion: networking.k8s.io/v1beta1

tag and it worked fine. However, that tag is no longer supported so I'm using

apiVersion: networking.k8s.io/v1

I have 2 frontends both in react and several backends like 7 of them.

I have 2 issues:

  1. How do I deploy the two react frontends with default path "/" Since I need to use the react-router? N/B They both have "/", "/login". "/logout" ... paths, It is hosted locally so no hostname.. my yaml file looks like this:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web1-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web1-service
            port:
              number: 4000

---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web2-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web2-service
            port:
              number: 5000

If I ran this only one will work and is very slow, perhaps because queries go to both backends or something .. How do I solve this?

  1. One of my backend is a maptiler.. It does not load correctly i.e running it outside the cluster it loads the css and files properly but when adding it to the cluster, it has errors The unexpected '<' is for the tag in the container.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-map
  annotations:
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /styles/*
        pathType: Exact
        backend:
          service:
            name: map-service 
            port: 
              number: 7000
  ingressClassName: nginx

Is there something with the order?

Upvotes: 0

Views: 1563

Answers (1)

a_poluyanov
a_poluyanov

Reputation: 11

check if you are using the correct syntax, I had the following error and met this same problem. I wrote like this:

...
    ingressClassName: nginx
    rules:
    - host: test.webapi-auth.mpbr.renola.ru
    - http:
        paths:
        - backend:
            service:
              name: service1
              port:
                number: 80
          path: /(.*)
          pathType: Prefix
...

but it needed to be:

...
    ingressClassName: nginx
    rules:
    - host: test.webapi-auth.mpbr.renola.ru
      http:
        paths:
        - backend:
            service:
              name: service1
              port:
                number: 80
          path: /(.*)
          pathType: Prefix
...

note that there should not be a "-" character before http

Upvotes: 1

Related Questions