I have created an asp.net core api project. Created Configmaps, deployments, pods, services and deployed the same to docker-desktop (kubernetes running locally). Now how to read the configmaps env variables which are deployed on pod, in asp.net core api code?
apiVersion: v1
data:
order-view1: “{\r\n “_id”,\r\n “item”,\r\n “inventory_docs”\r\n}”
kind: ConfigMap
metadata:
creationTimestamp: “2021-11-01T10:08:03Z”
name: order-view1-configmap
namespace: default
resourceVersion: “65561”
uid: 5394785f-b9e7-4ee8-83a2-19159f5ef254
apiVersion: v1
data:
order-view2: "{\r\n “_id”,\r\n “item”,\r\n “price”,\r\n “quantity”\r\n
\ \"inventory_docs\"\r\n}"
kind: ConfigMap
metadata:
creationTimestamp: “2021-11-01T10:14:48Z”
name: order-view2-configmap
namespace: default
resourceVersion: “65846”
uid: 3c0ffa90-3879-4905-af35-2771c7a5e952
apiVersion: v1
kind: Pod
metadata:
name: configmap-example-pod
spec:
containers:
- name: dotnet-settings-container
image: 1392019/dotnet5-settings:latest
resources:
limits:
memory: "128Mi"
cpu: "500m"
command: [ "/bin/echo", "Application Type $(ORDER_VIEW1) - $(ORDER_VIEW2)" ]
env:
- name: ORDER_VIEW1
valueFrom:
configMapKeyRef:
name: order-view1-configmap
key: order-view1
- name: ORDER_VIEW2
valueFrom:
configMapKeyRef:
name: order-view2-configmap
key: order-view2
restartPolicy: Never
apiVersion: apps/v1
kind: Deployment
metadata:
name: dotnet-settings-deployment
spec:
selector:
matchLabels:
app: dotnet-settings
template:
metadata:
labels:
app: dotnet-settings
spec:
containers:
- name: dotnet-settings-container
image: 1392019/dotnet5-settings:latest
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
name: dotnet-settings-service
spec:
selector:
app: dotnet-settings
type: LoadBalancer
ports: