-
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
Mixed protocol support for Services with type=LoadBalancer #94028
Conversation
Hi @janosi. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
/label api-review |
/assign @thockin |
/ok-to-test |
pkg/apis/core/types.go
Outdated
|
||
//Current service state | ||
// +optional | ||
Conditions []ServiceCondition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The KEP says: "Our feature does not introduce new values or new fields"
am not saying that adding a field is wrong, but it is not part of the committed KEP. I re-read the discussion on the KEP and we agreed to this in theory, but it was never updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use metav1.Condition
from staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it is not part of the committed KEP. I re-read the discussion on the KEP and we agreed to this in theory, but it was never updated
Hmmm, we have in the KEP the following:
In order to provide a way for the CPI to indicate port statuses to the user we would add the following new portStatus list of port statuses to Service.status.loadBalancer.ingress, so the CPI can indicate the status of the LB. Also we add a conditions list of conditions to the Service.status.loadBalancer, with the first official condition LoadBalancerMixedProtocolNotSupported defined.
And then there is the specification of these fields, too.
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, should I remove this API change (ServiceStatus) from this PR? I put it in here, as it is part of the KEP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I guess I skimmed too fast. Sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I started using metav1.Condition
there instead of ServiceConditions, but as I can see, bazel-test fails due to that https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/94028/pull-kubernetes-bazel-test/1296919306033958912
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I started using metav1.Condition there instead of ServiceConditions, but as I can see, bazel-test fails due to that https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/94028/pull-kubernetes-bazel-test/1296919306033958912
chatted in slack, but for posterity, looks like metav1.Condition types should be added to
kubernetes/pkg/controlplane/import_known_versions_test.go
Lines 53 to 73 in c3b888f
// These types are registered in external versions, and therefore include json tags, | |
// but are also registered in internal versions (or referenced from internal types), | |
// so we explicitly allow tags for them | |
var typesAllowedTags = map[reflect.Type]bool{ | |
reflect.TypeOf(intstr.IntOrString{}): true, | |
reflect.TypeOf(metav1.Time{}): true, | |
reflect.TypeOf(metav1.MicroTime{}): true, | |
reflect.TypeOf(metav1.Duration{}): true, | |
reflect.TypeOf(metav1.TypeMeta{}): true, | |
reflect.TypeOf(metav1.ListMeta{}): true, | |
reflect.TypeOf(metav1.ObjectMeta{}): true, | |
reflect.TypeOf(metav1.OwnerReference{}): true, | |
reflect.TypeOf(metav1.LabelSelector{}): true, | |
reflect.TypeOf(metav1.GetOptions{}): true, | |
reflect.TypeOf(metav1.ExportOptions{}): true, | |
reflect.TypeOf(metav1.ListOptions{}): true, | |
reflect.TypeOf(metav1.DeleteOptions{}): true, | |
reflect.TypeOf(metav1.GroupVersionKind{}): true, | |
reflect.TypeOf(metav1.GroupVersionResource{}): true, | |
reflect.TypeOf(metav1.Status{}): true, | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liggitt Thank you for your help. Indeed, it is OK now.
pkg/apis/core/types.go
Outdated
@@ -3508,6 +3512,14 @@ type LoadBalancerIngress struct { | |||
// (typically AWS load-balancers) | |||
// +optional | |||
Hostname string | |||
|
|||
//The list has one entry per service port in the manifest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comments want a " " between //
and text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Godoc style starts with the field name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to tighten the spec. This field is optional, but if it is provided, there must be one entry per service port, mapped by port number and protocol (avoid the word "manifest, tooooo vague).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment here.
pkg/apis/core/types.go
Outdated
|
||
//The list has one entry per service port in the manifest | ||
// +optional | ||
PortStatuses []PortStatus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name "ports"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
pkg/apis/core/types.go
Outdated
// +optional | ||
PortStatuses []PortStatus | ||
|
||
//A human readable message indicating details about the condition of the load-balancer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is human-readable what we want here? We have conditions and ports which have messages - what is THIS for that isn't better in one of those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I just wonder how I should interpret all caps here).
Well, this is the part of the agreed and accepted KEP. Which has been reviewed and accepted by people much better in K8s API design than I.
Of course things change and I am OK to remove it from here. Just like the whole API implementation as said above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/KEPs are not written in stone, and API reviews can tweak the exact structure. I am asking what this particular field is for that is not already covered by the other messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original purpose was to have a "message" on this level, too. I.e. we have a condition with a message on Service level, we have a message on portstatus level, but no message on LB level, in the middle.
Though, I just removed it.
pkg/apis/core/types.go
Outdated
|
||
// PortStatus represents the condition of a service port condition | ||
type PortStatus struct { | ||
Port int32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments on all these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, please check.
var protocol api.Protocol = "init" | ||
for _, port := range service.Spec.Ports { | ||
if protocol == "init" { | ||
if port.Protocol == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not need to handle "" - that will be defaulted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole thing should be as easy as:
protos := map[string]bool{}
for _, port := range service.Spec.Ports {
protos[string(port.Protocol)] = true
}
return len(protos) > 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Replaced my code with this one.
@@ -4232,18 +4232,12 @@ func ValidateService(service *core.Service, allowAppProtocol bool) field.ErrorLi | |||
|
|||
if service.Spec.Type == core.ServiceTypeLoadBalancer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this whole block can go away - the same check (supportedPortProtocols.Has
) exists in validateServicePort() already. Please double-check that I am not missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Service ports are checked before this place for any Service. Removed this one here.
@@ -3971,6 +3977,15 @@ type LoadBalancerIngress struct { | |||
// (typically AWS load-balancers) | |||
// +optional | |||
Hostname string `json:"hostname,omitempty" protobuf:"bytes,2,opt,name=hostname"` | |||
|
|||
//The list has one entry per service port in the manifest | |||
// +listType=map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not atomic? Do we really need to patch individual records? The key for the map is multi-field, which is unpleasant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To tell the truth, it was more like a guess. Modified to atomic.
Port int32 `json:"port" protobuf:"varint,1,opt,name=port"` | ||
// The IP protocol for this port. Supports "TCP", "UDP", and "SCTP". | ||
// Default is TCP. | ||
// +optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is optional with a default, you need to write the rule in defaults.go to set it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it required. As you commented above port + protocol should be the key.
3a76398
to
5e34c49
Compare
FWIW regarding squash, you can set the |
Good to know. Thank you! :) |
/retest |
KEP: https://github.com/kubernetes/enhancements/blob/master/keps/sig-network/20200103-mixed-protocol-lb.md Add new feature gate to control the support of mixed protocols in Services with type=LoadBalancer Add new fields to the ServiceStatus Add Ports to the LoadBalancerIngress, so cloud provider implementations can report the status of the requested load balanc er ports Add ServiceCondition to the ServiceStatus so Service controllers can indicate the conditions of the Service
75a3e30
to
382f6f5
Compare
@thockin new rebase was required |
/lgtm |
/retest |
1 similar comment
/retest |
@andrewsykim @thockin @kikisdeliveryservice @liggitt Thank you all for your help! |
Thanks everyone for this! |
What type of PR is this?
/kind feature
/kind api-change
What this PR does / why we need it:
This PR implements the following KEP: kubernetes/enhancements@4ccf8f5
It enables the usage of different protocol values in the same LoadBalancer Service.
It extends the Service's Status definition so cloud provider implementations can include more details about the status of the cloud load balancer into that.
KEP issue: kubernetes/enhancements#1435
Which issue(s) this PR fixes:
Fixes #23880
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: