Skip to content

Instantly share code, notes, and snippets.

@magickatt
Created August 6, 2020 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magickatt/6eeafd1d3f93c67b27a7b8d6e94cc7d1 to your computer and use it in GitHub Desktop.
Save magickatt/6eeafd1d3f93c67b27a7b8d6e94cc7d1 to your computer and use it in GitHub Desktop.
Expose Kubernetes Pod UID as an environment variable to a container
apiVersion: v1
kind: Pod
metadata:
name: example-uid
spec:
containers:
- name: test
image: busybox
command: ["/bin/sh", "echo", "$EXAMPLE_UID"]
env:
- name: EXAMPLE_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
@alupuleasa
Copy link

Hello, do you know how to expose k8s.cluster.name as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment