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

GBK file being read as UTF-8 when run "kubectl create configmap --from-file" #58503

Closed
lentil1016 opened this issue Jan 19, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@lentil1016
Copy link

commented Jan 19, 2018

Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug

What happened: When I'm trying to create a configMap object with a text file encoded by GBK or GB2312 by running the following command,

kubectl create configmap test-conf --from-file ./some-gbk-file.txt

it seems K8s read and treat it as a UTF-8 text file and all Chinese chars in this file, which I read by mount the configMap into a container in K8s, have been transformed to U+FFFD —— the REPLACEMENT CHARACTER in UTF-8, witch looks like '锟斤拷锟斤拷锟斤拷' in GBK.

In addition:

before creating the configmap:

some_pc$ file some-gbk-file.txt
some-gbk-file.txt: Algol 68 source, ISO-8859 text, with CRLF line terminators

after creating the configmap and mount it into a container:

in-container$ file some-gbk-file.txt
some-gbk-file.txt: UTF-8 Unicode text, with CRLF line terminators

What you expected to happen:

  • it will be nice if configmap can create by GBK file (Transform it into UTF-8? Or not, Just return false with an error, or a warning, rather than just read it as a UTF-8 file anyway)
  • it will be nicer if configmap can create by GBK file and remain as a GBK file when put it into container

How to reproduce it (as minimally and precisely as possible):

export LC_ALL="en_US.UTF-8"
echo "测试" > utf8-file.txt
iconv -f UTF-8 -t GBK utf8-file.txt -o gbk-file.txt
kubectl create configmap test-conf --from-file gbk-file.txt
kubectl get configmap test-conf -o yaml > bad-gbk-file.txt
cat gbk-file.txt bad-gbk-file.txt # Looks different.

Environment:

  • Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T21:07:38Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T20:55:30Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}

  • Cloud provider or hardware configuration: VMWare virtual machine
  • OS (e.g. from /etc/os-release): CentOS Linux release 7.4.1708
  • Kernel (e.g. uname -a): Linux glsserver-5776b9b9bc-c75vs 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools: kubeadm
  • Others: Nope
    sig/cli
@lentil1016

This comment has been minimized.

Copy link
Author

commented Jan 19, 2018

/sig cli

@liggitt

This comment has been minimized.

Copy link
Member

commented Jan 19, 2018

thank you for the detailed report. this is actually a duplicate of #32432 related to storing non-UTF8 data in configmaps

it is being addressed in #57938 and is targeting the 1.10 release

/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.