No access to Google private cluster via master authorized networks

2/27/2019

The current setup I have:

Google Project "Test Project"
  VPC "test-vpc01"
  Subnet "test-vpc01-sub01"
    Subnet Range "10.3.1.0/24"
    Private Cluster "test-cluster"
      Master address range "10.4.1.0/28"
      Master authorized networks "10.6.1.0/28"
      Master zone "europe-west2-b"
  Subnet "test-vpc01-sub02"
    Subnet Range "10.6.1.0/24"
    Compute VM "test-vm"
      Zone "europe-west2-b"
      Internal IP "10.6.1.2"

When I try to commit a "kubectl" command I receive the following:

user@test-vm:~/.kube$ kubectl get pods -v 10
I0227 15:17:59.446195    1153 loader.go:359] Config loaded from file /home/tristan_clarke/.kube/config
I0227 15:17:59.447194    1153 loader.go:359] Config loaded from file /home/tristan_clarke/.kube/config
I0227 15:17:59.447982    1153 round_trippers.go:419] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.13.3 (linux/amd64) kubernetes/721bfa7" 'https://10.4.1.2/api?timeout=32s'
I0227 15:18:29.450476    1153 round_trippers.go:438] GET https://10.4.1.2/api?timeout=32s  in 30002 milliseconds
I0227 15:18:29.450502    1153 round_trippers.go:444] Response Headers:
I0227 15:18:29.450540    1153 cached_discovery.go:113] skipped caching discovery info due to Get https://10.4.1.2/api?timeout=32s: dial tcp 10.4.1.2:443: i/o timeout

Google documentation just informs to ensure the CIDR address is correct. Although, I'm certain that's not the issue wondering if it is possibly firewall rules/routing etc...

-- Tristan C
gke-networking
google-cloud-platform
kubernetes

2 Answers

2/27/2019

You should have a firewall rule automatically created to allow traffic. You can check the firewall rules using the next command:

gcloud compute firewall-rules list

If there is no firewall rule, you can create one manually using the the next command:

gcloud compute firewall-rules create <<NAME>> --allow all \
      --description "Allow incoming traffic" \
      --destination-ranges <<CIDR-RANGE>> \
      --destination-ranges <<CIDR-RANGE>> \
      --direction INGRESS

I wish that this can help you. :)

-- Eduardo Ruela
Source: StackOverflow

3/5/2019

You are not able to connect to a private cluster with a private endpoint from outside your vpc.

-- Tristan C
Source: StackOverflow