Skip to content

Instantly share code, notes, and snippets.

@jhidalgo3
Forked from troyharvey/deployment.yml
Created July 9, 2020 14:13
Show Gist options
  • Save jhidalgo3/ec3bf68cc404c846cc22fa6baf358926 to your computer and use it in GitHub Desktop.
Save jhidalgo3/ec3bf68cc404c846cc22fa6baf358926 to your computer and use it in GitHub Desktop.
Using Kubernetes envFrom for environment variables
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1
selector:
matchLabels:
app: mans-not-hot
template:
metadata:
labels:
app: mans-not-hot
spec:
containers:
- name: app
image: gcr.io/mans-not-hot/app:bed1f9d4
imagePullPolicy: Always
ports:
- containerPort: 80
envFrom:
- configMapRef:
name: env-configmap
- secretRef:
name: env-secrets
# Use config map for not-secret configuration data
apiVersion: v1
kind: ConfigMap
metadata:
name: env-configmap
data:
APP_NAME: Mans Not Hot
APP_ENV: production
# Use secrets for things which are actually secret like API keys, credentials, etc
# Base64 encode the values stored in a Kubernetes Secret: $ pbpaste | base64 | pbcopy
# The --decode flag is convenient: $ pbpaste | base64 --decode
apiVersion: v1
kind: Secret
metadata:
name: env-secrets
type: Opaque
data:
DB_PASSWORD: cDZbUGVXeU5e0ZW
REDIS_PASSWORD: AAZbUGVXeU5e0ZB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment