Home > other >  .Net Core API container on Minikube not running
.Net Core API container on Minikube not running

Time:09-30

I have a deployment on Minikube for a .Net Core 5 API that is not returning response when I try to invoke it from Postman. When I run a GET from Postman to the exposed port(32580) and endpoint http:// localhost:32580/api/platforms/ I get Error: getaddrinfo ENOTFOUND. Oddly enough I was previously getting a Connection refused (before I restarted my Docker desktop). The container works perfectly when I use Docker but once I deployed it to Kubernetes context it no longer works.

I am unsure how exactly I can debug the container and get more meaningful error detail.

I have tried the following :

1)Checking status of Deployment (platforms-depl)

NAME             READY   UP-TO-DATE   AVAILABLE   AGE 
hello-minikube   1/1     1            1           134d
ping-google      0/1     1            0           2d2h
platforms-depl   1/1     1            1           115m

2)Checking status of Pod (platforms-depl-84d7f5bdc6-sgxcp)

NAME                              READY   STATUS             RESTARTS   AGE 
hello-minikube-6ddfcc9757-6mfmf   1/1     Running            21         134d
ping-google-5f84d66fcc-kbb7j      0/1     ImagePullBackOff   151        2d2h
platforms-depl-84d7f5bdc6-sgxcp   1/1     Running            1          115m

3)Running kubectl describe pod platforms-depl-84d7f5bdc6-sgxcp gives below output (truncated) :

Status:       Running
IP:           172.17.0.3
IPs:
  IP:           172.17.0.3
Controlled By:  ReplicaSet/platforms-depl-84d7f5bdc6
Containers:
  platformservice:
    Container ID:   docker://a73ce2dc737206e502df94066247299a6dcb6a038087d0f42ffc6e3b9dd194dd
    Image:          golide/platformservice:latest
    Image ID:       docker-pullable://golide/platformservice@sha256:bbed5f1d7238d2c466a6782333f8512d2e464f94aa64d8670214646a81b616c7      
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Tue, 28 Sep 2021 15:12:22  0200
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-rl5kf (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True

4)When I run docker ps I cannot see the container and it also doesnt appear in the list of running containers in VS Code Docker/Containers extension.

5)kubectl get services gives me the following :

NAME                    TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE 
hello-minikube          NodePort    10.99.23.44    <none>        8080:31378/TCP   134d
kubernetes              ClusterIP   10.96.0.1      <none>        443/TCP          134d
paymentsapi             NodePort    10.111.243.3   <none>        5000:30385/TCP   108d
platformnpservice-srv   NodePort    10.98.131.95   <none>        80:32580/TCP     2d2h

then tried pinging the ClusterIP

Pinging 10.98.131.95 with 32 bytes of data:
Request timed out.
Request timed out.
 
Ping statistics for 10.98.131.95:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), 

What am I missing ?

I read in suggestions I have to exec into the pod so that I get meaningful output but Im not sure of the exact commands to run , I tried :

kubectl exec POD -p platforms-depl-84d7f5bdc6-sgxcp

only to get error : kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. Error from server (NotFound): pods "POD" not found

My environment Docker Linux containers with WSL2 on Windows 10.

What am I missing ?

CodePudding user response:

First thing which is worth to note that generally minikube has a lot of possible drivers to choose from - in my case I found the docker drive to be most easiest to use.

My setup is:

I used following command to start minikube: minikube start --driver=docker. If you are using other driver I suggest moving to the docker one.

Answering your question:

What am I missing ?

By setting nodePort service type you are exposing your deployment / replica set using node IP address which not accessible from Windows host (when using docker driver). It's because all Kubernetes cluster resources are setup inside Docker container, which is isolated.

However, minikube offers simple solution to make available specified nodePort service to your Windows host. Just run minikube service command which will create a tunnel. Let's check it.

You setup platformnpservice-srv service so you need to use this name in minikube service command instead of testmini which I used:

minikube service --url testmini
           
  • Related