Add multiple environment variables from docker to kubernetes

12/18/2020

I'm a newbie regarding kubernetes. I need to 'convert' these docker commands to kubernetes so I can deploy runtime from Kubernetes to cloud.

`docker run -d -e AP_USERNAME=test1 -e AP_PASSWORD=test2 -e AP_ENVIRONMENT=test3 -e AP_ORGANIZATION="test4" -e AP_ARM_SERVER_NAME="test5" test/docker-mule:0.1`
-- Austine
cloud
docker
kubernetes

1 Answer

12/18/2020

Create a pod definition file / manifest with Environment variables in it as below and create it in k8s cluster as kubectl create -f <pod-definition-file.yaml>

apiVersion: v1
kind: Pod
metadata:
  name: docker-mule-pod
  labels:
    name: docker-mule-pod
spec:
  containers:
  - name: docker-mule-pod
    image: test/docker-mule:0.1
    env:
    - name: AP_USERNAME
      value: "test1"
    - name: AP_PASSWORD
      value: "test2"
	- name: AP_ENVIRONMENT
	  value: "test3"
	- name: AP_ORGANIZATION
	  value: "test4"
	- name: AP_ARM_SERVER_NAME
	  value: "test5"

You can also create ConfigMaps and/or Secrets which you can refer to in pod definition file.

-- Sandeep
Source: StackOverflow