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

Proposal: optional service links #1249

Closed
wants to merge 2 commits into from
Closed

Proposal: optional service links #1249

wants to merge 2 commits into from

Conversation

kongslund
Copy link

This proposal has its root in an environment conflict that I encountered while trying to get an Docker image to run on Kubernetes. @thockin was kind to provide a bit of input on the mailing list and at DockerCon EU.

I've got a proof of concept working which always disables the injection of service links. I'm new to the code base so I'd probably need a bit of assistance to make a proper PR. This is of course assuming that this proposal is accepted.

I'm looking forward to your input.

Ping Node SIG leads: @dchen1107 @derekwaynecarr

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 21, 2017
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems non-controversial.

@erictune @bgrant0607 @smarterclayton
@kubernetes/api-reviewers


## Implementation

`PodSpec` is extended with an additional field, `disableServiceLinks` of type boolean. Default value is false.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open question: I'd prefer this as enableServiceEnvVars with default true. Objections?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would this make sense as defaulting from PodPreset? @jessfraz and ???

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable is preferred over disable, yes.

@droot regarding PodPreset

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field should be a pointer to a boolean, default to true if nil, and have a positive value (enableServiceEnvVars).


`PodSpec` is extended with an additional field, `disableServiceLinks` of type boolean. Default value is false.

In `kubelet_pods.go`, the value of that field is passed along to the function `getServiceEnvVarMap` where it is used to decide which selector should be used for the `serviceLister`. Current behavior is `labels.Everything()`. In case `disableServiceLinks` is true then only the `kubernetes` service in the `kl.masterServiceNamespace` should be injected.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open: Should this include the kubernetes variables? Or maybe we need a different field for that? Anyone have thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the service variables.

DNS, PodPreset, and potentially explicit service links should replace them all. The existence of any is a problem for scalability, creation-order dependencies, and other reasons.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this omits KUBERNETES_SERVICE_HOST then in cluster config will break. That impacts sidecars like istio.

It’s not clear to me that we should omit those variables. If we do, we may have to make this a container field, not pod field.

@bgrant0607
Copy link
Member

See also #176

@bgrant0607
Copy link
Member

Also ref kubernetes/kubernetes#1768

@thockin
Copy link
Member

thockin commented Oct 26, 2017 via email

@bgrant0607
Copy link
Member

cc @kubernetes/sig-api-machinery-api-reviews

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Oct 26, 2017
@bgrant0607
Copy link
Member

We may need a special case for just the apiserver-related variables.


### Use Cases

* As a user, I want to be able to disable service link injection since the injected environment variables interfer with a Docker image that I am trying to run on Kubernetes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: interfere

@k8s-github-robot k8s-github-robot added the sig/node Categorizes an issue or PR as relevant to SIG Node. label Oct 27, 2017
@thockin
Copy link
Member

thockin commented Oct 30, 2017 via email

@kongslund
Copy link
Author

Thanks for comments so far. Any other remarks?


## Alternatives considered

An alternative is to add support for explicit service links, e.g. by applying a label selector map with a default behavior of including everything.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting with a way to disable the current behavior and considering extending via selector typ behavior might be nice, but definitely needs a few specific examples, where that might be necessary from a k8s perspective.

@thockin
Copy link
Member

thockin commented Nov 13, 2017

@kongslund I think you're on-target. You have a week before code freeze for 1.9 :)

@kongslund
Copy link
Author

kongslund commented Nov 13, 2017

Thanks for the heads up, @thockin.
So does everyone think that a boolean flag is sufficient for now?

@thockin
Copy link
Member

thockin commented Nov 13, 2017

I think that's fine. Let's get it working so we can take a concrete look at it. Deltas from there are not so terrible to contemplate.

@thockin
Copy link
Member

thockin commented Feb 28, 2018

Is this abandoned?

@vadorovsky
Copy link
Contributor

Does that proposal need to be merged before I continue the work on my implementation? If yes, @kongslund, are you up to finishing the work on proposal?

I'm sorry that I started the implementation, but I didn't see the proposal before and I just started working on the issue...

@kongslund
Copy link
Author

@mrostecki The proposal is a starting point and already has good feedback from the community. It does not need to be merged before you can provide an implementation but you should incorporate the contents of the proposal or start a discussion if you think something should be different.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 6, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kongslund
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: smarterclayton

Assign the PR to them by writing /assign @smarterclayton in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@bgrant0607
Copy link
Member

