Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution for configmap --from-file #232

Open
hubert-wojtowicz opened this issue Oct 30, 2021 · 1 comment
Open

Solution for configmap --from-file #232

hubert-wojtowicz opened this issue Oct 30, 2021 · 1 comment

Comments

@hubert-wojtowicz
Copy link

hubert-wojtowicz commented Oct 30, 2021

Data for config.txt did not create correct key-value pairs according to the provided solution.
solution number 3 here

image

image

image

@syaffers
Copy link
Contributor

There's a difference in the options --from-file and --from-env-file.

According to https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-configmap-em-

Name Shorthand Default Usage
...
from-env-file Specify the path to a file to read lines of key=val pairs to create a configmap (i.e., a Docker .env file).
from-file [] Key file can be specified using its file path, in which case file basename will be used as configmap key, or optionally with a key and file path, in which case the given key will be used. Specifying a directory will iterate each named file in the directory whose basename is a valid configmap key.
...

So if you pass a file to the --from-file option, the ConfigMap key will contain the contents of the file itself, newlines and all. With --from-env-file, if your file is structured as

key1=val1
key2=val2

it will read these as KV pairs into

{
  "key1": "val1",
  "key2": "val2"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants