Set environment variables in Pod
When you create a Pod, you can set environment variables for the containers that run in the Pod. To set environment variables, including the env or envFrom field in the configuration file. In your shell, run the printenv command to list the environment variables. To exit the shell, run exit command.
Below is the example of the YAML file in which we are setting up environment Name and city
apiVersion: v1 kind: Pod metadata: name: myfirstpod labels: label1: harshal label2: gaurav label3: saurav spec: containers: - name: firstcontainer image: coolgourav147/nginx-custom env: - name: myname value: Gaurav - name: city value: Jaipur
to run the YAML file use the below command
kubectl apply -f yamlFileName