-
Notifications
You must be signed in to change notification settings - Fork 39.4k
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
Configmap pretty display #36222
Comments
Hrm, this seems to me like the right answer is to special case 'kubectl edit' for configmaps, rather than try to hack around with the YAML decoder. I suppose we could use block quotes (e.g. |
Automatic merge from submit-queue (batch tested with PRs 38284, 38403, 38265) Display config map data, not byte count. Begins to address #36222 Next step is: `kubectl edit configmap <name> --key=<file-name>` @kubernetes/sig-cli
Automatic merge from submit-queue (batch tested with PRs 38445, 40292) Add the ability to edit fields within a config map. Addresses part of #36222 Example command: ```console $ kubectl edit configmap foo --config-map-data=bar ``` Will open the data element named `bar` in the `ConfigMap` named `foo` in `$EDITOR`, the edited contents are then updated back to the config map. @kubernetes/sig-cli ```release-note Add a special purpose tool for editing individual fields in a ConfigMap with kubectl ```
Closing this, pretty print is there, kubectl configMap edit support is there. |
This still happens on kube 1.7 :-( I'm not 100% sure how to reproduce, but what I did was:
|
I'm also seeing this issue in kube 1.7. During the past few days I have edited a configmap ~110 times, and seen the formatting get destroyed (spaces messed up, |
I'm still seeing this issue too. For example, I have a configmap with 3 files in ; they all are identical except one variable ; 2 of them display normally, and the last one displays with \n ... |
also seeing this issue on 1.7 |
can we reopen this issue? or open a new one? |
I created a brand new configmap using and when I viewed the yaml with |
I am experiencing the same. \n character is messing up a configmap I'm creating with --from-file option. Anyone found a reason why this is happening ? |
Also failing in 1.8.4 |
I am also facing the same issue of formatting .. I have a application configuration of 400-500 lines. Tryied many times. For fist 40-50 lines the format is good ans easily readable.. However, when i try to create config for entire configuration file its very difficult to edit the config map.. |
Same issue here. No idea what makes one configmap show better than another. |
This issue corrupted my aws-auth configMap that authenticates my user to access the EKS cluster and while trying to add other users to the configMap the formatting corrupted the configMap file and now I am locked out of my EKS cluster. Version: 1.10.3 |
I don't know if this will help somebody else but I was facing the same issue with escaped data in a config map edit and get (the config map had a single .conf file), and it seems that I had a unneeded extra space at the end of a single line in my data. When I removed that extra space the pretty printing was maintained in edit and get. |
1.11 |
still same ( there is an example if install helm install stable/prometheus , you will find cm/prometheus-server ) |
I agree with @lleontop - I can recreate it every time
However, repeat the above (or edit the existing one with |
Can we reopen this issue? I need this feature to change the yaml in cm, and I have been struggling with the intent and \n for several days ... |
If you just want the raw output as it was read in when created --from-file, you can use jq to get the raw string (without escaped newlines etc) Get the data: |
Edited a cm, came back in, and had \n all over. Something about white space in my previous edit? Not great overall :/ On kubectl version |
Awesome, very good website~ |
Thank You very much |
I was able to fix this behavior by:
It will also convert CRLF to LF only, by removing |
Something small that exacerbates this issue is that in python's standard lib module So if you have old-ish glue (e.g. python 2.7) that parses a k8s configmap into a file for archival purposes, and you made that file readable by pretty-printing it, using that file to regenerate a new configmap results in this gross escape behaviour. |
Based on this: kubernetes/kubernetes#36222 Spaces before Newlines causes issues rendering confgMaps. Very anoying when `kubectl edit` is involved
Depending on your configuration, the configmap can be rendered with lines having trailing whitespace. This causes k8s to display the configmap as just a big string containing literal "\n" strings, rather than actual linebreaks. This is most notably a problem when using `kubectl edit`, as it is somewhat more difficult to edit the config when it's all on one line. kubernetes/kubernetes#36222 has a whole bunch of discussion on the issue, in case you wanted to read about a bunch of people yelling past each other. Regardless of whether it's a bug or not, seems best to just avoid it in the first place.
Depending on your configuration, the configmap can be rendered with lines having trailing whitespace. This causes k8s to display the configmap as just a big string containing literal "\n" strings, rather than actual linebreaks. This is most notably a problem when using `kubectl edit`, as it is somewhat more difficult to edit the config when it's all on one line. kubernetes/kubernetes#36222 has a whole bunch of discussion on the issue, in case you wanted to read about a bunch of people yelling past each other. Regardless of whether it's a bug or not, seems best to just avoid it in the first place.
Hello There, |
yaml marshallers will write a string to a multiline string e.g. multiline_string: |
some string!
with new lines and \ no need to escape things UNLESS
|
I am in the same situation. Were you able to solve this? |
Also reproduce in v1.22.3 :( |
I occasionally encountered this problem in v1.15.6 or v1.21.2, The state of the online configmap under edit, to modify the local configmap file, is ultimately able to deal with this problem, |
yes if you are working on linux |
i would like to share an observation that helped me sort out the line merging and \n. |
I got the same error after editing the ConfigMap file. I used an online tool to remove the trailing white space that we cannot see in the text. After copying the content which removed trailing whitespaces I was able to resolve this issue FYI - https://miniwebtool.com/remove-leading-trailing-spaces/ (online tool which I used) |
When this trailing whitespace is present, and the Tigera Operator manifest is embedded as YAML within a Kubernetes ConfigMap or Secret, all whitespace in the embedded YAML is escaped. This is discussed in kubernetes/kubernetes#36222.
in v1.24 also i can see same issue. |
Finally, I found that the absence of a value defined or the value is empty string in valus.yaml will cause the data: {{ .Values.application.data}}
just use quote to the value resolved
|
delete space before \n or after \n |
did anyone find solution when we edit cm how we can see in proper format as for me really difficult to edit cm as we have many \n char and I can still see this issue in k8s version 1.28 |
Kubernetes version :
What happened:
When I try to display configmap content with yaml output (kubectl get configmap webapp-inifile -o yaml), the output is sometimes pretty, and sometimes not -depending newlines are effectively displayed or not - just \n char-
I can't find what's the difference between some file and some others. (limit on numer of lines ?)
Configmap is created with --from-file option
Ex :
What you expected to happen:
More human readable display, in order to be able to easily change parameter when kubectl edit congifmap
How to reproduce it :
The text was updated successfully, but these errors were encountered: