9

I am trying to create a docker-registry secrete for GCR, but am getting a really cryptic error message. This is the kubectl cmd that I am running:

kubectl create secret docker-registry gcrsecret --docker-username=_json_key --docker-password=”$(cat wk-test-1-b3c9659d9a07.json)” --docker-server=https://gcr.io --docker-email=rynslmns@gmail.com

But it is erroring out with the following error message:

error: exactly one NAME is required, got 26

Any thoughts? I am not seeing anything obvious in the documentation.

Ryan Salmons
  • 1,429
  • 10
  • 21
  • 42

6 Answers6

7

It seems that you are using (Unicode RIGHT DOUBLE QUOTATION MARK) instead of " (ASCII 0x22), which is confusing your shell.

jonjohnson
  • 346
  • 1
  • 5
  • This does not work!! I'm using this I still get the same error. kubectl create secret docker-registry regcred --docker-server="https://gcr.io" --docker-username=_json_key --docker-email=you@gmail.com --docker-password="`(cat file.json)`" – quantdaddy Feb 14 '20 at 06:17
  • The problem is that the json file contains double quotes and they have to be escaped. I couldn't figure out how to do that yet. – quantdaddy Feb 14 '20 at 06:21
6

Future readers. Watch out for any spaces.

The below line will cause an error: ("BAD!")

kubectl create configmap special-config --from-literal=special.how=very --from-literal= special.type='charm'

error: exactly one NAME is required, got 2

The below line will work:

kubectl create configmap special-config --from-literal=special.how=very --from-literal=special.type='charm'

configmap "special-config" created

Note the space before "special.type" in the BAD! example.

granadaCoder
  • 26,328
  • 10
  • 113
  • 146
3

If you're on windows use ' rather than "

Prasanth Louis
  • 4,658
  • 2
  • 34
  • 47
2

My issue was that I copied and pasted the command from a browser to a terminal. Typing the code directly into the terminal solved the issue.

charlchad
  • 3,381
  • 1
  • 16
  • 9
1

Adding an command option which does not exist leads to the same error as well

kubectl create secret generic --dry-run -oj json \
mysecretname \
--from-literal=KEY=value \
| kubeseal --format yaml

Notice the option j? Remove it and it works fine

Anytoe
  • 1,605
  • 1
  • 20
  • 26
0

And you cannot use ~ for set path.

--from-file= ~/XXX is wrong use insted --from-file= /root/XXX

Bawantha
  • 3,644
  • 4
  • 24
  • 36