Giter Club home page Giter Club logo

Comments (5)

alecmerdler avatar alecmerdler commented on September 14, 2024

A PR would be greatly appreciated; I have no knowledge of how to upgrade scaffolding created from an older version of the Operator SDK.

from helm-app-operator-kit.

hasbro17 avatar hasbro17 commented on September 14, 2024

@joelanford We might tweak the templates and the CLI slightly in the coming days but you should be able to use it to scaffold a new controller-runtime based project.

Since we don't have a migration strategy figured out right now I would suggest doing a clean start.

$ mv helm-app-operator helm-app-operator-old
$ operator-sdk new helm-app-operator
$ operator-sdk add api --api-version=app.example.com/v1alpha1 --kind=HelmApp
$ operator-sdk add controller --api-version=app.example.com/v1alpha1 --kind=HelmApp

However that would only get you started with a typical controller that watches and reconciles for that exact APIVersion and Kind resource.
I have to take a closer look at how the helm-app-operator works but I think it's significantly different.

The sdk.Watch() can dynamically watch for any apiversion and kind as the helm-operator currently does:

resource := os.Getenv(APIVersionEnvVar)
kind := os.Getenv(KindEnvVar)
sdk.Watch(resource, kind, namespace, resyncPeriod)

However the default controller generated above would watch for that specific kind:

err = c.Watch(&source.Kind{Type: &appv1alpha1.HelmApp{}}, &handler.EnqueueRequestForObject{})
if err != nil {
	return err
}

I haven't tried it out myself yet but I think the controller runtime should support watching a type dynamically using Unstructured objects controller-runtime #101:

helmApp := &unstructured.Unstructured{}
helmApp.SetGroupVersionKind(schema.GroupVersionKind{
	Group:   <group from APIVersion env var>,
	Version: <version from APIVersion env var>,
	Kind:    <kind from Kind env var>,
})

err = c.Watch(&source.Kind{Type: helmApp}, &handler.EnqueueRequestForObject{})
if err != nil {
	return err
}

And then the reconcile for the controller would be the same as the ansible-operator where you'd lookup the correct unstructured object(by setting its gvk) from the cache.
https://github.com/operator-framework/operator-sdk/blob/master/pkg/ansible/controller/reconcile.go#L47-L49

Of course this will affect #41 as well. I'll need to take a closer look at the helm-operator to give this some more thought.

from helm-app-operator-kit.

joelanford avatar joelanford commented on September 14, 2024

That makes sense to me and is the path I'm going down. I've got an initial version working that also covers #41. As it turns out, it may just be easier to fold those together into the same PR, which should be coming this afternoon.

I anticipate there will be more changes and tweaks, but I figured it would be easier if we have something concrete to discuss.

from helm-app-operator-kit.

joelanford avatar joelanford commented on September 14, 2024

I've fixed a few minor issues in PR #43. I believe it is now ready for review.

I attempted to organize the pkg/helm package similarly to the pkg/ansible package in operator-sdk to make it easy to pull into operator-sdk when we're ready. As a result, I think the PR is bigger than it necessarily has to be. If it makes more sense, I can reorganize with a focus on minimizing changes.

from helm-app-operator-kit.

joelanford avatar joelanford commented on September 14, 2024

This issue is closed by PRs #45, #46, and #47

from helm-app-operator-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.