<p>The following link <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/private-clusters" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/how-to/private-clusters</a> talks about the setting up of a private GKE cluster in a separate custom VPC. The Terraform code that creates the cluster and VPCs are available from <a href="https://github.com/rajtmana/gcp-terraform/blob/master/k8s-cluster/main.tf" rel="nofollow noreferrer">https://github.com/rajtmana/gcp-terraform/blob/master/k8s-cluster/main.tf</a> Cluster creation completed and I wanted to use some kubectl commands from the Google Cloud Shell. I used the following commands</p>

<pre><code>$ gcloud container clusters get-credentials mservice-dev-cluster --region europe-west2
$ gcloud container clusters update mservice-dev-cluster \
&gt;     --region europe-west2 \
&gt;     --enable-master-authorized-networks \
&gt;     --master-authorized-networks "35.241.216.229/32"
Updating mservice-dev-cluster...done.
ERROR: (gcloud.container.clusters.update) Operation [&lt;Operation
clusterConditions: []
detail: u'Patch failed'

$ gcloud container clusters update mservice-dev-cluster \
&gt;     --region europe-west2 \
&gt;     --enable-master-authorized-networks \
&gt;     --master-authorized-networks "172.17.0.2/32"
Updating mservice-dev-cluster...done.
Updated [https://container.googleapis.com/v1/projects/protean- 
XXXX/zones/europe-west2/clusters/mservice-dev-cluster].
To inspect the contents of your cluster, go to: 
https://console.cloud.google.com/kubernetes/workload_/gcloud/europe- 
west2/mservice-dev-cluster?project=protean-XXXX

$ kubectl config current-context
gke_protean-XXXX_europe-west2_mservice-dev-cluster

$ kubectl get services
Unable to connect to the server: dial tcp 172.16.0.2:443: i/o timeout
</code></pre>

<p>When I give the public IP of the Cloud Shell, it says that public IP is not allowed with error message given above. If I give the internal IP of Cloud Shell starting with 172, the connection is timing out as well. Any thoughts? Appreciate the help.</p>

R Thottuvaikkatumana
<p>Google suggest creating a VM within the same network as the cluster and then accessing that via SSH in the cloud shell and running kubectl commands from there: 
<a href="https://cloud.google.com/solutions/creating-kubernetes-engine-private-clusters-with-net-proxies" rel="nofollow noreferrer">https://cloud.google.com/solutions/creating-kubernetes-engine-private-clusters-with-net-proxies</a></p>
