-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Document how to add 3rd party resources, such as OpenShift resources #477
Comments
@benjaminapetersen adding new types to the SDK scheme via I think just documenting it on the user-guide or somewhere else should be sufficient. |
@benjaminapetersen @hasbro17 same approach if I need to create a route from within the operator? Is there any simple example operator that creates and watches deployment, service and route which is typical for a webapp? |
Whichever types you want to use in your operator need to be added to the scheme. for the core APIs (empty group) we add those by default. operator-sdk/pkg/util/k8sutil/k8sutil.go Line 45 in 4179b6a
If you want Deployments you will have to register Example of how:
|
@eivantsov my snippet above was for a route, that was my exact use case as well. |
@eivantsov in total my inport routev1 "github.com/openshift/api/route/v1"
// init will run before main
func init() {
k8sutil.AddToSDKScheme(route.Install)
}
func watch(apiVersion, kind, namespace string, resyncPeriod int) {
logrus.Infof("Watching %s, %s, %s, %d", apiVersion, kind, namespace, resyncPeriod)
sdk.Watch(apiVersion, kind, namespace, resyncPeriod)
}
// and off we go
func main() {
resyncPeriod := 60 * 60 * 10 // 10hrs. no less.
watch(routev1.GroupVersion.String(), "Route", namespace, resyncPeriod)
watch(myResourceGroupVersion, "MyResource", namespace, resyncPeriod)
sdk.Handle(stub.NewHandler())
sdk.Run(context.TODO())
} |
@benjaminapetersen thanks but for some reason, a simple
Results in
|
You added the dependencies via |
(thats my guess) |
@benjaminapetersen yes, that was it, though I did |
Nice! |
@benjaminapetersen thanks for your help. I think a short:
with code snippets would be very helpful for those not familiar with Operators or k8s go lib in general. I was able to write a simple operator that creates deployment, service account, rolebinding, service and a route exploring available examples and using some help from @benjaminapetersen |
Closed by #509 |
Hi folks, It shows no longer work in this way. Could you please give me a hand in #1365? c.c @eivantsov @hasbro17 @benjaminapetersen @shawn-hurley @jfchevrette |
@camilocot #509 works for me. https://github.com/eclipse/che-operator/blob/master/pkg/controller/che/che_controller.go#L71 |
@eivantsov it worked the issue was just because I was adding the |
When attempting to
sdk.Watch
an OpenShiftRoute
via:I get errors like:
However, this seems to have fixed the problem:
I'm suggesting one of two solutions:
sdk.Watch
can be modified to handle resources generically, that may avoid the previous need.The text was updated successfully, but these errors were encountered: