Change:
I am trying to create a configmap from a file using the "kubectl create configmap myconfigmap --from-file=game.properties" The game.properties consists of the following key value pairs The command is failing with the error "game.properties" is not a valid key name for a ConfigMap: a valid config key must consist of alphanumeric characters, '-', '' or '.' (e.g. '', or 'KEYNAME', or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+') Also, with the same file (game.properties), i tried creating the configmap using "kubectl create configmap myconfigmap --from-file=game-properties-key=game.properties" and the configMap is getting created successfully. I tried creating a secret using the example given in kubernetes documentation ie kubectl create secret generic db-user-pass --from- --from- I am getting the same error for secrets as well This command was working a few weeks ago. I haven't changed my kubectl version since then. Kubectl version: 1.9.0 I also tried the same command with 1.7, 1.6 and 1.4 version and am getting the same error. /sig cli /kind bug
what server version do you have (output of )? dots are allowed in 1.4.x+ ( in )
Kubectl version: Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.1", GitCommit:"", GitTreeState:"clean", BuildDate:"2017-10-11T23:27:35Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"windows/amd64"} Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.7", GitCommit:"", GitTreeState:"clean", BuildDate:"2017-09-28T23:56:03Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
I'm having the same issue trying to add yaml files. I've tried several files and get the same error on all of them? I'm on a mac and just did a new install of kubctl with homebrew, which was v1.8.0.
Is there any update on this? The same file is not working with a 1.4.6 version as well. Is there some specific way in which we need to specify the key value pairs in a config map using the file method?
not really, the described scenario works as expected for me:
I finally got what is wrong. When i specify the file path, i get the error specified. If the file is in the same location from where i am running the command the command executes successfully. eg: kubectl create configmap myconfigmap1 --from-file="C:UsersanshenoDesktop" gives me the error error: "C:UsersanshenoDesktop" is not a valid key name for a ConfigMap: a valid config key must consist of alphanumeric characters, '-', '' or '.' (e.g. '', or 'KEYNAME', or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+')
ah, great. will fix that. in the meantime, you can do
Thanks a lot!. One more observation was that the command works if you specify the path to the directory which contains the file instead of the path to the file itself.
Hi, what would be eta of this fix? Also, will it be available in all the versions of kubectl?
it will be in 1.11, targeted for end of june ()

Discussion:
"errors" "fmt" "path" <ins> "path/filepath" </ins> "strings" "time"

numSeparators := strings.Count(source, "=") switch { case numSeparators == 0: <del> return path.Base(source), source, nil </del> <ins> return path.Base(filepath.ToSlash(source)), source, nil </ins> case numSeparators == 1 && strings.HasPrefix(source, "="): return "", "", fmt.Errorf("key name for file path %v missing.", strings.TrimPrefix(source, "=")) case numSeparators == 1 && strings.HasSuffix(source, "="):