kuroi_karasu
kuroi_karasu

Reputation: 283

Kubernetes ingress path based working well

Hello I am new to kubernetes and i need some help.

I want use kubernetes ingress path for my 2 different nuxt project.

First / path working well but my

second /v1 path not get resources like .css and .js

My first deployment and service yaml file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-1
  labels:
    app: nginx1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx1
  template:
    metadata:
      labels:
        app: nginx1
    spec:
      containers:
      - name: nginx1
        image: st/itmr:latest  "can't show image"
        ports:
        - containerPort: 80
---

apiVersion: v1
kind: Service
metadata:
  name: nginx1-svc
spec:
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  selector:
    app: nginx1

My second deployment and service yaml file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx2
  labels:
    app: nginx2
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx2
  template:
    metadata:
      labels:
        app: nginx2
    spec:
      containers:
      - name: nginx2
        image: st/itpd:latest  "can't show image"
        ports:
        - containerPort: 8080
---

apiVersion: v1
kind: Service
metadata:
  name: nginx2-svc
spec:
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
    name: http
  selector:
    app: nginx2

And there is the my ingress yaml file:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: some.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx1-svc
            port:
              number: 80
      - path: /v1
        pathType: Prefix
        backend:
          service:
            name: nginx2-svc
            port:
              number: 8080

I tought using nginx.ingress.kubernetes.io/rewrite-target: /$1 would be work for me bu its not.

I don't know where is the problem so help me.

Upvotes: 1

Views: 168

Answers (1)

kkopczak
kkopczak

Reputation: 862

To clarify I am posting a community wiki answer.

The problem here was resolved by switching the project path.

See more about ingress paths here.

Upvotes: 1

Related Questions