Can we use “data” as a yaml file instead of Json file in Config map2019 Community Moderator ElectionCan we use same Configmap for different volume mounts?config-map kubernetes multiple environmentsenvFrom configmap in Pod template of DeploymentVolume mounted configmap, by label selectorKubernetes config map symlinks (..data/) : is there a way to avoid them?Error while creating k8s secret through rest apiData is empty when accessing config file in k8s configmap with HelmError in yaml file to create Kubernetes dashboardSpring Cloud Kubernetes - Spring boot not reading config mapsharing a configmap between two charts in helmGetting a validtion error when trying to apply a Yaml file in AKS
Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?
Good allowance savings plan?
Fourth person (in Slavey language)
Why the color red for the Republican Party
Aliens englobed the Solar System: will we notice?
Do I really need to have a scientific explanation for my premise?
A question on the ultrafilter number
Time travel short story where dinosaur doesn't taste like chicken
Can Mathematica be used to create an Artistic 3D extrusion from a 2D image and wrap a line pattern around it?
Why does the negative sign arise in this thermodynamic relation?
String reversal in Python
Why would one plane in this picture not have gear down yet?
Unreachable code, but reachable with exception
Space in array system equations
PTIJ: Why can't I eat anything?
How do you like my writing?
How do I deal with a powergamer in a game full of beginners in a school club?
Why would a jet engine that runs at temps excess of 2000°C burn when it crashes?
Subset counting for even numbers
Offered promotion but I'm leaving. Should I tell?
Am I not good enough for you?
Should I take out a loan for a friend to invest on my behalf?
Why is this plane circling around the Lucknow airport every day?
Could a cubesat propel itself to Mars?
Can we use “data” as a yaml file instead of Json file in Config map
2019 Community Moderator ElectionCan we use same Configmap for different volume mounts?config-map kubernetes multiple environmentsenvFrom configmap in Pod template of DeploymentVolume mounted configmap, by label selectorKubernetes config map symlinks (..data/) : is there a way to avoid them?Error while creating k8s secret through rest apiData is empty when accessing config file in k8s configmap with HelmError in yaml file to create Kubernetes dashboardSpring Cloud Kubernetes - Spring boot not reading config mapsharing a configmap between two charts in helmGetting a validtion error when trying to apply a Yaml file in AKS
lets take this example of a config map
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |-
<yml here>
Getting an error like failed to parse yaml to Json.
kubernetes configmap
add a comment |
lets take this example of a config map
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |-
<yml here>
Getting an error like failed to parse yaml to Json.
kubernetes configmap
remove '-' from abc.yml: |- and try
– P Ekambaram
Mar 7 at 8:37
add a comment |
lets take this example of a config map
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |-
<yml here>
Getting an error like failed to parse yaml to Json.
kubernetes configmap
lets take this example of a config map
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |-
<yml here>
Getting an error like failed to parse yaml to Json.
kubernetes configmap
kubernetes configmap
edited Mar 7 at 7:52
P Ekambaram
1,277613
1,277613
asked Mar 7 at 7:48
Nancy Nancy
114
114
remove '-' from abc.yml: |- and try
– P Ekambaram
Mar 7 at 8:37
add a comment |
remove '-' from abc.yml: |- and try
– P Ekambaram
Mar 7 at 8:37
remove '-' from abc.yml: |- and try
– P Ekambaram
Mar 7 at 8:37
remove '-' from abc.yml: |- and try
– P Ekambaram
Mar 7 at 8:37
add a comment |
3 Answers
3
active
oldest
votes
Create ConfigMap
from file.
kubectl create configmap myconfig --from-file=youfile.yml
.
You can check more examples on kubernetes docs
add a comment |
These could be the problems
1. most likely the issue could with the indentation.
2. remove '-' from abc.yml: |- and check
I followed the below steps and was able to load yaml file into configmap. it worked fine.
master $ cat c.yaml
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
master $ kubectl create configmap testcfg --from-file=./c.yaml
master $ kubectl get cm testcfg -oyaml
apiVersion: v1
data:
c.yaml: |
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
kind: ConfigMap
metadata:
creationTimestamp: 2019-03-07T08:35:18Z
name: testcfg
namespace: default
resourceVersion: "7520"
selfLink: /api/v1/namespaces/default/configmaps/testcfg
uid: f033536d-40b3-11e9-a67d-0242ac11005b
apiVersion: v1 kind: ConfigMap data: abc.yml: | namespace: "a_namespace" :development: <<: *defaults deployment >> default How to make the config map read the default variables ?
– Nancy
Mar 7 at 12:25
please state clearly what exactly you are trying to achieve
– P Ekambaram
Mar 7 at 13:28
add a comment |
Yes you can do that, but you should care about the syntax. You can also follow techniques for yaml from here.
If you use kubectl create configmap myconfig --from-file=abc.yml
, then it is ok.
But if you write the whole yaml file for your configmap in myconfig.yaml and then run kubectl create -f myconfig.yaml
, then you should care about syntax.
Say your abc.yml
file is as followings:
a:
b: b1
c: c1
d: d1
Then write your myconfig.yaml
file:
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |
a:
b: b1
c: c1
d: d1
Now just run kubectl create -f myconfig.yaml
.
That's it.
Happy Kubernetes!!!.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038569%2fcan-we-use-data-as-a-yaml-file-instead-of-json-file-in-config-map%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Create ConfigMap
from file.
kubectl create configmap myconfig --from-file=youfile.yml
.
You can check more examples on kubernetes docs
add a comment |
Create ConfigMap
from file.
kubectl create configmap myconfig --from-file=youfile.yml
.
You can check more examples on kubernetes docs
add a comment |
Create ConfigMap
from file.
kubectl create configmap myconfig --from-file=youfile.yml
.
You can check more examples on kubernetes docs
Create ConfigMap
from file.
kubectl create configmap myconfig --from-file=youfile.yml
.
You can check more examples on kubernetes docs
answered Mar 7 at 8:18
VeerendraVeerendra
7161239
7161239
add a comment |
add a comment |
These could be the problems
1. most likely the issue could with the indentation.
2. remove '-' from abc.yml: |- and check
I followed the below steps and was able to load yaml file into configmap. it worked fine.
master $ cat c.yaml
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
master $ kubectl create configmap testcfg --from-file=./c.yaml
master $ kubectl get cm testcfg -oyaml
apiVersion: v1
data:
c.yaml: |
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
kind: ConfigMap
metadata:
creationTimestamp: 2019-03-07T08:35:18Z
name: testcfg
namespace: default
resourceVersion: "7520"
selfLink: /api/v1/namespaces/default/configmaps/testcfg
uid: f033536d-40b3-11e9-a67d-0242ac11005b
apiVersion: v1 kind: ConfigMap data: abc.yml: | namespace: "a_namespace" :development: <<: *defaults deployment >> default How to make the config map read the default variables ?
– Nancy
Mar 7 at 12:25
please state clearly what exactly you are trying to achieve
– P Ekambaram
Mar 7 at 13:28
add a comment |
These could be the problems
1. most likely the issue could with the indentation.
2. remove '-' from abc.yml: |- and check
I followed the below steps and was able to load yaml file into configmap. it worked fine.
master $ cat c.yaml
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
master $ kubectl create configmap testcfg --from-file=./c.yaml
master $ kubectl get cm testcfg -oyaml
apiVersion: v1
data:
c.yaml: |
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
kind: ConfigMap
metadata:
creationTimestamp: 2019-03-07T08:35:18Z
name: testcfg
namespace: default
resourceVersion: "7520"
selfLink: /api/v1/namespaces/default/configmaps/testcfg
uid: f033536d-40b3-11e9-a67d-0242ac11005b
apiVersion: v1 kind: ConfigMap data: abc.yml: | namespace: "a_namespace" :development: <<: *defaults deployment >> default How to make the config map read the default variables ?
– Nancy
Mar 7 at 12:25
please state clearly what exactly you are trying to achieve
– P Ekambaram
Mar 7 at 13:28
add a comment |
These could be the problems
1. most likely the issue could with the indentation.
2. remove '-' from abc.yml: |- and check
I followed the below steps and was able to load yaml file into configmap. it worked fine.
master $ cat c.yaml
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
master $ kubectl create configmap testcfg --from-file=./c.yaml
master $ kubectl get cm testcfg -oyaml
apiVersion: v1
data:
c.yaml: |
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
kind: ConfigMap
metadata:
creationTimestamp: 2019-03-07T08:35:18Z
name: testcfg
namespace: default
resourceVersion: "7520"
selfLink: /api/v1/namespaces/default/configmaps/testcfg
uid: f033536d-40b3-11e9-a67d-0242ac11005b
These could be the problems
1. most likely the issue could with the indentation.
2. remove '-' from abc.yml: |- and check
I followed the below steps and was able to load yaml file into configmap. it worked fine.
master $ cat c.yaml
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
master $ kubectl create configmap testcfg --from-file=./c.yaml
master $ kubectl get cm testcfg -oyaml
apiVersion: v1
data:
c.yaml: |
apiVersion: v1
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
kind: ConfigMap
metadata:
name: example-redis-config
kind: ConfigMap
metadata:
creationTimestamp: 2019-03-07T08:35:18Z
name: testcfg
namespace: default
resourceVersion: "7520"
selfLink: /api/v1/namespaces/default/configmaps/testcfg
uid: f033536d-40b3-11e9-a67d-0242ac11005b
edited Mar 7 at 8:42
answered Mar 7 at 8:36
P EkambaramP Ekambaram
1,277613
1,277613
apiVersion: v1 kind: ConfigMap data: abc.yml: | namespace: "a_namespace" :development: <<: *defaults deployment >> default How to make the config map read the default variables ?
– Nancy
Mar 7 at 12:25
please state clearly what exactly you are trying to achieve
– P Ekambaram
Mar 7 at 13:28
add a comment |
apiVersion: v1 kind: ConfigMap data: abc.yml: | namespace: "a_namespace" :development: <<: *defaults deployment >> default How to make the config map read the default variables ?
– Nancy
Mar 7 at 12:25
please state clearly what exactly you are trying to achieve
– P Ekambaram
Mar 7 at 13:28
apiVersion: v1 kind: ConfigMap data: abc.yml: | namespace: "a_namespace" :development: <<: *defaults deployment >> default How to make the config map read the default variables ?
– Nancy
Mar 7 at 12:25
apiVersion: v1 kind: ConfigMap data: abc.yml: | namespace: "a_namespace" :development: <<: *defaults deployment >> default How to make the config map read the default variables ?
– Nancy
Mar 7 at 12:25
please state clearly what exactly you are trying to achieve
– P Ekambaram
Mar 7 at 13:28
please state clearly what exactly you are trying to achieve
– P Ekambaram
Mar 7 at 13:28
add a comment |
Yes you can do that, but you should care about the syntax. You can also follow techniques for yaml from here.
If you use kubectl create configmap myconfig --from-file=abc.yml
, then it is ok.
But if you write the whole yaml file for your configmap in myconfig.yaml and then run kubectl create -f myconfig.yaml
, then you should care about syntax.
Say your abc.yml
file is as followings:
a:
b: b1
c: c1
d: d1
Then write your myconfig.yaml
file:
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |
a:
b: b1
c: c1
d: d1
Now just run kubectl create -f myconfig.yaml
.
That's it.
Happy Kubernetes!!!.
add a comment |
Yes you can do that, but you should care about the syntax. You can also follow techniques for yaml from here.
If you use kubectl create configmap myconfig --from-file=abc.yml
, then it is ok.
But if you write the whole yaml file for your configmap in myconfig.yaml and then run kubectl create -f myconfig.yaml
, then you should care about syntax.
Say your abc.yml
file is as followings:
a:
b: b1
c: c1
d: d1
Then write your myconfig.yaml
file:
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |
a:
b: b1
c: c1
d: d1
Now just run kubectl create -f myconfig.yaml
.
That's it.
Happy Kubernetes!!!.
add a comment |
Yes you can do that, but you should care about the syntax. You can also follow techniques for yaml from here.
If you use kubectl create configmap myconfig --from-file=abc.yml
, then it is ok.
But if you write the whole yaml file for your configmap in myconfig.yaml and then run kubectl create -f myconfig.yaml
, then you should care about syntax.
Say your abc.yml
file is as followings:
a:
b: b1
c: c1
d: d1
Then write your myconfig.yaml
file:
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |
a:
b: b1
c: c1
d: d1
Now just run kubectl create -f myconfig.yaml
.
That's it.
Happy Kubernetes!!!.
Yes you can do that, but you should care about the syntax. You can also follow techniques for yaml from here.
If you use kubectl create configmap myconfig --from-file=abc.yml
, then it is ok.
But if you write the whole yaml file for your configmap in myconfig.yaml and then run kubectl create -f myconfig.yaml
, then you should care about syntax.
Say your abc.yml
file is as followings:
a:
b: b1
c: c1
d: d1
Then write your myconfig.yaml
file:
apiVersion: v1
kind: ConfigMap
data:
abc.yml: |
a:
b: b1
c: c1
d: d1
Now just run kubectl create -f myconfig.yaml
.
That's it.
Happy Kubernetes!!!.
edited Mar 8 at 17:15
answered Mar 8 at 10:17
Shudipta SharmaShudipta Sharma
1,185414
1,185414
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038569%2fcan-we-use-data-as-a-yaml-file-instead-of-json-file-in-config-map%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
remove '-' from abc.yml: |- and try
– P Ekambaram
Mar 7 at 8:37