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










1















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.










share|improve this question
























  • remove '-' from abc.yml: |- and try

    – P Ekambaram
    Mar 7 at 8:37















1















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.










share|improve this question
























  • remove '-' from abc.yml: |- and try

    – P Ekambaram
    Mar 7 at 8:37













1












1








1








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












3 Answers
3






active

oldest

votes


















0














Create ConfigMap from file.



kubectl create configmap myconfig --from-file=youfile.yml.



You can check more examples on kubernetes docs






share|improve this answer






























    0














    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






    share|improve this answer

























    • 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


















    0














    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!!!.






    share|improve this answer
























      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
      );



      );













      draft saved

      draft discarded


















      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









      0














      Create ConfigMap from file.



      kubectl create configmap myconfig --from-file=youfile.yml.



      You can check more examples on kubernetes docs






      share|improve this answer



























        0














        Create ConfigMap from file.



        kubectl create configmap myconfig --from-file=youfile.yml.



        You can check more examples on kubernetes docs






        share|improve this answer

























          0












          0








          0







          Create ConfigMap from file.



          kubectl create configmap myconfig --from-file=youfile.yml.



          You can check more examples on kubernetes docs






          share|improve this answer













          Create ConfigMap from file.



          kubectl create configmap myconfig --from-file=youfile.yml.



          You can check more examples on kubernetes docs







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 8:18









          VeerendraVeerendra

          7161239




          7161239























              0














              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






              share|improve this answer

























              • 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















              0














              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






              share|improve this answer

























              • 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













              0












              0








              0







              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






              share|improve this answer















              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







              share|improve this answer














              share|improve this answer



              share|improve this answer








              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

















              • 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











              0














              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!!!.






              share|improve this answer





























                0














                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!!!.






                share|improve this answer



























                  0












                  0








                  0







                  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!!!.






                  share|improve this answer















                  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!!!.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 8 at 17:15

























                  answered Mar 8 at 10:17









                  Shudipta SharmaShudipta Sharma

                  1,185414




                  1,185414



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                      Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                      2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived