Skip to content

Kubebuilder support for controller flags / command line arguments #611

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

Closed
eytan-avisror opened this issue Feb 22, 2019 · 14 comments
Closed
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@eytan-avisror
Copy link

eytan-avisror commented Feb 22, 2019

I am trying to find a way to pass command line flags to my generated controller, is there an established pattern for doing so without making too many changes to scaffolded code?

My use case is very simple, I would like to mount a config map on the controller as part of the installation, and pass a command line flag that provides that path to the controller so that it can load it (prefer to not hardcode that path) - this is a standard pattern in kubernetes controllers - as well as passing other flags that make sense for your controller.

Is there some way to do this with kubebuilder?
from what I can see, main.go (manager) does not provide an straightforward way to pass flags to my generated controller/reconciler code.

@droot
Copy link
Contributor

droot commented Feb 27, 2019

/cc @DirectXMan12

@droot droot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Feb 27, 2019
@DirectXMan12
Copy link
Contributor

this is a known issue with the current scaffolded code. we're working to change the scaffolding to provide a simpler model that's more amenable to this usecase.

@eytan-avisror
Copy link
Author

Thanks guys, is there a different issue for this feature that I should track? or can I track this issue?

@DirectXMan12
Copy link
Contributor

#588 is the base issue, and I'll make sure everything gets linked in there.

@gaocegege
Copy link

Hi, is there any progress? We are looking forward to the awesome feature! Is there anything I can do to help you?

@DirectXMan12
Copy link
Contributor

We've got work in process, but it'll take a bit to overhaul our generation system so that we don't break existing users.

cc @droot

@droot
Copy link
Contributor

droot commented Mar 19, 2019

@gaocegege This is still in progress #632. You can refer to to the simplified scaffolding design , it will give you an overall idea about the approach.

@gaocegege
Copy link

Thanks, I will take a look! 🎉

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 18, 2019
@droot
Copy link
Contributor

droot commented Jun 18, 2019

Closing this since 2.0.0 includes new scaffolding structure which makes it easy to setup reconciler.
/cc @gaocegege

@droot droot closed this as completed Jun 18, 2019
@gaocegege
Copy link

Thanks, I tried the new scaffolding and it works for me.

@texascloud
Copy link

@droot or @gaocegege can y'all point me to an example where I can provide flags to my controller like the OP mentioned?

@albrechtsimon
Copy link

albrechtsimon commented Dec 11, 2019

In my project I just used go flags like this:

var AWSRegion string

func InitManagerArguments() {
	flag.StringVar(&AWSRegion, "aws-region", "", "AWS region")
}

func main() {
	arguments.InitManagerArguments()
        ...
}

@gaocegege
Copy link

@CamelCaseNotation You can define flags like https://github.com/gaocegege/ray-operator/blob/master/main.go#L50 and use them in your reconcile initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

No branches or pull requests

8 participants