Today I want to add a docker registry credential in kubernetes v1.21.3 (it works fine in lower version of kubernetes but have problem in new version of kubernetes):
kubectl create secret docker-registry regcred \
--docker-server=registry.cn-hangzhou.aliyuncs.com \
--docker-username=docker654321 \
--docker-password=$balabala123 \
--docker-email=foo@gmail.com \
-n reddwarf-pro
but it tell me:
error: either --from-file or the combination of --docker-username, --docker-password and --docker-server is required
what should I do to add docker registry crediential into this cluster? This is the version info:
[root@k8smasterone ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe34773c74f79527be4afd95bf39", GitTreeState:"clean", BuildDate:"2021-07-15T21:04:39Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:53:14Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
$
and it works, I also did not know any more, why the@
not escape and works? – Dolphin Aug 05 '21 at 07:20@
is in no way special to the shell and therefore does not need escaping or quoting. Personally, I would recommend single-quoting strings containing special characters (--docker-password='$balabala123'
) rather than escaping individual characters (which works, but which makes for ugly code and which is fiddly). – Kusalananda Aug 05 '21 at 08:06