Quick way to print environment variables of a running pod

A quick way to print the environment variables of a running pod is to use the following command.

kubectl exec <pod-name> -- env

For example, take a look at the sample nginx pod with few additional (MY_POD and PORT) environment variables.

apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- image: nginx:1.14.2
name: nginx
ports:
- containerPort: 8080
env:
- name: POD_NAME
value: "my_pod"
- name: PORT
value: "8080"

Once the pod is in running state, you can use the following command to print the environment variables of the pod.

kubectl exec my-pod -- env

You can see the output as below listing the environment variables.

screenshot showing output of the command showcasing environment variables

--

--

--

Microsoft MVP | Developer | Passionate about Cloud, .NET and DevOps

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AWS Lambda function with DynamoDB and API Gateway

Building code editor plugins — A comparison

Intro to Scratch Org Definition JSON

Accessibility on iOS: Make your app more accessible using UIScrollView

Building a health endpoint

4 Must Know Tools for Developers (2022)

A little notion about infrastructure

All of the Tech Podcasts You Should Listen To

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Utkarsh Shigihalli

Utkarsh Shigihalli

Microsoft MVP | Developer | Passionate about Cloud, .NET and DevOps

More from Medium

Manage Multiple Cron with Helm Flow Control

Understanding Kubernetes + Docker

How to build Kubernetes Operators in Go

Top 5 Tips to pass the CKAD Exam