-
Notifications
You must be signed in to change notification settings - Fork 303
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
Neg crd feature gate #1166
Neg crd feature gate #1166
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. I understand the commands that are listed here. |
Hi @swetharepakula. 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. |
af1f4c6
to
b41dea6
Compare
/ok-to-test |
pkg/context/context.go
Outdated
@@ -127,6 +130,7 @@ func NewControllerContext( | |||
NodeInformer: informerv1.NewNodeInformer(kubeClient, config.ResyncPeriod, utils.NewNamespaceIndexer()), | |||
recorders: map[string]record.EventRecorder{}, | |||
healthChecks: make(map[string]func() error), | |||
NegClient: networkendpointgroupClient, |
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.
NegClient -> NegCrdClient?
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.
Since the other clients other than kube client are backendconfigclient
and frontendconfigclient
I am leaning towards NegClient
or SvcNegClient
.
pkg/neg/manager.go
Outdated
@@ -260,6 +273,30 @@ func (manager *syncerManager) ReadinessGateEnabled(syncerKey negtypes.NegSyncerK | |||
return false | |||
} | |||
|
|||
func (manager *syncerManager) DeleteNegServiceCRs(namespace, name string) error { |
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 can stay as private function. This can be trigger within other public facing interfaces
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 should also be ensureDeleteNegServiceCRs
.
It should first check if the deleteionTimestamp is set, then proceed to delete if necessary.
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 this a private function and called it from StopSyncer, and also checks for deletion timestamp before deleting.
pkg/neg/manager.go
Outdated
}, | ||
} | ||
|
||
_, err = manager.negClient.NetworkingV1beta1().ServiceNetworkEndpointGroups(svcKey.namespace).Create(context.Background(), &negCR, metav1.CreateOptions{}) |
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 might want to do a get and validate if the object is in the desired state. Then create or update
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.
In what situations can we update the existing CR? If any of the ObjectMeta differs, I am thinking that an error should be raised. In other cases, Initialized and Synced conditions are harder to update since we don't really know the state. I am thinking to leave the Initialized condition unchanged, and change the Synced Condition to ConditionUnknown
if we find an existing CR that matches the Neg we wish to create. What do you think?
pkg/neg/manager.go
Outdated
@@ -121,6 +129,11 @@ func (manager *syncerManager) EnsureSyncers(namespace, name string, newPorts neg | |||
// determine the implementation that calculates NEG endpoints on each sync. | |||
epc := negsyncer.GetEndpointsCalculator(manager.nodeLister, manager.podLister, manager.zoneGetter, | |||
syncerKey, portInfo.RandomizeEndpoints) | |||
|
|||
if err := manager.createNegCR(key, portInfo); err != nil { |
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 you need to mirror this behavior for removes. So that you can clean up the CRs that needs to be deleted.
pkg/neg/types/interfaces.go
Outdated
@@ -79,6 +79,8 @@ type NegSyncerManager interface { | |||
GC() error | |||
// ShutDown shuts down the manager | |||
ShutDown() | |||
// DeleteNegServiceCRs marks all NEG CRs corresponding to a service for deletion | |||
DeleteNegServiceCRs(namespace, name string) error |
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 add this.
You might just need to modify the StopSyncer interface.
pkg/neg/manager.go
Outdated
ObjectMeta: metav1.ObjectMeta{ | ||
Name: portInfo.NegName, | ||
Namespace: svcKey.namespace, | ||
Finalizers: []string{common.NegFinalizerKey}, |
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 suggest you do not add the finalizer in this PR because it would break HEAD if NEG CRD is enabled.
Add a TODO here and remember to add the finalizer in the following PR that handles GC.
Maybe just comment out this line and add TODO
- when enabled, NEG CRD is ensured in k8s cluster
b41dea6
to
e9e8e5d
Compare
e9e8e5d
to
7d3feb2
Compare
7d3feb2
to
9836768
Compare
- names specified in service annotations are passed along into the port info map
caa984c
to
991b046
Compare
The initial pull request was quite big, so splitting it into two. This now will only cover the feature gate and the utils changes necessary to start using custom names. |
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.
There is one corner case I want to confirm:
Let us say the NEG annotation is {"ingress": "true", "exposed_ports": {80:{"name": "foo"}}}. Ingress and standalone NEG shared the same service port 80.
Should we allow this config? I think disallowing this config might be good enough. But want to see if it makes things easier for allowing it.
A few small improvements to the ingress controller and the helper utils and structs are necessary to support the change. One benefit we would gain from supporting it, would not having to do any error handling for that situation. |
After discussing with @freehan, I think for now we should not support the config where Ingress is true with a custom named neg, as it would require the Ingress controller to also parse and store the information in service annotations. The custom named standalone neg implementation will not limit opening this restriction up in the future if desired. |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: freehan, swetharepakula 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 |
Add feature gate for NEG CRDs and propagate flag to neg controller and manager.
Depends on #1154 being merged