-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Pass pod labels to containers and to lifecycle hooks #560
Comments
As discussed in #386, environment variables aren't ideal. But we should pass labels down. |
Labels will reach the node when #1662 lands |
Somewhat opinionated proposal of how downward API could be exposed as env for both labels and service values described here:
Essentially, do a limited form of env var substitution as pre-processing pass on the Pod prior to invoking docker start. Walk the list once to get all the user provided env, then go through and allow env substitution and let the substitution values pull from a) kubernetes "downward env API" source (service vars, labels, pod info) and b) env vars. Optionally, we could include c) env in the image. Then we would pass that entire env to the container. This would mean we would never inject env into the user's container by default (so no hidden magic variables except service hosts for now), but users would be able to selectively include variables by name. The kube downward env API vars could be appropriately namespaced. |
And then users who want the actual string "$" in their env vars need to I could buy a new block of env vars that are explicitly handled this way, On Fri, Jan 30, 2015 at 8:43 AM, Clayton Coleman notifications@github.com
|
There would be a flag that says you want this. I'm not insane, just dangerous. Like "Resolve":true or "expand":true
|
I clarified in the other one this was explicit opt in on a per var basis, but forgot to copy that here.
|
I could probably live with that. As per the migration issue - exposing On Fri, Jan 30, 2015 at 7:14 PM, Clayton Coleman notifications@github.com
|
True. I was thinking as a default of exposing only host, port, and maybe a few attributes off the pod. We could then nuke the docker style env vars. At least here we have a way to do a migration, vs with magic env vars that show up and people use without you being able to tell.
|
@smarterclayton Clarifying for the record that by flag in your above comment you mean attribute on |
Yes, although a separate block is also reasonable. Is a separate block easier to reason about, or confusing to new users?
|
@smarterclayton I think a separate block that is designated as being resolved is probably easier to reason about, but that's my own subjective opinion. @sdminonne, any opinions about that? |
FWIW, this should probably be discussed in #386. As @thockin cautioned and as mentioned in #3949, I wouldn't expose a pod's host. Note that any property encoded in an env. var. would require a container restart when its value changed. I'd prefer a separate block, similar to the distinction between labels and annotations. |
I would prefer to avoid a new block.
Looking at #386 (@smarterclayton I wasn't aware of it when we started the discussion about this) the /etc/labels file (proposed by @bgrant0607) sounds a reasonable solution. The container applications are free to use or ignore this information and dynamic updates to it. The syntax key=label is fine. |
I have a slight preference for a new block, but the /etc/labels file or On Thu, Feb 5, 2015 at 1:39 AM, Salvatore Dario Minonne <
|
Good point - it would be nice to make that flexible. We could also introduce a volume type that can pull labels or volumes. I guess the question is - what is the boundary for volume types? File generation? File generation from a template? Retrieving keys from etcd and then transforming them? Or is that a job for sidecar containers or pre start lifecycle hooks?
|
Right now volumes are run-once. If you need something active, as in a git On Thu, Feb 5, 2015 at 5:16 PM, Clayton Coleman notifications@github.com
|
After some thought and discussion with @sdminonne, @EricMountain-1A, and @smarterclayton, I had some thoughts on this:
Thinking through the possibility of a source abstraction for environments in the context of this issue:
Other source of information can be adapted with new Source implementations. Typing this out, I'm not sure if I like it. Any thoughts, @smarterclayton @sdminonne @EricMountain-1A @thockin @bgrant0607 @lavalamp ? |
@pmorie thanks for the explanation. |
@sdminonne correct. The sidecar container would need auth to access the master, either via a secret consumed in the volume or something like the LOAS Daemon. |
Why would it need auth? It all seems strictly read-only... As for feature set, less is more unless there's no other choice. I'd love And yes, I think that a generic "sync kubernetes info to files" container On Tue, Feb 17, 2015 at 8:40 AM, Paul Morie notifications@github.com
|
----- Original Message -----
I think so for the near term. We can take real use cases to handle the container case, and adapt them in later if necessary.
|
@sdminonne @thockin @smarterclayton @bgrant0607 Continuing to flesh out the sidecar container outlined above: {
"id": "kubernetes-info-test-pod",
"kind": "Pod",
"apiVersion":"v1beta2",
"labels": {
"name": "kubernetes-info-test-pod"
},
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "kubernetes-info-test-pod",
"containers": [{
"name": "client-container",
"image": "busybox",
"command": [ "cat", "/etc/kubernetes-info/labels" ],
"volumeMounts": [{
"name": "kubernetes-info-volume",
"mountPath": "/etc/kubernetes-info",
"readOnly": true
}]
},
{
"name": "kubernetes-info-sidecar",
"image": "kubernetes/kubernetes-info",
"command": [ "write-kubernetes-info", "/etc/kubernetes-info"],
"volumeMounts": [{
"name": "kubernetes-info-volume",
"mountPath": "/etc/kubernetes-info",
}]
}],
"volumes": [{
"name": "kubernetes-info-volume",
}]
}
}
} |
@pmorie thanks for this. |
Had a good chat w/ @sdminonne and @EricMountain-1A this morning. Dario is going to prototype a new docker image for the sidecar container that will accept parameters for:
Example:
The sidecar will poll the API server for information about the Pod (we had talked about watching, but I had forgotten that there is no watch API for pods) and refresh the information in the shared volume. |
@sdminonne @EricMountain-1A see @thockin's comments re: atomic update here: #4673 (comment) |
Dumping info into files was also discussed in #386. I certainly prefer that over environment variables. However, I think that doesn't address @smarterclayton's concerns about accidental coupling, opt-in for specific information, and adapting to application expectations rather than forcing them to adapt to Kubernetes conventions (other than deployment-time adapters). |
Just add #5093 as a possible implementation. |
Add system uuid and machine id information
Done enough, via downward API |
Remove tombstoned Release folders
For context, see: https://groups.google.com/d/msg/google-containers/frOLMyNl5U4/W5_DQUL933IJ
Idea specifically is to have a <service_name>_LABELS env var in addition to the service's port.
Filing as an issue to track discussion. I'm unsure if it's generally useful enough to justify the extra complexity.
The text was updated successfully, but these errors were encountered: