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

ingressclass: New controller. #574

Merged

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Mar 16, 2021

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 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.
  • test/e2e/operator_test.go (TestDefaultIngressClass): New test. Verify that the ingresscontroller has created an ingressclass for the default ingresscontroller.

@Miciah Miciah force-pushed the ingressclass-new-controller branch from 666ceef to 754b06b Compare March 16, 2021 03:33
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 16, 2021
@Miciah Miciah changed the title ingressclass: New controller. WIP: ingressclass: New controller. Mar 17, 2021
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 17, 2021
Miciah added a commit to Miciah/enhancements that referenced this pull request Mar 17, 2021
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.
@Miciah Miciah force-pushed the ingressclass-new-controller branch 2 times, most recently from f08f701 to c1c136a Compare March 26, 2021 19:26
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 26, 2021
@Miciah Miciah force-pushed the ingressclass-new-controller branch from c1c136a to d6b7c6b Compare March 26, 2021 19:29
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 26, 2021
@Miciah Miciah force-pushed the ingressclass-new-controller branch from d6b7c6b to 5e2262e Compare March 26, 2021 20:31
@Miciah
Copy link
Contributor Author

Miciah commented Mar 30, 2021

/test e2e-aws-operator

@Miciah Miciah force-pushed the ingressclass-new-controller branch 2 times, most recently from 4df91ab to a8bcd3f Compare April 5, 2021 19:38
@Miciah Miciah force-pushed the ingressclass-new-controller branch from a8bcd3f to 6b7d760 Compare April 5, 2021 20:19
@Miciah Miciah force-pushed the ingressclass-new-controller branch 2 times, most recently from 2c466a3 to 3495fc8 Compare April 5, 2021 22:02
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.
@Miciah Miciah force-pushed the ingressclass-new-controller branch from 3495fc8 to 44c2306 Compare April 6, 2021 01:54
@Miciah
Copy link
Contributor Author

Miciah commented Apr 6, 2021

Rebased.

@Miciah Miciah changed the title WIP: ingressclass: New controller. ingressclass: New controller. Apr 6, 2021
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 6, 2021
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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@sgreene570
Copy link
Contributor

CI was green before the rebase.

Looks good! Thanks for quick turn around.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2021
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@sgreene570
Copy link
Contributor

FAIL: TestUniqueIdHeader (21.70s):  Internal error occurred: admission plugin "MutatingAdmissionWebhook" failed to complete mutation in 13s

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@Miciah
Copy link
Contributor Author

Miciah commented Apr 6, 2021

/test e2e-aws-operator

@openshift-merge-robot openshift-merge-robot merged commit 74ae4c7 into openshift:master Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants