-
Notifications
You must be signed in to change notification settings - Fork 1.8k
doc: add migration guide #653
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
doc: add migration guide #653
Conversation
[skip ci]
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.
Flow looks good. A few cosmetic changes are needed.
|
||
### Scaffold api for custom types | ||
|
||
Create the api for your custom resource(CR) in the new project with `operator-sdk add api --api-version=<apiversion> --kind=<kind>` |
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.
Space before (CR)
doc/user-guide.md
Outdated
You then need to tell the operators to use these functions to add the resources to its scheme. In operator-sdk you use [AddToSDKScheme][osdk_add_to_scheme] to add this. | ||
Example of you main.go: | ||
```go | ||
By default the operator's manager will register all custom resource types defined in your project under `pkg/apis` with its scheme. |
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.
{m -> M}anager
doc/user-guide.md
Outdated
To add a 3rd party resource to an operator, you must add it to the manager's scheme. By creating an `AddToScheme` method or reusing one you can easily add a resource to your scheme. An [example][deployments_register] shows that you define a function and then use the [runtime][runtime_package] package to create a `SchemeBuilder`. | ||
|
||
#### Register with the manager's scheme | ||
Call the `AddToScheme()` function for your 3rd party resource and pass it the manager's scheme via `mgr.GetScheme()`. |
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.
{m -> M}anager
However if there are any operator specific flags or settings defined in the old main file copy those over. | ||
If you have any 3rd party resource types registered with the sdk's scheme, then register those with the manager's scheme in the new project. See how to [register 3rd party resources][register-3rd-party-resources]. |
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.
Upper-case 'sdk'
Co-Authored-By: hasbro17 <hasbro17@gmail.com>
Co-Authored-By: hasbro17 <hasbro17@gmail.com>
Co-Authored-By: hasbro17 <hasbro17@gmail.com>
Co-Authored-By: hasbro17 <hasbro17@gmail.com>
Co-Authored-By: hasbro17 <hasbro17@gmail.com>
Co-Authored-By: hasbro17 <hasbro17@gmail.com>
21622d7
to
ce43fd5
Compare
[skip ci]
ce43fd5
to
ec57205
Compare
Fixed some typos and formatting issues. |
[v0.1.0-changes-doc]: ./v0.1.0-changes.md | ||
[v0.0.7-memcached-operator]: https://github.com/operator-framework/operator-sdk-samples/tree/aa15bd278eec0959595e0a0a7282a26055d7f9d6/memcached-operator | ||
[v0.1.0-memcached-operator]: https://github.com/operator-framework/operator-sdk-samples/tree/master/memcached-operator |
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.
This should probably be locked to a specific commit so this doc stays consistent as we update the SDK over time
Co-Authored-By: hasbro17 <hasbro17@gmail.com>
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.
Initial feedback, but didn't get a chance to try it yet.
@@ -0,0 +1,268 @@ | |||
# Migration Guide from v0.0.x to v0.1.0 | |||
|
|||
This document describes how to migrate an operator project built using Operator SDK `v0.0.x` to the project structure required by `v0.1.0`. For an overview of the major changes in the `v0.1.0` project layout and APIs see the [v0.1.0 changes doc][v0.1.0-changes-doc]. |
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.
The ./v0.1.0-changes.md
doesn't seem to exist so let's add this when that is added.
err = r.client.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: namespace}, dep) | ||
``` | ||
Lastly copy and intialize any other fields that you may have had in your `Handler` struct into the `Reconcile<Kind>` struct: |
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.
s/intialize/initialize
|
||
#### Multiple custom resources | ||
|
||
If your operator is watching more than 1 CR type then you can do one of the following depending on you application: |
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.
If your operator is watching more than 1 CR type then you can do one of the following depending on you application: | |
If your operator is watching more than 1 CR type then you can do one of the following depending on your application: |
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.
LGTM just some thoughts but 👍 overall!
memcached-operator old-memcached-operator | ||
|
||
# Copy over .git from old project | ||
$ cp -rf memcached-operator/.git old-memcached-operator/.git |
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.
This copies new to old, right? Don't you want this:
cp -rf old-memcached-operator/.git memcached-operator/.git
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.
Yes it should be the other way around, good catch.
871239f
to
7d48f65
Compare
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.
LGTM
8995a11
to
2738d46
Compare
2738d46
to
281b24d
Compare
Going to follow this up with the v0.1.0 vs v0.0.x differences doc. That should be a bit smaller since we've gone over most of it in the migration guide. |
[skip ci]
Description of the change:
v0.1.0
with the new controller-runtime changes.v0.1.0-changes.md
doc referenced in the migration guide will be added in a followup PR. But even without that the migration guide should be sufficient to understand the changes.Motivation for the change:
v0.1.0
release./cc @shawn-hurley @joelanford @lilic @AlexNPavel @estroz