Share via

Received invalid status code: 404 in the backend server’s HTTP response.

Abdullah 1 Reputation point
2022-01-30T17:36:14.503+00:00

I had configured an azure application gateway with ingress controller and everything looks good i.e

  1. Workload is running
  2. Service is running
  3. Ingress resource deployed

below is the image of 'Backed health'

169665-image.png

Service status

169673-image.png

Ingress status
169550-image.png

Pods status
169653-image.png

Below the are yaml snippets used for pods, ingress, service deployment

apiVersion: apps/v1
kind: Deployment
metadata:
name: apiservice-deployment
labels:
app: apiservice
spec:
replicas: 1
selector:
matchLabels:
app: apiservice
template:
metadata:
labels:
app: apiservice
spec:
containers:

  • name: apiservice
    image: "{{ .Values.image.repository }}:{{ .Values.image.tag}}"
    ports:
  • containerPort: 8080
    protocol: TCP

apiVersion: v1
kind: Service
metadata:
name: apiservice-service
spec:
ports:

  • port: 80
    targetPort: 8080
    protocol: TCP
    name: http
    selector:
    app: apiservice
    type: ClusterIP

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: apiservice-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
spec:
rules:

  • http:
    paths:
  • path: /
    backend:
    service:
    name: apiservice-service
    port:
    number: 80
    pathType: Prefix

Pods, service and ingress showing as green status but Gateways says 'All the instances in one or more backend pool is unhealthy', I can see the below is the backend pool

169674-image.png

I am not able to figure our why I am getting the error "502 Bad Gateway" when I am trying to access the app via the public IP "http://20.85.243.181/",
Kindly suggest if I am doing something wrong

Azure Kubernetes Service
Azure Kubernetes Service

An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.

0 comments No comments

1 answer

Sort by: Most helpful
  1. shiva patpi 13,396 Reputation points Microsoft Employee Moderator
    2022-01-30T19:09:33.67+00:00

    Hello @Abdullah ,
    Tried applying the exact YAML files and I can repro the issue.
    After changing below values in YAML files - I can see backend is Healthy in AppGW
    containerPort : 80 in Deployment YAML file
    targetPort: 80 in Service YAML file
    Ingress Port: 80

    Please try out those changes from your end.

    If it helps , I tried below YAML file locally:

    169675-image.png

    Regards,
    Shiva.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.