<p>So I was going to set up a GKE cluster and interact it with <code>kubectl</code>. But when I tried to apply the namespace, it just threw an error.</p>
<p>I've added my IP to Control plane authorized networks in GKE dashboard.</p>
<p>I'm using a Windows 10 machine, my kube/config</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: [REDACTED]
    server: https://34.66.200.196
  name: gke_project-307907_us-central1_test
contexts:
- context:
    cluster: gke_project-307907_us-central1_test
    user: gke_project-307907_us-central1_test
  name: gke_project-307907_us-central1_test
current-context: gke_project-307907_us-central1_test
kind: Config
preferences: {}
users:
- name: gke_project-307907_us-central1_test
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      command: gke-gcloud-auth-plugin.exe
      installHint: Install gke-gcloud-auth-plugin for use with kubectl by following
        https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
      provideClusterInfo: true
</code></pre>
<p>I tried to apply namespace but,</p>
<pre class="lang-bash prettyprint-override"><code>╰─ kubectl apply -f k8s/canary/namespace.yaml
Unable to connect to the server: dial tcp 34.66.200.196:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
</code></pre>

<strong>Looks kubectl lost connection to the Cluster and you can set the Cluster context by following the official GCP troubleshooting doc&nbsp;<a href="https://cloud.google.com/kubernetes-engine/docs/troubleshooting#kubectl-times-out" rel="nofollow noreferrer">GCP kubectl command times out</a>, try below two solutions :</strong></p>
<strong>Solutions 1 : When kubectl cannot communicate with the cluster control plane or doesn't exist:</strong></p>
<blockquote>
<p>To resolve your issue, verify the context were the cluster is set:</p>
<p>Go to <code>$HOME/.kube/config</code> or run the command <code>kubectl config view</code> to
verify the config file contains the cluster context and the external
IP address of the control plane (Check there is a possibility that the
server mentioned was old or not reachable).</p>
<p>Set the cluster credentials:</p>
<pre><code>    gcloud container clusters get-credentials CLUSTER_NAME \
            --region=COMPUTE_REGION \
            --project=PROJECT_ID
</code></pre>
<p><strong>Note :</strong> For zonal clusters, use <code>--zone=COMPUTE_ZONE</code></p>
</blockquote>
<p>Above command will automatically update the default cluster for kubectl. In case you don’t know the correct cluster name and zone, use <code>gcloud container clusters list</code>. After completing the above steps, please try to create the namespace again and let me know the outcome.</p>
<p><strong>Solution 2 : Source IP is not allowed on the &quot;<code>Control plane authorized networks</code>&quot; - cluster config :</strong></p>
<blockquote>
<p>If the cluster is a private GKE cluster, then ensure that the outgoing
IP of the machine you are attempting to connect from is included in
the list of existing authorized networks.</p>
<p>You can find your existing authorized networks by running the
following command:</p>
<pre><code>  gcloud container clusters describe  \
    --region= --project= \
    --format &quot;flattened(masterAuthorizedNetworksConfig.cidrBlocks[])&quot;
</code></pre>
</blockquote>
<p>In GKE, there is a feature called &quot;<code>Control plane authorized networks</code>&quot;. The main purpose of this parameter is to allow the user to specify CIDR ranges and allow IP addresses in those ranges to <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept#overview" rel="nofollow noreferrer">access GKE cluster endpoints</a>.</p>
<p>You can also use the GCP console to check the allowed IP CIDR in the &quot;<code>Control plane authorized networks</code>&quot; from the GKE cluster details.</p>
<p><strong>Other Scenarios :</strong></p>
<p><strong>a.</strong> For other common reasons refer to <strong>Uli Köhler’s</strong> blog on <strong>Techover flow</strong> <a href="https://techoverflow.net/2019/04/01/how-to-fix-kubectl-unable-to-connect-to-the-server-dial-tcp-443-i-o-timeout/" rel="nofollow noreferrer">How to fix kubectl Unable to connect to the server: dial tcp …:443: i/o timeout</a>.</p>
<p><strong>b.</strong> Check If you're using docker's default bridge network as your GKE endpoint, disable the bridge network to avoid the network conflict.</p>
<p><strong>c.</strong> Also, check if there are recent updates in <strong>Windows/Docker</strong>. Refer to <strong>Dzmitry Paulouski’s</strong> answer <a href="https://stackoverflow.com/questions/68954948/kubernetes-on-windows-error-unable-to-connect-to-the-server-dial-tcp-some-ip">Kubernetes on Windows Error: Unable to connect to the server: dial tcp</a>, which may help to resolve your issue.</p>
<p><strong>d.</strong> If the issue with the config file, restarts the Docker Desktop restores with the new config file by adding/replacing it in your <code>HOME/.kube / config file</code>.</p>
