0

I'm using kubernet to deploy my application: Here's my service description:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: flaskgql
  labels:
    name: flaskgql
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: flaskgql
    spec:
      containers:
      - name: flaskgql
        image: cryptodraco/flask_gql
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
        volumeMounts:
          - name: secrets
            mountPath: /etc/secrets
            readOnly: true
      volumes:
      - name: secrets
        secret:
          secretName: db-passwords
---

apiVersion: v1
kind: Service
metadata:
  name: flaskgql
  labels:
    name: flaskgql
spec:
  type: LoadBalancer
  #loadBalancerIP: 35.189.238.42
  ports:
  - port: 80
    targetPort: 8080
  selector:
    name: flaskgql

When I list my services, everythings is fine:

flaskgql  LoadBalancer   10.59.251.206   35.189.238.42   80:30677/TCP   6m

And my docker file is as follow:

FROM gcr.io/google_appengine/python

RUN virtualenv /env

# source venv/bin/activate
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

# no database - SQL only
#ENV NODB 1

ADD . /app

CMD gunicorn -b :$PORT wsgi:app

But when I try to access my assigned static ip, it is not working. Note: I have already done the same thing before and it was ok. But now when I access the static ip, I get a 404error. Seems like my gunicorn server is not port forwarded to the ip. Even if from gcloud I get: enter image description here

I don't know if it is because I should stick the VM instead of the instance. But all I know is that it is not working and I have no idea how to debug that. Thanks in advance

Mr Bonjour
  • 121
  • 1
  • 1
  • 4

1 Answers1

1

To begin with, 404 not found implies that the request is making to the intended server but is unable to locate the requested file, I doubt this is an issue with the Static IP.

There are a few things you can do to debug this. The first step is to SSH into one of your nodes and try to connect to the pod directly using the cluster IP:

List your pods along with their CLuster IP

kubectl get pods -o wide

SSH into one of your cluster's nodes either through the GCP Console or using gcloud command

gcloud compute instances ssh [node_name]

Once you are connected to the node, run a curl command to see if your container is answering to requests properly

curl [pod_cluster_ip]

If this returns a 404 error message, it means that there is an issue with your container image. Either there are no files in the root of the server or the docker image has not exposed port 80.

If this test works, you know the container is serving correctly so there might be an issue with the service.

Repeat the curl test using the LB service cluster IP.

You can also attach to the pod to watch for activity

kubectl attach [pod_name] -i

Lastly, you can check the GCP Load Balancer to see if there are any reported errors there such as unhealthy backends.

I'm not as good with dockerfiles, but the k8s yaml look good

Patrick W
  • 582
  • 2
  • 8