code: def get_k8s_metadata():
      
      k8s_metadata = {}
  
      gcp_cluster = (gcp_metadata_config.GcpMetadataConfig
                     .get_attribute(gcp_metadata_config.CLUSTER_NAME_KEY))
      if gcp_cluster is not None:
          k8s_metadata[CLUSTER_NAME_KEY] = gcp_cluster
  
      for attribute_key, attribute_env in _K8S_ENV_ATTRIBUTES.items():
          attribute_value = os.environ.get(attribute_env)
          if attribute_value is not None:
              k8s_metadata[attribute_key] = attribute_value
  
      return k8s_metadata
docs: Get kubernetes container metadata, as on GCP GKE.