-
Notifications
You must be signed in to change notification settings - Fork 40
defining configmap/secret data in a way that auto-creates the container env vars #2
Comments
if folks wanted to work with multiple configmaps/secrets and want to make the exposing as env vars more container specific they could maybe do this kinda thing, nesting them inside the container... name: foo
replicas: 1
containers:
- name: wordpress
image: wordpress:4
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 120
timeoutSeconds: 5
envConfig:
- data:
WORDPRESS_DB_HOST: "database:3306"
envSecret:
- data:
WORDPRESS_DB_PASSWORD: something
- name: database
image: postgres
envConfig:
- data:
WORDPRESS_DB_NAME: foo
MYSQL_USER: myuser
services:
- ports:
- port: 8080
targetPort: 80
expose: true where the configmaps / secrets would be generated using |
I guess for files there's 2 separate concerns; importing data from local files; then mounting configmap/secret entries as volumes. I guess you can always do an explicit mount of the latter; but it might be nice to have some kinds of mounts within the envConfig / envSecret? |
another implementation idea is that we keep the definitions of configmaps / secrets as top level things; then we have a way to import env vars inside the container structs; using wildcards? name: web
replicas: 1
containers:
- image: wordpress:4
envValuesFrom:
- kind: Secret
imports:
- FOO_BAR
- WHATNOT_*
- kind: ConfigMap
name: cheese
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 120
timeoutSeconds: 5
services:
- ports:
- port: 8080
targetPort: 80
expose: true
secrets:
- name: wordpress
data:
WORDPRESS_DB_PASSWORD: something
configs:
- name: database
data:
WORDPRESS_DB_NAME: foo
MYSQL_USER: myuser
files:
cheese: ../foo/bar.txt
- name: web
data:
WORDPRESS_DB_HOST: "database:3306" whats kinda nice about the import approach is we can more easily do container specific imports with wildcards; we can default the name of the configmap/secret to the app name too to make things more concise. e.g. when there's only 1 name: web
replicas: 1
containers:
- image: wordpress:4
envValuesFrom:
- kind: Secret
imports:
- FOO_BAR
- WHATNOT_*
- kind: ConfigMap
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 120
timeoutSeconds: 5
services:
- ports:
- port: 8080
targetPort: 80
expose: true
secrets:
- data:
WORDPRESS_DB_PASSWORD: something
configs:
- data:
WORDPRESS_DB_HOST: "database:3306"
WORDPRESS_DB_NAME: foo
MYSQL_USER: myuser
files:
cheese: ../foo/bar.txt with an optional |
I wonder if merging the name: web
replicas: 1
containers:
- image: wordpress:4
envValuesFromSecrets:
- imports:
- *
envValuesFromConfigMaps:
- imports:
- *
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 120
timeoutSeconds: 5
services:
- ports:
- port: 8080
targetPort: 80
expose: true
secrets:
- data:
WORDPRESS_DB_PASSWORD: something
configs:
- data:
WORDPRESS_DB_HOST: "database:3306"
WORDPRESS_DB_NAME: foo
MYSQL_USER: myuser
files:
cheese: ../foo/bar.txt or name: web
replicas: 1
containers:
- image: wordpress:4
envValuesFromSecrets:
- name: database
envValuesFromConfigMaps:
- name: database:
- name: wordpress
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 120
timeoutSeconds: 5
services:
- ports:
- port: 8080
targetPort: 80
expose: true
secrets:
- data:
WORDPRESS_DB_PASSWORD: something
configs:
- data:
WORDPRESS_DB_HOST: "database:3306"
WORDPRESS_DB_NAME: foo
MYSQL_USER: myuser
files:
cheese: ../foo/bar.txt |
About the root level I am okay with populating
I like this idea of allowing users to specify a relative path to embed files and when converting we embed the file content in the
this will create secrets and configmaps which are container specific, here how do we enable someone else to use the secret defined here? For e.g. the
I think envConfig:
- data:
WORDPRESS_DB_NAME: foo
MYSQL_USER: myuser
files:
application.properties: target/classes/application.properties
mountPath: /foo/bar
why do we need to have wildcards when |
Yes I think so we can close this one! |
so defining configmaps and exposing them as env vars is very painful. e.g. this:
we could use magic character prefixes on env vars like
$FOO
or/bar
for files. Maybe separate nested structs could help; as they can also let us define multiple secrets/configmaps too. e.g. here's one way of doing the above:where we use
envConfig
to specify environment variables which populate a ConfigMap and dittoenvSecret
for secrets.Note that in the case where there's 1 ConfigMap and 1 Secret it looks like:
also since we have nested structs for the secret / config map data we can also add an extra map for
files
The text was updated successfully, but these errors were encountered: