-
Notifications
You must be signed in to change notification settings - Fork 58
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
Migrate operator to the latest operator-sdk #124
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To be able to perform the migration, we need to start from an empty directory/repo.
Command executed: `operator-sdk init --domain onepassword.com --repo github.com/1Password/onepassword-operator --plugins=go/v4-alpha --license=none` - `--plugin=go/v4-alpha` is used to enable support for Apple Sillicon environments. - `--license=none` is used since the only option is Apache, and we use the MIT license. `hack/boilerplate.go.txt` is updated with the MIT license instead.
Command executed: `operator-sdk create api --version v1 --kind OnePasswordItem --resource --controller` `--group` flag is skipped because we don't have a group in the previous version of the operator and we want to make things consistent and not bring any breaking changes.
- Define the API by modifying the `onepassworditem_types.go`. - Commands executed after the API is defined: `make generate && make manifests`.
- Migrate the functionality of the Controller for the OnePasswordItem resource. - Add the RBAC markers that will generate the RBAC permissions. - Run `make manifests` to generate the RBAC permissions.
- Add the packages that help the operator work as expected. - Update `go.mod` by running `go mod tidy`.
These yaml files are used when the environment variable `MANAGE_CONNECT` for the operator is set to `true`.
- `version` is used for getting the operator version and the operator SDK version in the logs. - `k8suitl` is extracted from the operator-sdk to be able to fetch the namespace the operator is deployed to. This is used to deploy Connect in the same namespace if `MANAGE_CONNECT` is set to `true`. In the future, we may want to no rely on this, since this functionality is internal in the operator-sdk.
- `deploy/deployment.yaml` is now `config/manager/manager.yaml` - `deploy/crds/onepassword.com_v1_onepassworditem_cr.yaml` is now `config/samples/onepassword_v1_onepassworditem.yaml`
Ginkgo has switched to v2 and we should make use of it instead. It doesn't affect how we make tests, but we get the latest enhancements and improvements on the ways tests are executed.
- Migrate `CHANGELOG.md`, `.VERSION`, `LICENSE`, GitHub pipelines, release script, GitHub issue templates. - Add in Makefile the commands to prepare release and make the release tag.
4 tasks
Migrate operator updates
Feature/controllers tests
This is done so that we don't delete the namespace when running `make undeploy`
Update operator-sdk version
Update pipelines with latest versions of actions
This is made to eliminate the chance of tests being flaky when run in aprallel
generate random version each time calling mock onepassword item
jillianwilson
approved these changes
Oct 26, 2022
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'm approving under the assumption that all the features of the operator have been tested thoroughly.
…e-deployment Feature/migrate operator rename deployment
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the operator is created based on the
operator-sdk
v0.18.0
. The latest version isv1.25.0
.Packages were required to be updated which brought us to the need of migrating the
operator-sdk
to v1.The migration process was performed by following the operator migration documentation.
Key changes in this migration:
main.go
is now in the root directory instead ofcmd
directoryapi
andcontrollers
packages now are at the root directory instead ofpkg
. Also, these new directories are simplified.yaml
files are now inconfig
directory instead ofdeploy
directory.yaml
files used for deploying the operator are more granular.main.go
is slightly simplified and adjusted to new way of initializing the operator.ginkgo
, which is a more mature way of testing the actual behavior of the operator in a cluster.make deploy
to deploy everything they need to use the operator and theOnePasswordItem
CRD. To remove it, they can runmake undeploy
.For more details, check out the new elements brought with v1 of the
operator-sdk
.The commit messages should reflect the migration process.