Skip to content
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

Container downward/upward API umbrella issue #386

Closed
bgrant0607 opened this issue Jul 9, 2014 · 29 comments
Closed

Container downward/upward API umbrella issue #386

bgrant0607 opened this issue Jul 9, 2014 · 29 comments
Labels
area/downward-api kind/design Categorizes issue or PR as related to design. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/node Categorizes an issue or PR as relevant to SIG Node.

Comments

@bgrant0607
Copy link
Member

We need to start establishing the "downward API", starting with enough context that a container can find out more information about itself.

I think that minimal info is:
K8S_APISERVER = host:port of apiserver
K8S_POD_ID
K8S_CONTAINER_NAME

@smarterclayton
Copy link
Contributor

Would it be better to make this explicit in the manifest (VAR_A=$K8_POD_ID) rather than implicit? I ask because in Openshift we found this led to lazy coupling, and in scenarios where you have code that wants a unique id, you want to be able to alias names instead. At least that couples k8s to an image via a specific resource provided by k8s, vs making the image dependent on k8s.

@bgrant0607
Copy link
Member Author

@smarterclayton Hmm. I see the case for doing the substitution in k8s rather than in the container, though I do have some concerns about introducing yet another substitution mechanism.

I was thinking that, at least for now, any additional information the container wanted about itself could be retrieved by querying the apiserver, which would obviously also couple the querier to k8s.

I think we are going to need to standardize on a "downward-facing API", including this type of contextual information (and also IP address, DNS name, auth info, etc.), but also a variety of notifications and/or hooks (#140). If we had hooks, we could make the context info available to the hooks, which could then normalize the info for the application. I see hooks as being necessarily specific to the hosting framework and other glue services.

@smarterclayton
Copy link
Contributor

That's true, although one strong goal in docker has been to try and offer via libchan/libswarm a "Docker" abstraction where on multiple platforms images can invoke consistent actions that affect the platform. That applies to more generic operations, whereas k8s specific actions will always require some downwards API. The abstraction is a long term play that requires active participation by a number of stakeholders and also implemented, demonstrated use cases, so it's not an argument for avoiding trying.

I don't think the downward API is bad, but some of the use cases (unique id for an instance, what ip do I have) might benefit from looser coupling or by trying to find the most lowest common denominator expression. In the end image authors can always ignore those settings, but you do want image users to have the tools to bend a recaltricant image to their will.

@thockin
Copy link
Member

thockin commented Jul 10, 2014

As much as I want to keep this simple, Clayton's argument of using a non
k8s native image in k8s by application of clever env vars is compelling.

But what scope? Env vars only? Env vars and command lines?
On Jul 9, 2014 5:08 PM, "Clayton Coleman" notifications@github.com wrote:

That's true, although one strong goal in docker has been to try and offer
via libchan/libswarm a "Docker" abstraction where on multiple platforms
images can invoke consistent actions that affect the platform. That applies
to more generic operations, whereas k8s specific actions will always
require some downwards API. The abstraction is a long term play that
requires active participation by a number of stakeholders and also
implemented, demonstrated use cases, so it's not an argument for avoiding
trying.

I don't think the downward API is bad, but some of the use cases (unique
id for an instance, what ip do I have) might benefit from looser coupling
or by trying to find the most lowest common denominator expression. In the
end image authors can always ignore those settings, but you do want image
users to have the tools to bend a recaltricant image to their will.

Reply to this email directly or view it on GitHub
#386 (comment)
.

@bgrant0607
Copy link
Member Author

I find it compelling, too. Internally, we have thousands of uses of the downward API, and I agree it introduces unnecessary coupling. OTOH, I'd like to think more about the configuration and parameterization story before introducing substitution.

As opposed to the k8s-specific mechanism I proposed, perhaps we could start by thinking about what a typical application would need to know about itself and how that information could be provided in the least entangled manner.

@bgrant0607 bgrant0607 changed the title Provide minimal container context via environment variables Provide minimal container context Aug 23, 2014
@bgrant0607 bgrant0607 changed the title Provide minimal container context Container downward/upward API umbrella issue Sep 30, 2014
@bgrant0607
Copy link
Member Author