cc @kubernetes/sig-architecture-proposals

@k8s-ci-robot k8s-ci-robot added the sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. label Mar 6, 2018

## Implementation

`PodSpec` is extended with an additional field, `enableServiceLinks`. The field should be a pointer to a boolean and default to true if nil.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need to be disableServiceLinks, so that the existing behavior would be in effect if it were the zero value.
cc @erictune

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either is fine with me. However, there seems to be a preference for enable instead of disable cf. #1249 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brian, as a pointer zero value would be interpreted as existing behavior by older clients - can you articulate a bit more what you’d be concerned about as a bool ptr?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we go with enable, we can set its default value to true, so I don't see any backwards compatibility issues there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay. I do want this to happen.

If we make it a pointer and omitempty, will both true and false values be explicitly encoded as long as the field is non-null? I want to ensure that podspecs without the field can be unambiguously interpreted.

Also, doing this will add a field to every Pod and every pod template rendered. It will change podspec hashes, but that should be ok. It will make all pods more verbose, but maybe more users will become aware of the field and use it.

If we could, it would be great to not apply the default in pod templates. In addition to not changing hashes, this would make it feasible to set the field via admission control.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's the case, to what in the apply discussion are you referring?

Client-applied defaults are ~impossible to ever change in our system, even over version boundaries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think that defaults explicitly manifested by the server is the right thing. It just needs to be done where the resources are actually reified, not in templates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do we have some agreement there? Are we OK with the field named disableServiceLinks, pointer, omitempty, with the default false value on the server side? That seems to address @bgrant0607's doubts - it will preserve the old behavior by default and would not require to define that field.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable is probably a better API. I think that's what Brian was saying - pointers make this possible.

Any serialized form of an object which has this value specified will retain that value. Anything that has this value omitted will get nil which will be defaulted to whatever the versioned default is.

Right?

So if you serialize it in v1, when you read it back it will deserialize and default. If you write it back as v2, that v1 default is still retained...

Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I agree. Let's go with enable. I will change that in my implementation.

@bgrant0607
Copy link
Member

cc @kubernetes/sig-scalability-proprosals @kubernetes/sig-network-proposals

@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Jun 1, 2018
@bgrant0607
Copy link
Member

cc @kubernetes/api-approvers

@m1093782566
Copy link

I meet the same issue when try to create more than 6000 services in my environment - Pod failed to start due to "too long parameters". I don't think this "one size fits all" approach works for me because if we disable the service ENV injection, users may have no way to know some service-related environment variables, e.g. SERVICE_PORT.

@thockin
Copy link
Member

thockin commented Jul 31, 2018

@m1093782566 SRV DNS exists for that, if you don't know the port number.

In theory we could add yet another downward API here, but I'd need to see a serious use case for it.

@thockin
Copy link
Member

thockin commented Aug 23, 2018

I still very much want to see this fixed, if you want to carry it forward @m1093782566

@m1093782566
Copy link

m1093782566 commented Aug 24, 2018

@thockin

SRV DNS exists for that, if you don't know the port number.

Yeah, DNS SRV record works for me.

I still very much want to see this fixed, if you want to carry it forward @m1093782566

I have the same feeling - my production team has complained about the limitation of service number for many times.

If we reach the agreement about the proposal, I can carry it forward. I volunteered to send a PR if no one has objections...

@thockin
Copy link
Member

thockin commented Aug 24, 2018

I feel like we sort of agreed on a single bool to enable service env which defaults to true.

It looks like @mrostecki is awake on https://github.com/kubernetes/kubernetes/pull/60206/files so maybe this is almost done already?

@bgrant0607
Copy link
Member

I would still like to get this proposal merged, to capture the discussion.

@thockin
Copy link
Member

thockin commented Aug 24, 2018 via email

@bradhoekstra
Copy link
Contributor

This feature has been merged in k/k: kubernetes/kubernetes#68754

@thockin
Copy link
Member

thockin commented Sep 24, 2018

@bradhoekstra - could you take the contents here and update them as a KEP? We should have done that in the first place...

Then we can close this

@bradhoekstra
Copy link
Contributor

KEP PR created here: #2709

@bradhoekstra
Copy link
Contributor

The KEP for this feature is merged.

/close

@k8s-ci-robot
Copy link
Contributor

@bradhoekstra: You can't close an active issue/PR unless you authored it or you are a collaborator.

In response to this:

The KEP for this feature is merged.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/design Categorizes issue or PR as related to design. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.