<p>This is my first time of setting up Kubernetes on Google Cloud Platform.</p>
<p><strong>These are the steps I followed</strong>:</p>
<p>I created an account on <strong>Google Cloud Platform</strong> and spun up a new instance:</p>
<pre><code>https://console.cloud.google.com/compute
</code></pre>
<p>Installed the gcloud SDK:</p>
<pre><code>curl https://sdk.cloud.google.com | bash
</code></pre>
<p>Configured my Google Cloud Platform account information</p>
<pre><code>gcloud auth login
</code></pre>
<p>Installed the latest verion of Kubernetes</p>
<pre><code>curl -sS https://get.k8s.io | bash
</code></pre>
<p>Launched a new cluster:</p>
<pre><code>kubernetes/cluster/kube-up.sh
</code></pre>
<p>Confirmed that my configuration along with the cluster management credentials are stored in:</p>
<pre><code>sudo nano /home/promisepreston/.kube/config
</code></pre>
<p>Installed kubectl on the server</p>
<pre><code>curl -LO &quot;https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl&quot;
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
</code></pre>
<p>Ran the command below which outputted the URL for the master services including DNS, UI, and monitoring</p>
<pre><code>kubectl cluster-info
</code></pre>
<p>Deployed the Dashboard UI by running the following command:</p>
<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
</code></pre>
<p>And finally, I tried accessing the Dashboard by running the following command:</p>
<pre><code>kubectl proxy
</code></pre>
<p>Which should make the Dashboard available at:</p>
<pre><code>http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
</code></pre>
<p>However, when I visit that URL I get error:</p>
<pre><code>Unable to connect
</code></pre>
<p>And even when I try the command below:</p>
<pre><code>curl http://localhost:8001/api
</code></pre>
<p>I get the error below:</p>
<pre><code>curl: (7) Failed to connect to localhost port 8001: Connection refused
</code></pre>
<p>I have looked through a lot of documentation and tried multiple solutions, but none seems to work for me.</p>

Promise Preston
<blockquote>
<p>Installed kubectl on the server</p>
</blockquote>
<p>You need <code>kubectl</code> on machine, from which you're going to access your cluster. If you installed it on the server and you ran <code>kubectl proxy</code> on the server - then you can access the proxy only from your server (depends on your network config).</p>
<p>If you do <code>curl http://localhost:8001/api</code> on the server - it will work.</p>
<p>So, you need to install <code>kubectl</code> on your machine, set up the k8s context for it and then run <code>kubectl proxy</code> - after that, all requests to proxy will be forwarded to your cluster.</p>
<p>In each request to k8s <code>API server</code> you need to be authenticated, when you run <code>kubectl proxy</code> - basically proxy will take care of authentication and SSL/TLS related stuff.</p>
<p>Read this for more info: <a href="https://kubernetes.io/docs/tasks/extend-kubernetes/http-proxy-access-api/" rel="nofollow noreferrer">Use an HTTP Proxy to Access the Kubernetes API</a>
and <a href="https://kubernetes.io/docs/concepts/overview/kubernetes-api/" rel="nofollow noreferrer">The Kubernetes API</a></p>
<p><a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/" rel="nofollow noreferrer">Configure Access to Multiple Clusters</a> - may also be useful</p>
<p><strong>Basically you need to do the following</strong>:</p>
<p><strong>Note</strong>: These should be done directly on your local machine, and not on the server or the terminal connecting to the server, but directly on your local machine:</p>
<p>Install the gcloud SDK:</p>
<pre><code># Add the Cloud SDK distribution URI as a package source
echo &quot;deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main&quot; | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

# Import the Google Cloud public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

# Update the package list and install the Cloud SDK
sudo apt-get update &amp;&amp; sudo apt-get install google-cloud-sdk
</code></pre>
<p>Configure your Google Cloud Platform account information:</p>
<pre><code>gcloud auth login
</code></pre>
<p>Install Kubectl the Kubernetes command line tool:</p>
<pre><code>curl -LO &quot;https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl&quot;
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
</code></pre>
<p>Install Minikube that will be using to install Kubernetes on your local machine:</p>
<pre><code>curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb

sudo dpkg -i minikube_latest_amd64.deb
</code></pre>
<p>Start Minikube to pull the latest image of Kubenetes on your local system and configure it with Kubectl:</p>
<pre><code>minikube start
</code></pre>
<p>If you already have some clusters set up, you can now use it to access your shiny new cluster:</p>
<pre><code>kubectl get po -A
</code></pre>
<p>Minikube bundles the Kubernetes Dashboard, allowing you to get easily acclimated to your new environment:</p>
<pre><code>minikube dashboard
</code></pre>
