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

Add fake operator for testing Operator Policy #286

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JeffeyL
Copy link
Contributor

@JeffeyL JeffeyL commented Aug 9, 2024

Not having control over operators used in testing makes tests inconsistent. This commit adds a fake operator for testing that is locally built, and uses a locally hosted registry in KinD. It lives in its own catalog.

Ref: https://issues.redhat.com/browse/ACM-11160

Details:

Majority of the code goes under the fake-operator-test folder, which I'll be explaining by subfolder below. I'll then outline things that have yet to be completed.

fake-catalog
This folder contains everything required to build a catalog, originally scaffolded using the opm tool. I have not modified anything after initial scaffolding.

fake-operator
This folder contains everything that goes into building the fake operator bundle. This was originally scaffolded using operator-sdk following these instructions, but I removed the majority of it, and changed the dockerfile to specify a container that sleeps indefinitely (using tail -f /dev/null as an entrypoint). Another important point is that the make target make bundle uses the config subfolder to generate the bundle. I modified the rbac folder where I commented out service_account.yaml in the kustomization file, since it was giving me weird serviceaccount errors on the deployments. I also modified manager/manager.yaml to not contain a command under the containers part of the spec, since on deployment this would give an error where the command wouldn't run. Documentation here (you might need to ctrl-f 'command') seems to claim that the dockerfile ENTRYPOINT is used instead.

scripts
This folder contains two shell files local-registry.sh and create-catalog.sh. local-registry.sh creates a locally hosted registry following these instructions hosted at localhost:5001. create-catalog.sh does everything else required to make the catalogsource available, from building the operator bundle, building the catalog bundle, and applying it. It also applies a serviceaccount that seems to be needed to install deployments properly (but doesn't seem to be applied automatically). I wasn't too sure about this, so it should probably be examined a bit more thoroughly. Also, the deployment seems to fail anyways.

Files:

fake-operator-template.yaml
This file is required for building the catalogsource.

kind-registry-config.yaml
Part of hosting the kind registry

kind-registry-configmap.yaml
Also part of hosting the kind registry

TODOs:

  1. If you apply fake-operator-test/samples/sample-oppol.yaml, this will work (almost). The operator deployment pod fails due to reasons that I couldn't find out in the end. There doesn't seem to be an error message when checking events, and the pod just fails by timing out eventually.
  2. After this, you could probably start using the fake operator in the tests normally. This might involve tweaking some Makefile stuff, as currently, the catalog is only setup on make kind-bootstrap-cluster-dev

Copy link

openshift-ci bot commented Aug 9, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JeffeyL
Once this PR has been reviewed and has the lgtm label, please assign dhaiducek for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

Not having control over operators used in testing makes tests inconsistent. This
commit adds a fake operator for testing that is locally built, and uses a locally
hosted registry in KinD. It lives in its own catalog.

Ref: https://issues.redhat.com/browse/ACM-11160
Signed-off-by: Jeffrey Luo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant