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

Disallow headless Services with LB type #33274

Merged
merged 1 commit into from
Sep 30, 2016

Conversation

nebril
Copy link
Contributor

@nebril nebril commented Sep 22, 2016

What this PR does / why we need it: It adds new validation rule for Services, to ensure that creating LoadBalancer type service with cluster IP set to "None" fails.

Which issue this PR fixes (optional, in fixes #<issue number>(, #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #33036

Release note:

Creating LoadBalancer Service with "None" ClusterIP is no longer possible

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-label-needed labels Sep 22, 2016
@smarterclayton
Copy link
Contributor

Would adding this validation break existing users? Strengthening validation is an API change so we have to ensure we cannot break an existing use case / automation setup that depends on it.

@smarterclayton smarterclayton added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Sep 22, 2016
@nebril
Copy link
Contributor Author

nebril commented Sep 22, 2016

@smarterclayton I will try to figure this out. Are there any procedures for checking whether the API change is breaking, or should I just move around the GH and check whether the change breaks existing manifests?

@smarterclayton
Copy link
Contributor

Easiest to justify is:

  • Was this a valid scenario before where someone accidentally could have
    this set, and if we change it will break them? If not, then it's less
    important (so if you can prove no one would be broken)
  • Can you find examples of this in the real world (can be hard, I don't
    always expect this but trying it is good)

On Thu, Sep 22, 2016 at 1:02 PM, Maciej Kwiek notifications@github.com
wrote:

@smarterclayton https://github.com/smarterclayton I will try to figure
this out. Are there any procedures for checking whether the API change is
breaking, or should I just move around the GH and check whether the change
breaks existing manifests?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#33274 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p1P1kuULfHaVkNG7T-S5pos2eKvMks5qsrS1gaJpZM4KD8Ko
.

@nebril
Copy link
Contributor Author

nebril commented Sep 23, 2016

@smarterclayton according to docs: http://kubernetes.io/docs/user-guide/services/#headless-services it doesn't make sense in any case to create a headless load balancer. Excerpt from the doc: "For such Services a cluster IP is not allocated, the kube proxy does not handle these services, and there is no load balancing or proxying done by the platform for them.". I will try to ask around if anyone ever tried to use this case for anything, but it doesn't seem to make any sense.

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 23, 2016
@smarterclayton
Copy link
Contributor

There's no lie balancing done by the platform - could an integrator off the platform use this correctly (or in a more powerful way) if they wanted?

@smarterclayton
Copy link
Contributor

"Load"

@nebril
Copy link
Contributor Author

nebril commented Sep 26, 2016

According to the docs, ClusterIP is a virtual IP address used by Kubernetes to fetch traffic to backend pods. So headless LoadBalancer doesn't seem to make sense, because it doesn't have an address to balance the load to and therefore should be disallowed by API.

@smarterclayton
Copy link
Contributor

LoadBalancer services don't actually have to load balance to the cluster
IP, though. That's just an artifact of implementation. A LoadBalancer
service is given an external load balancing address, and many of the
implementations just happen to use the clusterIP, but it does not require
that function.

On Mon, Sep 26, 2016 at 3:19 AM, Maciej Kwiek notifications@github.com
wrote:

According to the docs, ClusterIP is a virtual IP address used by
Kubernetes to fetch traffic to backend pods. So headless LoadBalancer
doesn't seem to make sense, because it doesn't have an address to balance
the load to and therefore should be disallowed by API.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#33274 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p2WJVaLBPEXGYjcx0QmDQpTtuBrMks5qt3HlgaJpZM4KD8Ko
.

@nebril
Copy link
Contributor Author

nebril commented Sep 27, 2016

@smarterclayton can you give me an example of such implementation? I was not aware of that.

@thockin does the issue this PR aims to fix actually make sense given what Clayton is saying?

@thockin
Copy link
Member

thockin commented Sep 27, 2016

I don't think there any combination of headless+LB that valid today. This is technically a breaking change, but every platform we support fails to handle this.

@@ -2402,6 +2402,9 @@ func ValidateService(service *api.Service) field.ErrorList {
allErrs = append(allErrs, field.Invalid(portPath, port.Port, "may not expose port 10250 externally since it is used by kubelet"))
}
}
if service.Spec.ClusterIP == "None" {
allErrs = append(allErrs, field.Invalid(specPath.Child("clusterIP"), service.Spec.ClusterIP, "may not be set to 'None' for LoadBalancer"))
Copy link
Member

Choose a reason for hiding this comment

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

nit: add the word "services" at the end

@smarterclayton
Copy link
Contributor

smarterclayton commented Sep 27, 2016 via email

@nebril
Copy link
Contributor Author

nebril commented Sep 28, 2016

Is release note in PR description enough?

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 28, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins unit/integration failed for commit 95f4b6a. Full PR test history.

The magic incantation to run this job again is @k8s-bot unit test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GCE e2e failed for commit 95f4b6a. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@smarterclayton
Copy link
Contributor

Yes

On Wed, Sep 28, 2016 at 9:07 AM, k8s-ci-robot notifications@github.com
wrote:

Jenkins GKE smoke e2e failed
https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/33274/kubernetes-pull-build-test-e2e-gke/14517/
for commit 95f4b6a
95f4b6a.
Full PR test history http://pr-test.k8s.io/33274.

The magic incantation to run this job again is @k8s-bot gke e2e test this.
Please help us cut down flakes by linking to an open flake issue
https://github.com/kubernetes/kubernetes/issues?q=is:issue+label:kind/flake+is:open
when you hit one in your PR.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#33274 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_pzktGnmnasI_Jn7unwfS_TC8HnBrks5qumZ5gaJpZM4KD8Ko
.

@k8s-ci-robot
Copy link
Contributor

Jenkins GKE smoke e2e failed for commit 95f4b6a. Full PR test history.

The magic incantation to run this job again is @k8s-bot gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@thockin thockin changed the title Validate empty Service ClusterIP against LB type Disallow headless Services with LB type Sep 28, 2016
@@ -2406,6 +2406,9 @@ func ValidateService(service *api.Service) field.ErrorList {
allErrs = append(allErrs, field.Invalid(portPath, port.Port, "may not expose port 10250 externally since it is used by kubelet"))
}
}
if service.Spec.ClusterIP == "None" {
allErrs = append(allErrs, field.Invalid(specPath.Child("clusterIP"), service.Spec.ClusterIP, "may not be set to 'None' for LoadBalancer service"))
Copy link
Member

Choose a reason for hiding this comment

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

nit, since CI is still flaking. "services" not "service"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aw man, sorry about that. Will fix and rebase, flakes are still strong here.

@thockin
Copy link
Member

thockin commented Sep 28, 2016

@k8s-bot unit this

@thockin
Copy link
Member

thockin commented Sep 28, 2016

@k8s-bot gci gce e2e test this

@thockin thockin added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 28, 2016
@thockin
Copy link
Member

thockin commented Sep 28, 2016

I've LGTM'ed this, despite asking for a 1 character change. If this goes through, please followup. If it doesn't, please fix :)

If the Service is a Load Balancer, it should not have None Cluster IP.
If it does, Service validation fails.
@nebril
Copy link
Contributor Author

nebril commented Sep 29, 2016

Fixed the typo, rebased, flakes are gone. Please re-review.

@smarterclayton smarterclayton added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 29, 2016
@smarterclayton
Copy link
Contributor

Lgtm

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Services with clusterIP: None can be created with type LoadBalancer
6 participants