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 Kube.netes 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:
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
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
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
When I run docker ps
I cannot see the container and it also doesn't appear in the list of running containers in VS Code Docker/Containers extension.
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 I'm 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?
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 Kube.netes 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
🏃 Starting tunnel for service testmini.
|-----------|----------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|----------|-------------|------------------------|
| default | testmini | | http://127.0.0.1:33849 |
|-----------|----------|-------------|------------------------|
http://127.0.0.1:33849
❗ Because you are using a Docker driver on linux, the terminal needs to be open to run it.
Note the last sentence - we need to keep this terminal window to be open, otherwise the tunnel won't be established. Now, on my Windows host, in the browser I'm opening: http://127.0.0.1:33849/api/platforms
website. The output is following:
[{"id":1,"name":"Dot Net","publisher":"Microsoft","cost":"Free"},{"id":2,"name":"Linux","publisher":"Ubuntu","cost":"Free"},{"id":3,"name":"Kubernetes","publisher":"CNCF","cost":"Free"},{"id":4,"name":"SQL Express","publisher":"Microsoft","cost":"Free"}]
Voila. Seems that everything is working properly.
Also, other notes:
tried pinging the ClusterIP
The ClusterIP is internal address which is only accessible from the cluster , so you can't ping it from Windows host neither WSL2.
kubectl exec POD -p platforms-depl-84d7f5bdc6-sgxcp
As output suggests, you need to specify command you want to exec on the pod . If you just want to get bash shell, use the following:
kubectl exec -it platforms-depl-84d7f5bdc6-sgxcp -- sh
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.