-
Notifications
You must be signed in to change notification settings - Fork 191
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
ingressclass: New controller. #574
ingressclass: New controller. #574
Conversation
666ceef
to
754b06b
Compare
This enhancement updates the [ingress-to-route](https://github.com/openshift/openshift-controller-manager/blob/master/pkg/route/ingress/ingress.go) controller to use the stable `networking.k8s.io/v1` version of the Ingress API. Although the API server already supports the v1 API version without this enhancement, the ingress-to-route controller requires changes to transition from using the v1beta1 client to using the v1 client and to support new v1 features. These new features include the `spec.pathType` and `spec.ingressClassType` fields as well as the associated IngressClass API. This enhancement does *not* extend the Route API to accommodate new features in the Ingress API; these are only supported to the extent that they are compatible with the Route API. --- Implementation PRs: - [ ] [openshift/cluster-ingress-operator#574 WIP: ingressclass: New controller.](openshift/cluster-ingress-operator#574) - [ ] [openshift/openshift-controller-manager#172 WIP: ingress: Migrate to networking.k8s.io/v1.](openshift/openshift-controller-manager#172) - [ ] TODO openshift/api PR for `openshift.io/ingress-to-route` ingressclass controller name. - [ ] TODO openshift/cluster-monitoring-operator PR for alerts.
f08f701
to
c1c136a
Compare
c1c136a
to
d6b7c6b
Compare
d6b7c6b
to
5e2262e
Compare
/test e2e-aws-operator |
4df91ab
to
a8bcd3f
Compare
a8bcd3f
to
6b7d760
Compare
2c466a3
to
3495fc8
Compare
Bump to github.com/openshift/api@47be53705a1362bfe78926a87dc5d12e0480accf to get the named constant for the "openshift.io/ingress-to-route" controller name. * go.mod: Bump. * go.sum: * manifests/00-custom-resource-definition.yaml: * pkg/manifests/bindata.go: * vendor/*: Regenerate.
Add a controller that creates and manages an ingressclass for each ingresscontroller. * manifests/00-cluster-role.yaml: Give the operator access to ingressclasses. * pkg/manifests/bindata.go: Regenerate. * pkg/operator/controller/ingressclass/controller.go: New file. Define a controller that manages ingressclasses for ingresscontrollers. (controllerName): New const for the new controller's name. (New): New function. Create and return a controller that watches ingresscontrollers and ingressclasses and reconciles them, using the new ingressClassHasIngressController function and ingressClassToIngressController method to map events for ingressclasses to reconcile requests for ingresscontrollers. (ingressClassHasIngressController): New function. Given an ingressclass, return a Boolean value indicating whether it references an ingresscontroller. (ingressClassToIngressController): New method. Given a client object, check if the object is an ingressclass with an associated ingresscontroller, and return a slice of reconciliation requests with a request for any ingresscontroller that is associated with the ingressclass. (Config): New type. Store the configuration needed to create an ingressclass controller. (reconciler): New type. Store the state of an ingressclass controller. (Reconcile): New method. Handle a reconciliation request for an ingresscontroller by ensuring that it has the expected ingressclass. * pkg/operator/controller/ingressclass/ingressclass.go: New file. (ensureIngressClass): New method. Ensure the expected ingressclass exists for the given ingresscontroller, using the new desiredIngressClass function and currentIngressClass and updateIngressClass methods. (desiredIngressClass): New function. Given an ingresscontroller's name, return a desired ingressclass. (currentIngressClass): New method. Given an ingresscontroller's name, return its current ingressclass if it exists. (updateIngressClass): New method. Given current and desired ingressclasses, update the current ingress class if needed, using the new ingressclassChanged function. (ingressclassChanged): New function. Compare current and expected ingressclasses to determine if they match, and return an updated ingressclass if they do not. * pkg/operator/controller/names.go (IngressClassName): New function. Given an ingresscontroller's name, return the name of the corresponding ingressclass. * pkg/operator/operator.go (New): Initialize the new controller. * test/e2e/operator_test.go (TestDefaultIngressClass): New test. Verify that the ingressclass controller has created an ingressclass for the default ingresscontroller.
3495fc8
to
44c2306
Compare
Rebased. |
if err := c.Watch(&source.Kind{Type: &operatorv1.IngressController{}}, &handler.EnqueueRequestForObject{}); err != nil { | ||
return nil, err | ||
} | ||
if err := c.Watch(&source.Kind{Type: &networkingv1.IngressClass{}}, handler.EnqueueRequestsFromMapFunc(reconciler.ingressClassToIngressController), predicate.NewPredicateFuncs(ingressClassHasIngressController)); 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.
👍
CI was green before the rebase. Looks good! Thanks for quick turn around. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Miciah, sgreene570 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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test e2e-aws-operator |
Add a controller that creates and manages an ingressclass for each ingresscontroller.
pkg/operator/controller/ingressclass/controller.go
: New file. Define a controller that manages ingressclasses for ingresscontrollers.(
controllerName
): New const for the new controller's name.(
New
): New function. Create and return a controller that watches ingresscontrollers and ingressclasses and reconciles them, using the newingressClassHasIngressController
function andingressClassToIngressController
method to map events for ingressclasses to reconcile requests for ingresscontrollers.(
ingressClassHasIngressController
): New function. Given an ingressclass, return a Boolean value indicating whether it references an ingresscontroller.(
ingressClassToIngressController
): New method. Given a client object, check if the object is an ingressclass with an associated ingresscontroller, and return a slice of reconciliation requests with a request for any ingresscontroller that is associated with the ingressclass.(
Config
): New type. Store the configuration needed to create an ingressclass controller.(
reconciler
): New type. Store the state of an ingressclass controller.(
Reconcile
): New method. Handle a reconciliation request for an ingresscontroller by ensuring that it has the expected ingressclass.pkg/operator/controller/ingressclass/ingressclass.go
: New file.(
ensureIngressClass
): New method. Ensure the expected ingressclass exists for the given ingresscontroller, using the newdesiredIngressClass
function andcurrentIngressClass
andupdateIngressClass
methods.(
desiredIngressClass
): New function. Given an ingresscontroller's name, return a desired ingressclass.(
currentIngressClass
): New method. Given an ingresscontroller's name, return its current ingressclass if it exists.(
updateIngressClass
): New method. Given current and desired ingressclasses, update the current ingress class if needed, using the newingressclassChanged
function.(
ingressclassChanged
): New function. Compare current and expected ingressclasses to determine if they match, and return an updated ingressclass if they do not.pkg/operator/controller/names.go
(IngressClassName
): New function. Given an ingresscontroller's name, return the name of the corresponding ingressclass.test/e2e/operator_test.go
(TestDefaultIngressClass
): New test. Verify that the ingresscontroller has created an ingressclass for the default ingresscontroller.