kubernetes set env variable

3/22/2021

My requirement is inside pod there is a file location : /mnt/secrets-store/environment

In kubernetes manifest file i would like to set environment variable . Values contains above location flat file

pls share your thought how to achieve that

I have tried below option in the k8s yml file but not working

apiVersion: apps/v1
kind: Deployment
metadata:
  name: sample-api
  namespace: dev
spec:
  replicas: 3
  selector:
    matchLabels:
      app: sample-api 
  template:
    metadata:
      labels:
        app: sample-api
        aadpodidbinding: azure-pod-identity-binding-selector        
    spec:
      containers:
      - name: sample-api
        image: sample.azurecr.io/sample:11129
        imagePullPolicy: Always
        ports:
        - containerPort: 80
        env:
        - name: "ASPNETCORE_ENVIRONMENT"
          value: "Kubernetes"
        - name: NRIA_DISPLAY_NAME
          value: $("/usr/bin/cat" "/mnt/secrets-store/environment")
-- newbee
environment-variables
kubernetes

0 Answers