Connecting to a private subnet from a GCP service - google-cloud-platform

I am trying to reach a server in a private subnet that only has an internal IP from GCP cloud build. Is there something I need to do in order to allow traffic to be routed from google services to my private subnets or see my private DNS zones? Thanks in advance for the help!
Additional Details
I am trying to hit it via HTTP through an internal load balancer: Step #1 - "Auth to Vault": Error authenticating: Put http://10.16.6.33:8200/v1/auth/gcp/login: dial tcp 10.16.6.33:8200: i/o timeout

Google Cloud Build is a Google service located in Google controlled VPCs. Your internal load balancer is located in your VPC which Google Cloud Build cannot access.
At this time, Google Cloud does not offer a "VPC Connector" supporting Cloud Build accessing resources in your VPC using RFC 1918 private addresses.

you would have to allow your subnet to talk internal Google resources-
Go to VPC > networks > subnet > Enbale Private Google Access

Related

Can I run Cloud Run applications on a private IP (inside dedicated VPC network)?

We have an app running on cloud run and it is authenticated only from API gateway.
But still cloud run has *.run.app public domain associated with it and seems like it can still be security issue for sensitive applications which deal with PII data.
How can we run the cloud run inside private VPC network so that private IP is assigned to it?
Is this a con for cloud run over GKE in terms of private VPC network?
Cloud Run cannot have a "private" IP for your service. In general, Cloud Run will be always have its own *.run.app.
Said that what you can do is to restrict the ingress of the service but you should keep in mind that if you set the service as Private or Private + Load Balancer it will be not reachable by API Gateway but by resources in the VPC.
Of course you can set an Internal Load Balancer + MIG as a proxy + Cloud Run private ingress but this increases the configuration overhead.
I think this will change in the future since there is a Feature Request to support Internal HTTPS Load balancers + Serverless NEGs and with the ingress Internal and Cloud Load Balancing you will have a "private" IP for your service (You can ask access for the preview here).
Answering your last question Is this a con for cloud run over GKE in terms of private VPC network? This is something you should evaluate according to your requirements and in general this particular question is an opinion-based which is off-topic. Consider the facts and choose what is better for you.

with gcp vpn, can resources be accessed using interal ip addresses?

On connecting my on-prem network with GCP VPC using GCP VPN. From the on-prem network can i access the resources in GCP VPC using the internal ip address of resources.
If the answer is yes, does this apply to all VPN's in general.
I have searched this page for "internal" but found no clue - Cloud VPN overview
Yes, it's the principle of a VPN: bridge 2 networks, through the public internet, but with encrypted communication to keep the traffic secret.
Of course, there are limits and constraints: IP range overlap, routing, network announcement (BGE protocol if supported), firewalls,...
Yes you can access the GCP resources with internal IP addresses from on-premises network.
There are 4 types of private access options. These private access options can be used to allow VM instances with internal IP addresses to communicate with certain API’s and services. To choose an option that supports the APIs and services that you need to access refer to the documentation private-access-options. You can configure one or all of these options. They operate independently of each other.
4 types of private access options are:
Private google access
Private google access for on-prem hosts
Private service access
Serverless VPC access
Private google access for on-prem hosts:
Private google access for on-prem hosts used with on-prem hosts. Private Google Access for on-premises hosts is an alternative to connecting to Google APIs and services over the internet by routing traffic through a Cloud VPN tunnel or a Cloud Interconnect attachment (VLAN). Such on-prem hosts may or may not be configured with external IP addresses.You can use this option when you want to connect to Google API’s and services through VPC network. When using private google access for on-prem hosts your on-prem hosts do not need to have external IP addresses assigned to them.
For more information refer to the documentation private google access for on-premises hosts.

Secure GCP servless with IaaS appliance

