Home > Blockchain >  Angular pod healthy but bad gateway (502) , how to debug further?
Angular pod healthy but bad gateway (502) , how to debug further?

Time:01-15

I have started a pod with an angular app in it and it is healthy with no errors when I do kubectl describe pod.

However, when I curl to ingress route I get a 502 bad gateway.

I tried exec into angular pod and do a curl localhost:4200 and I get: Failed to connect to localhost port 4200: Connection refused.

Weirdly enough when i do kubectl logs podname I see nothing and I thought I always see something here, not sure.

Question now is, do I have overlooked something?

  • How do I check if angular app is working inside the pod?
  • What is the location of the logfile you see normally when you npm start an app?

I havent posted any yaml files, because I think the problem lies with the angular app itself (the curl localhost:4200 hinted me to that).

CodePudding user response:

your container configuration is not set up correctly to start the service?

you have a config like:

apiVersion: v1
kind: Pod
metadata:
  name: my-angular-app
spec:
  containers:
  - name: my-angular-app
    image: nginx:latest
    ports:
    - containerPort: 80

it should also have an command like command: ["nginx", "-g", "daemon off;"] to actually start the service.

if it does, then you have logs indicating if it is starting and the current description should indicate the correct port:

You can check the logs at the container level by using kubectl logs -f podname -c containername to see if there are any errors or issues that are preventing the app from starting

You can check the port by running kubectl describe pod podname and looking at the "Containers" section.

CodePudding user response:

This could be caused by a variety of things. Generally around the container networking/ports/services.

  1. Investigate your Dockerfile source code. Does it run a process to expose your application and on what port.

  2. If you can exec inside a running container...Find the active process exposing and port of your application. netstat is a useful tool for this: netstat -pant will list processes and their ports.

  3. Does the port number correspond to that defined in your deployment/service/ingress yaml

  4. Does the service name defined in the ingress match an actual service. If possible you could look at the ingress logs to see more information about the 502. It would probably say if it can't find an upstream service name.

  5. Describe your service associated with your application, does it list active endpoints.

Hopefully that points you in right direction.

  • Related