class Google::Cloud::Env

def kubernetes_engine_namespace_id

Returns:
  • (String, nil) -
def kubernetes_engine_namespace_id
  # The Kubernetes namespace is difficult to obtain without help from
  # the application using the Downward API. The environment variable
  # below is set in some older versions of GKE, and the file below is
  # present in Kubernetes as of version 1.9, but it is possible that
  # alternatives will need to be found in the future.
  variables["GKE_NAMESPACE_ID"] ||
    file_system.read("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
end