Skip to content

Conversation

@dtfranz
Copy link
Contributor

@dtfranz dtfranz commented Jan 27, 2023

Combines @perdasilva 's latest commits with a selection from @varshaprasad96 and @ankitathomas 's controller_prototype to enable the operator-controller to create bundledeployments using a (currently hard-coded) CatalogSource. Also adds additional Makefile targets to enable simpler installation of dependencies (cert-manager and rukpak).

It should be possible to demonstrate milestone 1 by running the following two commands:

$ make run
$ kubectl apply -f config/samples/operators_v1alpha1_operator.yaml

@dtfranz dtfranz changed the title BundleDeployment creation with BundleImage Draft: BundleDeployment creation with BundleImage Jan 27, 2023
@dtfranz dtfranz marked this pull request as draft January 27, 2023 00:49
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 27, 2023
Comment on lines 143 to 154
.PHONY: cert-mgr
cert-mgr: ## Install cert-manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s

.PHONY: rukpak
rukpak: ## Install rukpak
kubectl apply -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml
kubectl wait --for=condition=Available --namespace=rukpak-system deployment/core --timeout=60s

Copy link
Member

Choose a reason for hiding this comment

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

Add a TODO to swap this out with whatever we come up with for the "distribution" or install script or whatever that ends up being?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Name: o.GetName(),
},
Spec: rukpakv1alpha1.BundleDeploymentSpec{
//TODO: Don't assume plain provisioner
Copy link
Member

Choose a reason for hiding this comment

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

+1

Long term, I envision a separate configuration API that sets up mappings from bundle properties to provisioner class names.

Mid term, perhaps we get some mileage around a property that sets the provisioner class name directly. We have to be careful with this though because I expect ProvisionerClass could end up being a new API in rukpak, which means provisionerClassName becomes a runtime thing, not something hardcoded in rukpak.

Short term, what you have here will be fine for quite awhile, I imagine.

},
Spec: rukpakv1alpha1.BundleSpec{
Source: rukpakv1alpha1.BundleSource{
// TODO: Don't assume image type
Copy link
Member

Choose a reason for hiding this comment

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

IMO, we should make that bundle path property something a bit more definitive (e.g. bundle image reference). At that point, it would be totally safe to assume that we use the rukpak image type if we have that property. And that would then leave the door open for bundles to have different properties that map to a different source type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed here. I've created another issue here #108 to address this, since I was hoping it wouldn't be a blocker for our shorter term goals.

r.resolver = resolution.NewOperatorResolver(mgr.GetClient(), resolution.HardcodedEntitySource)

err := ctrl.NewControllerManagedBy(mgr).
Owns(&rukpakv1alpha1.BundleDeployment{}).
Copy link
Member

Choose a reason for hiding this comment

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

Convention/nit/my opinion: Always declare For as the first watch. Its the primary CR type. Then Owns, then Watches.

Sort of ordering from most coupling (self) to least coupling (things I watch, but don't own).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that makes sense to me too. I'll update it.

Scheme *runtime.Scheme

resolver *resolution.OperatorResolver
Resolver *resolution.OperatorResolver
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be exported? Could we just create a GetEntity(id DeppyID) function for the OperatorReconciler type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is answering your second question, but for the first one it was done this way to allow the resolver to be set up separately from the controller in main(), which you can see in the prototype here. This seems to make it easier to set up the catalog source cache.

Copy link
Member

Choose a reason for hiding this comment

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

That could be done with a NewOperatorReconciler(c client, s scheme, r resolver) &OperatorReconciler function, right? Point being that once the cache is set we shouldn't allow it to be manipulated directly.

Copy link
Member

Choose a reason for hiding this comment

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

Well, avoid allowing people to manipulate the resolver that is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I see your point there, I'll update 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Makefile Outdated
.PHONY: cert-mgr
cert-mgr: ## Install cert-manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s
Copy link
Contributor

Choose a reason for hiding this comment

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

Make the timeouts a variable; "60s" is a reasonable default, but for some others?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, can now be overridden with WAIT_TIMEOUT

kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
Copy link
Contributor

Choose a reason for hiding this comment

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

Not something you did (probably kubebuilder), but manager-role is just too generic a name for a ClusterRole

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is kubebuilder - and it also gets prepended with a prefix set in config/defaults/kustomization.yaml: namePrefix: operator-controller-, so it ends up as operator-controller-manager-role. Personally I also don't like this way of doing it much but it's also kind of a pain to go through and replace all the names with different values. Plus some of them don't get prepended and I've never quite figured out the rule for when that happens...

Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid touching it for now, keep in mind that all kubebuilder controllers follow this convention, so there are some assumptions about the name of this role.

bundlePath, err := v.BundleEntity().BundlePath()
if err != nil {
return ctrl.Result{}, err
} // Create bundleDeployment
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment should really be on next line, as it does not apply to the block it follows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@dtfranz dtfranz marked this pull request as ready for review January 31, 2023 17:34
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 31, 2023
@dtfranz dtfranz changed the title Draft: BundleDeployment creation with BundleImage BundleDeployment creation with BundleImage Jan 31, 2023
@awgreene
Copy link
Member

/approve

@awgreene awgreene added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 31, 2023
@awgreene
Copy link
Member

Oh, can we fix the commit header?

Combines @perdasilva 's latest commits with a selection from @varshaprasad96 and @ankitathomas 's controller_prototype to enable the operator-controller to create bundledeployments using a (currently hard-coded) CatalogSource. Also adds additional Makefile targets to enable simpler installation of dependencies (cert-manager and rukpak).

Signed-off-by: dtfranz <dfranz@redhat.com>
@awgreene awgreene merged commit 13ea200 into operator-framework:main Jan 31, 2023
LalatenduMohanty pushed a commit to LalatenduMohanty/operator-controller that referenced this pull request Dec 19, 2024
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants