-
-
Save gemmadlou/6262c824ee868c417ea88bfceee64f7d to your computer and use it in GitHub Desktop.
Using Kubernetes envFrom for environment variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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