1

I have a Django web application that can display forecasts graphs using the machine learning library Sktime and the library plotly for graphs. It runs fine on my local machine. However, when I run it on Kubernetes it doesn't load. The web page just stays forever loading. I have tried changing my yaml's resource files by increasing CPU and memory to 2000m and 1000mi, respectively. Unfortunately that does not fix the problems. Right now the way I run my application is by using the minikube command: minikube service --url mywebsite. I don't know whether its the proper way to start my application. Does anyone know?

Service + Deployment YAML:

apiVersion: v1
kind: Service
metadata:
  name: mywebsite
spec:
  type: LoadBalancer
  selector:
    app: mywebsite
  ports:
  - protocol: TCP
    name: http
    port: 8743
    targetPort: 8000
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mywebsite
spec:
  selector:
    matchLabels:
      app: mywebsite
  template:
    metadata:
      labels:
        app: mywebsite
    spec:
      containers:
      - name: mywebsite
        image: mywebsite
        imagePullPolicy: Never
        ports:
        - containerPort: 8000
        resources:
          requests:
            cpu: 200m
            memory: 100Mi
          limits:
            memory: "1Gi"
            cpu: "200m"
Mikolaj S.
  • 2,850
  • 1
  • 5
  • 17
  • Did you test your container image in containerization platform (not in Kubernetes) for example in Docker? Was it working properly? Did you try [`minikube tunnel` command](https://minikube.sigs.k8s.io/docs/handbook/accessing/#using-minikube-tunnel)? Is your service and deployment running? (`kubect get services` and `kubectl get deploy`)? Which OS are you using - Linux, Mac, Windows? Could you share you image or post a link for image with the same issue so your [problem will be reproducible](https://stackoverflow.com/help/minimal-reproducible-example)? – Mikolaj S. Nov 02 '21 at 13:44

1 Answers1

0

Posted answer with general solution as there are no further details / logs provided.


According to the official minikube documentation for accessing apps minikube supports both NodePort and LoadBalancer services:

There are two major categories of services in Kubernetes: NodePort and LoadBalancer

For accessing NodePort service you should use minikube service --url <service-name> command - check this.

For accessing LoadBalancer service you should use minikube tunnel command - check this.

As LoadBalancer type is also exposing NodePort, it should work with a minikube service command as you tried. I installed a minikube with Docker driver. I created a sample deployment, then I created a sample LoadBalancer service for this deployment. After that I ran minikube service --url <my-service> - On the output, I got address like:

http://192.168.49.2:30711

30711 is a node port. It's working fine when I try to access this address.

Why doesn't it work for you? Some possible reasons:

  • You are not using Linux - on the other OSes, there are some limitations for Minikube - i.e check this answer for Mac. Also it depends which minikube driver you are using.
  • Your pods are not running - you can check this with kubectl get pods command
  • You specified wrong ports in the definitions
  • Something is wrong with your image

Also check the "Troubleshooting" section on the minikube website.

Mikolaj S.
  • 2,850
  • 1
  • 5
  • 17