Kubernetes Ingress deployment not loading properly on bare metal

10/4/2021

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 <script> 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?

-- Denn
kubernetes
nginx-ingress
openmaptiles
reactjs

0 Answers