Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes: Can not curl minikube pod

What happened: I have been following this guidelines: https://kubernetes.io/docs/setup/minikube/ and I have the "connection refused" issue when trying to curl the application. Here are the steps I did

~~> minikube status
minikube: Stopped
cluster: 
kubectl: 
~~> minikube start
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.
~~> kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=9500
deployment.apps/hello-minikube created
~~> kubectl expose deployment hello-minikube --type=NodePort
service/hello-minikube exposed
~~> kubectl get pod
NAME                              READY     STATUS    RESTARTS   AGE
hello-minikube-79577c5997-24gt8   1/1       Running   0          39s
~~> curl $(minikube service hello-minikube --url)
curl: (7) Failed to connect to 192.168.99.100 port 31779: Connection refused

What I expect to happen: When I curl the pod, it should give a proper reply (like in the quickstart: https://kubernetes.io/docs/setup/minikube/)

minikube logs: https://docs.google.com/document/d/1o2-ebiZTsoCzQNSn_rQSkcuVzOJABmwT2KKzGoUQNiQ/edit

like image 791
Developer Avatar asked Sep 12 '18 07:09

Developer


People also ask

How do you curl a Kubernetes pod?

Create a new Pod that runs curl To do that, I use the kubectl run command, which creates a single Pod. Kubernetes will now pull the curlimages/curl image, start the Pod, and drop you into a terminal session. So now you can use curl! Make sure you run curl in the same Kubernetes namespace which you want to debug.

How do I access minikube pods?

Create a Service. By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster. To make the hello-node Container accessible from outside the Kubernetes virtual network, you have to expose the Pod as a Kubernetes Service.

Is minikube a Kubernet?

Minikube is a lightweight Kubernetes implementation that creates a VM on your local machine and deploys a simple cluster containing only one node. Minikube is available for Linux, macOS, and Windows systems.

Can I use kubectl with minikube?

You can use the kubectl command to deploy a test application to your Minikube cluster.


1 Answers

Not sure where you got the port 9500 from but that's the reason it doesn't work. NGINX serves on port 8080. This should work (it does for me, at least):

$ kubectl expose deployment hello-minikube \
          --type=NodePort \
          --port=8080 --target-port=8080


$ curl $(minikube service hello-minikube --url)

Hostname: hello-minikube-79577c5997-tf49z

Pod Information:
        -no pod information available-

Server values:
        server_version=nginx: 1.13.3 - lua: 10008

Request Information:
        client_address=172.17.0.1
        method=GET
        real path=/
        query=
        request_version=1.1
        request_scheme=http
        request_uri=http://192.168.64.11:8080/

Request Headers:
        accept=*/*
        host=192.168.64.11:32141
        user-agent=curl/7.54.0

Request Body:
        -no body in request-
like image 182
Michael Hausenblas Avatar answered Oct 10 '22 00:10

Michael Hausenblas