Skip to content

Instantly share code, notes, and snippets.

@zarelit
Created April 5, 2024 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zarelit/d08ad9d3d064cf6122eb4508f1a46945 to your computer and use it in GitHub Desktop.
Save zarelit/d08ad9d3d064cf6122eb4508f1a46945 to your computer and use it in GitHub Desktop.
Simple example of a Deployment with an env based on the namespace
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: downward-test
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
envFrom:
- configMapRef:
name: my-configmap
env:
- name: DAT_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: TEST_URL
value: "https://$(DAT_NAMESPACE)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment