I am looking for something equivalent to SPRING_APPLICATION_JSON env variable of Docker Compose in Kubernetes Deployment yaml.
I am aware of that we can pass individual config as name-value pair. But there must be something through which all env variables can be passed in json or yaml format in Kubernetes.
You can use the following command:
kubectl create cm env --from-file=SPRING_APPLICATION_JSON=./<your-json>.json
You can do that using ConfigMap. For example, create a configmap:
kind: ConfigMap
apiVersion: v1
metadata:
name: appconfig
data:
ENV_KEY1: val1
ENV_KEY2: val2
Then in your deployment container, use
spec:
containers:
- image: <image>
name: <name>
envFrom:
- configMapRef:
name: appconfig