I have created a vpc-native cluster and I am trying to connect from a pod inside the cluster to a postgres SQL instance with a private IP.
I am testing using a basic telnet 5432 command.
The connection works fine when I try it from a GCE instance that is in the same VPC. All connectivity tests in GCP are giving me green light so it seems to be a k8s issue.
Here is my cluster:
gcloud container clusters create alex-test \
--network=factory-vpc \
--region=europe-west1 \
--enable-ip-alias \
--subnetwork=europe-west1-factory-subnet \
--cluster-ipv4-cidr="/16" \
--services-ipv4-cidr="/20"
Here is how I am testing the connectivity:
kubectl run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox sh
telnet <private ip> 5432
Here is my network config in terraform:
resource "google_compute_network" "factory" {
name = "factory-vpc"
auto_create_subnetworks = false
depends_on = [google_project_service.compute]
}
resource "google_compute_subnetwork" "factory_subnet" {
name = "${var.region}-factory-subnet"
ip_cidr_range = "10.0.0.0/16"
region = var.region
network = google_compute_network.factory.self_link
private_ip_google_access = true
secondary_ip_range {
ip_cidr_range = "10.2.0.0/16"
range_name = "pods"
}
secondary_ip_range {
ip_cidr_range = "10.3.0.0/16"
range_name = "services"
}
}
resource "google_compute_global_address" "gitlab_google_private_peering" {
provider = google-beta
name = "gitlab-gcp-private"
address_type = "INTERNAL"
purpose = "VPC_PEERING"
network = google_compute_network.factory.self_link
prefix_length = 16
}
resource "google_service_networking_connection" "gitlab_google_private_peering" {
provider = google-beta
network = google_compute_network.factory.self_link
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.gitlab_google_private_peering.name]
}
I have already checked the following documentation and articles, but nothing helps:
Any help is greatly appreciated !