Is it possible to access GCP PaaS (App Engine , Cloud Function, Cloud Run) internally (throught VPC)
I see in this doc : https://cloud.google.com/vpc/docs/configure-serverless-vpc-access
"Serverless VPC Access only allows requests to be initiated by the serverless environment. Requests initiated by a VM must use the external address of your serverless service—see Private Google Access for more information."
But searching for something like "Serverless VPC Access allows in/out requests"
You have 2 ways: in and out
Request TO serverless APP
You can use ingress control with Cloud Functions and Cloud Run services. You can say: I want that only connections from my VPC (or VPC SC perimeter) access to my serverless APP. With App Engine, you have firewall rules but doesn't work with private IP.
Request FROM serverless APP
Here you want to reach private resource exposed only on your VPC with a private IP. And with Cloud Run, Cloud Functions and App Engine, you can plug a serverless VPC connector to achieve this.
EDIT 1
With your appliance firewall deployed on Google Cloud, App Engine isn't the perfect product for this. Indeed, with App Engine you can't control the ingress traffic, and you always accept the traffic from the internet, even if you have a stuff (here your appliance) already on Google Cloud Network with a private IP.
The solution here (to test, depends on the appliance capacity) is to use Cloud NAT and to route all the traffic of the subnet on which the appliance is deployed, and to use a reserved static IP.
Then, on App Engine, you can set a firewall rule to accept only traffic from this reserved static IP.
The latency will increase with all these layers...

Compute Engine in VPC can't connect to Internet & Cloud Storage after establishing Cloud VPN

Assuming I have a custom VPC with IP ranges 10.148.0.0/20
This custom VPC has firewall rules to allow-internal so the service inside those IP ranges can communicate to each other.
After the system grows I need to connect to some on-premises network by using Classic Cloud VPN, already create Cloud VPN (the on-premises side configuration already configured by someone) and the VPN Tunnel already established (with green checkmarks).
I also can ping to on-premises IP right now (let's say ping to 10.xxx.xxx.xxx where this is not GCP internal/private IP but on-premises private IP) using compute engine created on custom VPC network.
The problem is all the compute engine instance spawn in custom VPC network can't communicate to the internet now (like doing sudo apt update) or even communicate to google cloud storage (using gsutil), but they can communicate using private IP.
I also can't spawn dataproc cluster on that custom VPC (I guess because it can't connect to GCS, since dataproc needs GCS for staging buckets).
Since I do not really know about networking stuff and relatively new to GCP, how to be able to connect to the internet on instances that I created inside custom VPC?
After checking more in-depth about my custom VPC and Cloud VPN I realize there's misconfiguration when I establish the Cloud VPN, I've chosen route-based in routing option and input 0.0.0.0/0 in Remote network IP ranges. I guess this routes sending all traffic to VPN as #John Hanley said.
Solved it by using policy-based in routing option and only add specific IP in Remote network IP ranges.
Thank you #John Hanley and
#guillaume blaquiere for pointing this out

Connecting VPC to Cloud SQL

I am trying to connect a VPC with GKE to a Cloud SQL database.
I have specified a VPC with the following details:
IP ranges gateway
10.240.0.0/24 10.240.0.1
I see that all my GKE services are in 10.39.xxx.xx
NAME CLUSTER_IP
service/kubernetes 10.39.240.1 ....
service/api 10.39.xxx.xx
service/web 10.39.xxx.xx
I don't actually understand the connection with the VPC here. I want to have the GKE cluster able to communicate with a Cloud SQL database without exposing it over the public internet.
I have a Cloud SQL db on public IP, say, 36.241.123.123 with a private IP equal to 10.7.224.3.
In SQL - Connections I check the private IP box and given the choice between default and dev-vpc which is the name of my VPC, I select dev-vpc.
According to https://cloud.google.com/sql/docs/mysql/configure-private-ip I should be done now, but I am unable to connect to the Cloud SQL from my GKE cluster.
I do see the following message when selecting the private IP.
Private IP connectivity requires additional APIs and permissions. You may need to contact your organisation's administrator for help enabling or using this feature. Currently, Private IP cannot be disabled once it has been enabled.
I also have a VPC peering connection
Peering connection details
imported routes
10.7.224.0/24 [ the Cloud SQL internal IP is in this ]
exported routes
10.240.0.0/24 [ the VPC subrange ]
What am I missing?
The GKE cluster needs to be on the same VPC in order to have access to other services on that Private IP. This means you have to create a VPC-native cluster.
If you created your cluster before Cloud SQL had support for private IP, you need to recreate your cluster, I'm not sure why but most of the changes involving networking in GCP you have to recreate your cluster.