I propose a general approach: We should use/extend standard networking and filesystem-based mechanisms for the downward and upward container APIs as much as possible. We should not use custom environment variables (which can't be dynamically updated) nor REST APIs, and the mechanisms should not be intrinsically specific to Kubernetes (so no kubernetes in paths/names).

Downward:

TODO: Master election, shard assignment.

Upward:

References:

@bgrant0607
Copy link
Member Author

Also, while we could make the paths configurable for some of these files, I don't think we need to. Users could set their own environment variables and evaluate them on the command line (as described in https://github.com/GoogleCloudPlatform/kubernetes/wiki/User-FAQ), or could extract the information in a PreStart hook (#140, #1445).

@thockin
Copy link
Member

thockin commented Oct 7, 2014

Missing here - resource limits and usage?

@bgrant0607
Copy link
Member Author

@thockin That's "resource discovery".

@thockin
Copy link
Member

thockin commented Oct 7, 2014

We need to think hard about what cgroups interfaces we expose. On the one
hand, it's nice to be able to run sub-containers yourself. On the other
hand, the kernel world does NOT want to support that operating mode and it
is very fragile for all but the most sophisticated users.

On Mon, Oct 6, 2014 at 9:13 PM, bgrant0607 notifications@github.com wrote:

@thockin https://github.com/thockin That's "resource discovery".

Reply to this email directly or view it on GitHub
#386 (comment)
.

@bgrant0607
Copy link
Member Author

@thockin User subcontainers is #1568. Perhaps the solution to that overlaps with resource discovery, or perhaps not. Rather than directly reading cgroup files, I'd be fine if they were wrapped with a system utility and/or library, but it shouldn't require a daemon and definitely shouldn't require a HTTP API. Ideally, Linux apps would not need to be container-aware in order to work.

@thockin
Copy link
Member

thockin commented Oct 7, 2014

We don't need to design it here, but we should definitely make sure Vish,
Victor, and Rohit are game to support whatever we decide. I'm not sure
daemon-free can work in this new world, which makes me very sad.

On Mon, Oct 6, 2014 at 9:58 PM, bgrant0607 notifications@github.com wrote:

@thockin https://github.com/thockin User subcontainers is #1568
#1568. Perhaps
the solution to that overlaps with resource discovery, or perhaps not.
Rather than directly reading cgroup files, I'd be fine if they were wrapped
with a system utility and/or library, but it shouldn't require a daemon and
definitely shouldn't require a HTTP API. Ideally, Linux apps would not need
to be container-aware in order to work.

Reply to this email directly or view it on GitHub
#386 (comment)
.

@bgrant0607
Copy link
Member Author

Being discussed in Docker land: moby/moby#8427

@davidopp davidopp added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. team/master sig/node Categorizes an issue or PR as relevant to SIG Node. labels Feb 17, 2015
@bgrant0607 bgrant0607 added priority/design and removed priority/backlog Higher priority than priority/awaiting-more-evidence. labels Feb 28, 2015
@pmorie
Copy link
Member

pmorie commented Mar 25, 2015

We did some discussion on this topic starting around here: #2316 (comment)

@bgrant0607
Copy link
Member Author

@zmerlynn zmerlynn mentioned this issue Oct 29, 2015
15 tasks
@thockin
Copy link
Member

thockin commented Jun 9, 2016

I propose we close this umbrella bug and open new issues for specific points remaining.

@maicohjf
Copy link

As much as I want to keep this simple, Clayton's argument of using a non
k8s native image in k8s by application of clever env vars is compelling.

But what scope? Env vars only? Env vars and command lines?
On Jul 9, 2014 5:08 PM, "Clayton Coleman" notifications@github.com wrote:

That's true, although one strong goal in docker has been to try and offer
via libchan/libswarm a "Docker" abstraction where on multiple platforms
images can invoke consistent actions that affect the platform. That applies
to more generic operations, whereas k8s specific actions will always
require some downwards API. The abstraction is a long term play that
requires active participation by a number of stakeholders and also
implemented, demonstrated use cases, so it's not an argument for avoiding
trying.
I don't think the downward API is bad, but some of the use cases (unique
id for an instance, what ip do I have) might benefit from looser coupling
or by trying to find the most lowest common denominator expression. In the
end image authors can always ignore those settings, but you do want image
users to have the tools to bend a recaltricant image to their will.

Reply to this email directly or view it on GitHub
#386 (comment)
.

Create a deployment as follows
 Name: nginx-dns
 Exposed via a service: nginx-dns
 Ensure that the service & pod are accessible via their respective DNS records
 The container(s) within any Pod(s) running as a part of this deployment should use the nginx
image
Next, use the utility nslookup to look up the DNS records of the service & pod and write the
output to /opt/..../service.dns and /opt/..../pod.dns respectively. Ensure you use the
busybox:1.28 image (or earlier) for any testing, an the latest release has an unpstream bug which
impacts the use of nslookup.

😊
kubectl run nginx-dns --image=nginx
kubectl expose deployment/nginx-dns --port=80 --name=nginx-dns
kubectl run busybox -it --rm --image=busybox:1.28 sh
nslookup nginx-dns #svc 记录
nslookup pod-ip-addr #pod 记录
Nslookup 的结果不能直接输出到文件,我是粘贴到notepad 上再用

justaugustus pushed a commit to justaugustus/kubernetes that referenced this issue Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/downward-api kind/design Categorizes issue or PR as related to design. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/node Categorizes an issue or PR as relevant to SIG Node.
Projects
None yet
Development

No branches or pull requests

9 participants