Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate ConfigMap from directory without create it?

Tags:

kubernetes

How can I generate ConfigMap from directory without create it?

If I use:

$ kubectl create configmap my-config --from-file=configuration/ -o yaml
apiVersion: v1
   data:
...

ConfigMap yaml output is displayed but my-config is created on current Kubernetes project context.

I would like only generate ConfigMap file, it is possible? Are there a kubectl create "dry" mode?

Best regards,
Stéphane

like image 933
Stéphane Klein Avatar asked Mar 15 '17 13:03

Stéphane Klein


People also ask

How do I create a config map from a file?

You can use kubectl create configmap to create a ConfigMap from multiple files in the same directory. When you are creating a ConfigMap based on a directory, kubectl identifies files whose basename is a valid key in the directory and packages each of those files into the new ConfigMap.

How do I create a ConfigMap from Yaml file in Kubernetes?

The simplest way to create a ConfigMap is to store a bunch of key-value strings in a ConfigMap YAML file and inject them as environment variables into your Pods. After that, you can reference the environment variables in your applications using whatever methods is necessary for your programming language.

Which of these commands can be used to create ConfigMaps?

You can use the kubectl create configmap command to create configmaps easily from literal values, files, or directories.


1 Answers

Just add --dry-run so:

$ kubectl create configmap my-config --from-file=configuration/ -o yaml --dry-run

Source: https://kubernetes.io/docs/user-guide/kubectl/kubectl_create_configmap/

like image 128
Janos Lenart Avatar answered Oct 24 '22 16:10

Janos Lenart