I am Getting a bad gateway Error on my ingress nginx service

136 views Asked by At

I am getting a Bad Gateway error on accessing path from my ingress nginx host configuration

and i am not able to access /api/command.Please help me out I'm a beginner. This is my command-service deployment

kind: Deployment
metadata:
  name: command-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: commandservice
  template:
    metadata:
      labels:
        app: commandservice
    spec:
      containers:
      - name: commandservice
        image: borisningthou/commandservice:latest
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
---
apiVersion: v1
kind: Service
metadata:
  name: command-clusterip-srv
spec:
  type: ClusterIP
  selector:
    app: commandservice
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80

#kubectl rollout restart deployments command-depl

This is my platform service deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: platform-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: platformservice
  template:
    metadata:
      labels:
        app: platformservice
    spec:
      containers:
      - name: platformservice
        image: borisningthou/platformservice:latest
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
---
apiVersion: v1
kind: Service
metadata:
  name: platform-clusterip-srv
spec:
  type: ClusterIP
  selector:
    app: platformservice
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80

This is my ingress-nginx configuration

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-srv
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
    nginx.ingress.kubernetes.io/reqrite-target: /
spec:
  rules:
    - host: acme.com
      http:
        paths:
          - path: /api/platform
            pathType: Prefix
            backend:
              service:
                name: platform-clusterip-srv
                port:
                  number: 80
          - path: /api/command
            pathType: Prefix
            backend:
              service:
                name: command-clusterip-srv
                port:
                  number: 80

Please tell me to route different service using /api/myservice and how to resolve the bad gateway error

0

There are 0 answers