-
Notifications
You must be signed in to change notification settings - Fork 59
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
Upgrade the operator to use Operator SDK v1.33.0 #182
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
Based on the go/v4 project structure, the following changed: - Pakcage `controllers` is now named `controller` - Package `controller` now lives inside new `internal` directory
Based on the new go/v4 project structure, `main.go` now lives in the `cmd` directory.
Update the dependencies based on the versions obtained by creating a new operator project using `kubebuilder init --domain onepassword.com --plugins=go/v4`. This is based on the migration steps provided to go from go/v3 to go/v4 (https://book.kubebuilder.io/migration/migration_guide_gov3_to_gov4)
sigs.k8s.io/controller-runtime package had breaking changes from v0.14.5 to v0.16.3. This commit brings the changes needed to achieve the same things using the new functionality avaialble.
Since `main.go` is now in `cmd` directory, the paths to the files for deploying Connect have to be adjusted based on the new location `main.go` is executed from.
These changes are made based on the new project structure and scaffolding obtained when using the new go/v4 project structure. These were done based on the migration steps mentioned when migrating to go/v4 (https://book.kubebuilder.io/migration/migration_guide_gov3_to_gov4).
These updates are made based on the Kustomize v4 syntax. This is part of the upgrate to go/v4 (https://book.kubebuilder.io/migration/migration_guide_gov3_to_gov4)
Now the version in the Makefile matches the version of the operator
edif2008
changed the title
Draft: Upgrade the operator to use Operator SDK v1.33.0
Upgrade the operator to use Operator SDK v1.33.0
Jan 5, 2024
edif2008
commented
Jan 5, 2024
It seems that the +build tag is no longer needed based on the latest generated scaffolding, therefore it's removed.
Some customization in Makefile was lost during the migration process. Specifically, the namespace customization for `make deploy` command. Also, we push changes to kustomization.yaml for making the deploy process smoother.
It seems that with the latest changes to Kubernetes and Kustomize, we need to add additional RBAC to the service account used so that it can properly access the `leases` resource.
Functional review: ✅Confirm that the operator works fine after migration. Code review: ✅Most of the changes here are because of updating dependencies in |
volodymyrZotov
approved these changes
Jan 24, 2024
Dockerfile had a step for caching dependencies (go mod download). However, this is already done by the vendor directory, which we include. Therefore, this step can be removed to make the image build time faster.
THANK YOU 1P TEAM! |
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.
Summary
This PR migrates the operator from version Operator SDK
v1.29.0
tov1.33.0
.Previously we were using
go/v4-alpha
. With the latest changes, this went to stable (i.e.go/v4
). This brought a couple of key changes:In addition, we've updated dependencies and adjusted the code based on the breaking changes present in the
sigs.k8s.io/controller-runtime
package fromv0.14.5
tov0.16.3
.Resolves: #180
Details
The changes present in this PR can be divided into four parts:
controllers
tointernal/controller
directorymain.go
from project's root directory tocmd
1.21
sigs.k8s.io/controller-runtime
package. From a customer's experience, this shouldn't be a breaking change.yaml
files due to havingsecurityContext
->runAsNonRoot: true
. This also affects previous versions of the operator. It looks like we haven't noticed this concern (or my environment is weird and it shouldn't be an issue).How to test
Requirements
1password-credentials.json
file) and a Connect token. Follow this documentation to create them.Testing steps
make docker-build
. The steps below show how to do this withminikube
:config/manager/manager.yaml
with the following:imagePullPolicy: Never
so that it uses the image of the operator you've just built:WATCH_NAMESPACE
environment variable with the name of the namespace you want to use:minikube
:op-credentials
and theonepassword-token
Kubernetes secrets in the namespace:Check for any missed changes in the migration
These steps require to install the operator-sdk.
The steps below are adapted based on the Migration steps from
go/v3
togo/v4
with the key change of creating the project and API using theoperator-sdk
command instead ofkubebuilder
.v1.33.0
:OnePasswordItem
API:cmd/main.go
api/v1/onepassworditem_types.go
internal/controller
directorypkg
directoryENVTEST_K8S_VERSION
,KUSTOMIZE_VERSION
,CONTROLLER_TOOLS_VERSION
)Reference
go/v3
vsgo/v4
go/v3
togo/v4
go/v4
by updating the files manually