Documentation
¶
Overview ¶
Package workload holds what the emulator gives the containers that run users' code as on GCP, GKE pods and Build steps, so that unmodified clients reach the Instance by real hostname as a service account: the metadata and registry proxies their Sidecar agents serve, the DNS answers that send Google hostnames to the Sidecar agent's :443 relay to the Google front end, and the names of the Instance CA bundle and its variables.
Index ¶
Constants ¶
const ( CABundleKey = "ca-certificates.crt" CABundleDir = "/etc/gcpemu/certs" CABundlePath = CABundleDir + "/" + CABundleKey SystemBundlePath = "/etc/ssl/certs/ca-certificates.crt" )
The Instance CA bundle in a workload container, and the system bundle it replaces.
const MetadataHostEnv = "GCE_METADATA_HOST"
MetadataHostEnv tells Google client libraries (Go, Python, Java, Node) that they run on GCE, so they use the metadata server without probing. On GCP the probe is reliable because machines report a Google DMI product name; emulated ones cannot, and a probe racing a still-starting DNS would make a process decide once and for all that it has no credentials.
Variables ¶
var CAEnvVars = []string{"SSL_CERT_FILE", "REQUESTS_CA_BUNDLE", "NODE_EXTRA_CA_CERTS"}
CAEnvVars are set to the bundle path in every workload container: Go and OpenSSL, Python requests and Node.js read them.
Functions ¶
func DNSAnswer ¶
DNSAnswer returns the names a workload's DNS relay answers with addr, where its Sidecar agent serves: metadata.google.internal, and, when the Sidecar agent relays to the Google front end, the front end's hostnames and every LOCATION-docker.pkg.dev. Other names resolve as usual.
func MetadataProxy ¶
MetadataProxy forwards metadata requests to the emulator at base/md/<caller IP>/<path>, where the caller's address picks its identity. It does not add X-Forwarded-For (the metadata server rejects requests that carry it, like GCE's) and drops Authorization.
func RegistryProxy ¶
RegistryProxy forwards registry requests to Artifact Registry at registry (host:port, plain HTTP), adding the access token token returns for the request when it carries no Authorization of its own.
Types ¶
type TokenSource ¶
type TokenSource struct {
URL string
// contains filtered or unexported fields
}
TokenSource caches the access token served as JSON at URL, as the metadata server serves it.
func (*TokenSource) Token ¶
func (t *TokenSource) Token() string
Token returns the cached token, fetching a new one shortly before it expires; "" when none can be had.