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

feat: migrate operator code base to support new operator-sdk version #404

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

vprashar2929
Copy link
Collaborator

@vprashar2929 vprashar2929 commented Jun 14, 2024

This PR updates the code base for compatibility with the latest operator-sdk version(v1.35.0)

Key Changes:

  • Moved API files from pkg/api to api folder
  • Relocated main.go from cmd/manager/main.go to cmd/main.go
  • Shifted controllers from pkg/controllers to controllers folder
  • Made minor updates to components, utils and tests to use correct import paths
  • Updated scaffolding config to align with the latest operator-sdk version
  • Revised Operator, bundle and e2e Dockerfiles
  • Upgraded operator-sdk to v1.35.0 and controller-gen to v0.13.0
  • Updated bundle manifests accordingly

@vprashar2929 vprashar2929 marked this pull request as draft June 14, 2024 11:42
@vprashar2929 vprashar2929 force-pushed the upgrade branch 2 times, most recently from b98e8dd to 991afd8 Compare June 14, 2024 17:56
@vprashar2929 vprashar2929 force-pushed the upgrade branch 2 times, most recently from f1033fd to f60dc51 Compare June 24, 2024 08:02
@vprashar2929 vprashar2929 marked this pull request as ready for review June 24, 2024 10:22
@vprashar2929 vprashar2929 requested a review from sthaha June 24, 2024 10:22
description: 'Deploys and Manages Kepler on Kubernetes '
operators.operatorframework.io/builder: operator-sdk-v1.27.0
operators.operatorframework.io/builder: operator-sdk-v1.34.2
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about we move to 1.35 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AFAIU we can opt-out the internal folder as all the controller code should be in the project root dir https://sdk.operatorframework.io/docs/building-operators/golang/migration/#controllers
Any thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets not keep the controller internal. internal packages have special meaning - https://go.dev/doc/go1.4#internalpackages

@@ -8,7 +8,7 @@ stages:
- entrypoint:
- scorecard-test
- basic-check-spec
image: quay.io/operator-framework/scorecard-test:v1.25.1
image: quay.io/operator-framework/scorecard-test:v1.34.2
Copy link
Collaborator

Choose a reason for hiding this comment

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

1.35.0 ? :)

hack/bundle.sh Outdated
@@ -58,7 +58,7 @@ main() {
info "Found old version: $old_bundle_version"

info "Building bundle version $VERSION"
run operator-sdk generate kustomize manifests --apis-dir=./pkg/api --verbose
run operator-sdk generate kustomize manifests --apis-dir=./api --verbose
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIRC, api is the default dir. Could you please check?

Dockerfile Outdated
Comment on lines 21 to 22
# Copy must-gather scripts
COPY must-gather/ must-gather/
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets preserve the order based on chance of modifying these files.

Comment on lines 22 to 24

# selector:
# control-plane: controller-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete

@vprashar2929 vprashar2929 force-pushed the upgrade branch 2 times, most recently from 83c66f7 to 4df0d0b Compare July 30, 2024 06:43
PROJECT Outdated
@@ -9,6 +13,7 @@ repo: github.com/sustainable.computing.io/kepler-operator
resources:
- api:
crdVersion: v1
namespaced: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

this shouldn't marked as namespaced. Our APIs are cluster-scoped.

@@ -3,7 +3,7 @@ kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: serviceaccount
app.kubernetes.io/instance: controller-manager
app.kubernetes.io/instance: controller-manager-sa
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tested upgrade path with this? Will there be 2 SA after we upgrade ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When the Operator is upgraded it doesn't change the name of the SA as the name is fixed to controller-manager

This PR updates the code base for compatibility with the latest operator-sdk version(v1.35.0)

Key Changes:
* Moved API files from `pkg/api` to `api` folder
* Relocated `main.go` from `cmd/manager/main.go` to `cmd/main.go`
* Shifted controllers from `pkg/controllers` to `internal/controller` folder
* Made minor updates to components, utils and tests to use correct import paths
* Updated scaffolding config to align with the latest operator-sdk version
* Revised Operator, bundle and e2e Dockerfiles
* Upgraded operator-sdk to v1.35.0 and controller-gen to v0.13.0
* Updated bundle manifests accordingly

Signed-off-by: Vibhu Prashar <vibhu.sharma2929@gmail.com>
@sthaha sthaha merged commit ac1c1fd into sustainable-computing-io:v1alpha1 Jul 31, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants