code: def image_id_from_k8s():
      
      token_path = "/var/run/secrets/kubernetes.io/serviceaccount/token"
      if os.path.exists(token_path):
          k8s_server = "https://{}:{}/api/v1/namespaces/default/pods/{}".format(
              os.getenv("KUBERNETES_SERVICE_HOST"), os.getenv(
                  "KUBERNETES_PORT_443_TCP_PORT"), os.getenv("HOSTNAME")
          )
          try:
              res = requests.get(k8s_server, verify="/var/run/secrets/kubernetes.io/serviceaccount/ca.crt",
                                 timeout=3, headers={"Authorization": "Bearer {}".format(open(token_path).read())})
              res.raise_for_status()
          except requests.RequestException:
              return None
          try:
              return res.json()["status"]["containerStatuses"][0]["imageID"].strip("docker-pullable://")
          except (ValueError, KeyError, IndexError):
              logger.exception("Error checking kubernetes for image id")
              return None
docs: Pings the k8s metadata service for the image id