Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud Scheduler can't use internal DNS?

I have a cloud scheduler task that runs monthly to kick off some automation.  It use to hit a cloud function, now it directly sends an HTTP request to a compute instance running some expressJs custom code.  Lets call the compute instance vm1.  When I use the IP address (ephemeral) in the HTTP request it works just fine... but when that VM gets cycled its a new IP (duh). When I use the internal DNS vm1.c.PROJECT_ID.internal or vm1.ZONE.c.PROJECT_ID.internal it just fails.  The log is not helpful but the server isn't hit so I assume it's a DNS issue (isn't it always DNS?)

I may settle on using an instance schedule to start the VM a bit before it's needed, then a cron job in the VM itself, then schedule the instance stop... but I REALLY want cloud scheduler to understand internal DNS.

0 1 747
1 REPLY 1

Hi @ivanlawrence ,

Based from this issue that you have described, it looks like you're dealing problems with Cloud Scheduler and the internal DNS resolution.

You may consider the following workarounds:

a. If the VM is in a different network or subnet, consider using a VPN or Interconnect to connect the networks. This way, you can use the internal IP directly.

b. As you mentioned, you can schedule the VM to start a bit before it's needed using instance scheduling. This way, you give the VM enough time to boot up and ensure it's accessible when Cloud Scheduler triggers the job.

c. Deploy an Internal Load Balancer in front of your compute instance. This way, you can assign a static internal IP address to the ILB, and the ILB will route the traffic to the correct backend instance. This approach allows you to use a consistent internal IP address regardless of VM cycling.

Top Solution Authors