Home > front end >  Jenkins on docker can't reach minikube
Jenkins on docker can't reach minikube

Time:10-12

I'm running Jenkins with Docker.

I want to deploy Kubernetes resources from Jenkins on Minikube.

I'm facing an error that Jenkins cannot reach Minikube.

Error: Kubernetes cluster unreachable: Get "https://127.0.0.1:62756/version?timeout=32s": dial tcp 127.0.0.1:62756: connect: connection refused

I tried to publish the Minikube's port but still having the same error.

this is the command am using:

 docker run \
  --name jenkins-blueocean \
  --rm \
  --detach \
  --network jenkins \
  --env DOCKER_HOST=tcp://docker:2376 \
  --env DOCKER_CERT_PATH=/certs/client \
  --env DOCKER_TLS_VERIFY=1 \
  --publish 8080:8080 \
  --publish 50000:50000 \
  --publish 62756:62756 \
  --volume /Users/myuser/.kube:/var/jenkins_home/.kube \
  --volume /Users/myuser/.minikube:/Users/myuser/.minikube \
  --volume /Users/myuser/.minikube/profiles:/Users/myuser/.minikube/profiles \
  --volume /Users/myuser/.minikube/profiles/minikube:/Users/myuser/.minikube/profiles/minikube \
  --volume jenkins-data:/var/jenkins_home \
  --volume jenkins-docker-certs:/certs/client:ro \
  myjenkins-blueocean:1.1

CodePudding user response:

Minikube and docker each use separate virtual machines on macos.

You can determine the ip of the minikube machine using minikube ip and use that as kubernetes API server IP.

CodePudding user response:

If you already have a deployment, you need to expose the pod in order to access the resources in it from outside of your internal network.

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

The idea of a Service is to group a set of Pod endpoints into a single resource. You can configure various ways to access the grouping. By default, you get a stable cluster IP address that clients inside the cluster can use to contact Pods in the Service. A client sends a request to the stable IP address, and the request is routed to one of the Pods in the Service.

There are five types of Services:

  • ClusterIP (default)
  • NodePort
  • LoadBalancer
  • ExternalName
  • Headless

More information about kubernetes services in this link.

To expose your service using load balancer flag, use the kubectl expose command:

kubectl expose deployment hello-node --type=LoadBalancer --port=8080

The --type=LoadBalancer flag indicates that you want to expose your Service outside of the cluster.

If you want to take a look at the complete tutorial, follow this link

More information about Using a Service to Expose Your App here

If you want to know more about Kubernetes API Server please follow this link

And follow this link if you want to Access Clusters Using the Kubernetes API

  • Related