Unable to access the GCP metadata server from a pod

Solution In Progress - Updated -

Issue

  • The Google metadata server is not accessible from within a pod:

    $ oc rsh $POD curl -s "http://metadata.google.internal/computeMetadata/v1/instance/zone" -H "Metadata-Flavor: Google"
    command terminated with exit code 7
    
  • Running the same command from the node or a pod with hostNetwork: true works:

    $ oc debug node/${NODE} -- curl -s "http://metadata.google.internal/computeMetadata/v1/instance/zone" -H "Metadata-Flavor: Google"
    Starting pod/pbertera-03285776-s9fkd-worker-a-x77wx-debug ...
    To use host binaries, run `chroot /host`
    projects/123456789/zones/europe-west3-a
    Removing debug pod ...
    

Environment

  • Red Hat OpenShift Container Platform
  • Google Cloud Platform

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content