kubernetes: dot character in environment variable name yields "invalid value"
I modified the pod json from here https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/aws-coreos.md to have this in it:
"containers": [{
"name": "hello",
"env": [
{
"name": 'oms.port',
"value": 9000,
}],
"image": "quay.io/kelseyhightower/hello",
"ports": [{
"containerPort": 80,
"hostPort": 80
}]
}]
and when I do kubecfg -c pod.json create pods, I get
F1202 08:48:01.907263 04825 kubecfg.go:403] Got request error: pod "hello" is invalid: desiredState.manifest.containers[0].env[0].name: invalid value 'oms.port'
I am using Kubernetes 0.5.4
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 3
- Comments: 22 (15 by maintainers)
Commits related to this issue
- Support an alternative, shell friendly, way to define ES settings Shells allow a specific character class for environment variables: `[a-zA-Z_]+[a-zA-Z0-9_]*`. While Docker and POSIX[1] can deal wit... — committed to elastic/elasticsearch-docker by dliappis 7 years ago
- Merge pull request #48986 from timoreimann/relax-env-var-naming-restrictions Automatic merge from submit-queue (batch tested with PRs 50208, 50259, 49702, 50267, 48986) Relax restrictions on environ... — committed to kubernetes/kubernetes by deleted user 7 years ago
- (maint) Support dotted env vars in containers - Both docker (per https://github.com/moby/moby/issues/16585) and Kubernetes (per https://github.com/kubernetes/kubernetes/issues/2707) support pa... — committed to puppetlabs/puppetdb by Iristyle 3 years ago
- (maint) Add note about container dotted env vars - Both docker (per https://github.com/moby/moby/issues/16585) and Kubernetes (per https://github.com/kubernetes/kubernetes/issues/2707) support... — committed to puppetlabs/puppetserver by Iristyle 3 years ago
- (maint) Add note about container dotted env vars - Both docker (per https://github.com/moby/moby/issues/16585) and Kubernetes (per https://github.com/kubernetes/kubernetes/issues/2707) support... — committed to puppetlabs/puppetserver by Iristyle 3 years ago
- Merge pull request #48986 from timoreimann/relax-env-var-naming-restrictions Automatic merge from submit-queue (batch tested with PRs 50208, 50259, 49702, 50267, 48986) Relax restrictions on environ... — committed to akhilerm/apimachinery by k8s-publishing-bot 7 years ago
- (maint) Support dotted env vars in containers - Both docker (per https://github.com/moby/moby/issues/16585) and Kubernetes (per https://github.com/kubernetes/kubernetes/issues/2707) support pa... — committed to voxpupuli/container-puppetdb by Iristyle 3 years ago
A workaround for Elasticsearch until this is fixed is to use command arguments in your Kubernetes deployment spec like so:
As documented under configuration here: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
With the explanation from here quoted on the referenced Docker issue, it seems to me that Kubernetes is similar to Docker in the sense that it’s just an intermediary that should always pass environment variables through to the application even when they contain “illegal characters”; the reason being that applications may not be subject to the same restrictions as bash.
@erictune Do you think this is worth creating a new issue or reopening this one?
@webwurst it’ll only be available in 1.8.
My PR just got merged. Once released, environment variable names with dots (and dashes) should generally be supported.
Sorry to necro this thread. My issue turned out to be because I used “sh” in the command, which strips dotted names. Switching to “bash” allowed the variables to pass through as expected.
Super quick update: I’ve started work on this. Should hopefully be able to submit a PR soonish.
If you are stuck on <1.8 for the time being this fixed it all for me with elasticsearch (the similar answer above didn’t quite cut it) hope this helps someone
thanks @mtaufen – will follow up with a PR and see what folks have to say.
@erictune Funnily enough this hit us as well today for elasticsearch. Docker had this restriction and reverted it since POSIX pretty clearly states that you should tolerate env strings you don’t understand. See more in the relevant docker issue https://github.com/docker/docker/issues/16585
The issue (which is still present in Kube 1.5.3) is that a dot is not allowed in the podspec for environment variables names.
Some systems (elasticsearch for example) use dotted env var names. Example:
The above fails with
Deployment.extensions “es-es-kibana” is invalid: spec.template.spec.containers[0].env[2].name: Invalid value: “transport.host”: must match the regex [A-Za-z_][A-Za-z0-9_]*