This has worked great for years, and we use it in several scripts in our workloads to pull down the stored IP.
However, once the workload is running on an Autopilot cluster, this command now returns a 404 not found.
I’m not finding anything online about this issue anywhere, and don’t know what to do to proceed. How do I get workloads on the Autopilot cluster to be able to access this information?
Any help would be greatly appreciated.
Hello,
Thank you for the reply. Much appreciated.
Yes, if I revert back to a standard cluster, it works immediately with no issues. There’s no setup or fuss, it just works.
But going back to an autopilot cluster and I get a 404 for the metadata url.
Thanks for the link on the article, I’ll read through it.
I edited my workload to have a verbose output on the curl command, and this is what it gets back:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0*
Trying 169.254.169.254…
TCP_NODELAY set
Connected to metadata.google.internal (169.254.169.254) port 80 (#0)
GET /computeMetadata/v1/project/attributes/server_ip HTTP/1.1
Host: metadata.google.internal
User-Agent: curl/7.52.1
Accept: /
Metadata-Flavor: Google
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Wed, 08 Nov 2023 21:54:49 GMT
< Content-Length: 10
<
{ [10 bytes data]
Just to clarify, did you create these VMs manually in the Compute Engine page? Or are you referring to VMs that were created when you created the cluster?
Autopilot clusters use Workload Identity (you can’t disable it) and when Workload Identity is enabled, you have access to the GKE Metadata server which only makes a subset of the metadata from the GCE Metadata server available.
Thanks for the response. However, I’m not sure what to gather from that. That resource is where I originally got the url from that I put in my post. According to that document, the Workload Identity should have access to the “Project metadata”.
you will see that only two metadata entries - project-id and numeric-project-id - are accessible through the GKE metadata server used by Workload Identity.