This tutorial shows you how to solve kubernetes error “The connection to the server localhost:8080 was refused – did you specify the right host or port?” while running kubectl or helm commands.
Solve: Connection to the server localhost:8080 was refused
To solve the connection refused error the following are the steps that I have followed.
1. Create a Kubernetes Cluster
You can create a single zone cluster either using gcloud or on Google Cloud Console. Before you begin ensure you have enabled the Google Kubernetes Engine API and installed Cloud SDK. Then setup default gcloud settings following this tutorial.
I had created Kubernetes cluster through console. You can choose “Standard cluster” template option, then provide name (prototype-cluster) and hit “create” button.
2. Connect to the cluster
Once the Kubernetes cluster is created successfully as shown above, then hit “Connect” button, which would ask you to run the following command to configure kubectl command line access, so that you could connect to the cluster.
$ gcloud container clusters get-credentials prototype-cluster --zone us-central1-a --project sneppets-gcp Fetching cluster endpoint and auth data. kubeconfig entry generated for geprototype-cluster.
Now try runnning any kubectl or helm commands, the error should have gone away!
$ helm init Creating /home/sneppets/.helm Creating /home/sneppets/.helm/repository Creating /home/sneppets/.helm/repository/cache Creating /home/sneppets/.helm/repository/local Creating /home/sneppets/.helm/plugins Creating /home/sneppets/.helm/starters Creating /home/sneppets/.helm/cache/archive Creating /home/sneppets/.helm/repository/repositories.yaml Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com Adding local repo with URL: http://127.0.0.1:8879/charts $HELM_HOME has been configured at /home/sneppets/.helm. Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster. Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy. To prevent this, run `helm init` with the --tiller-tls-verify flag. For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
- Where the Docker images are stored locally?
- Terraform tutorial
- How to check docker image contents after you pull a docker image
- Java 8 : Find union and intersection of two Lists (ArrayLists)