-
Notifications
You must be signed in to change notification settings - Fork 44
Support reading KubeConfig from KUBECONFIG env var #293
Support reading KubeConfig from KUBECONFIG env var #293
Conversation
knative-prow-robot
left a comment
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.
@aliok: 0 warnings.
Details
In response to this:
Fixes #292
Proposed Changes
- Backwards compatible change
- Only use
KUBECONFIGif the command line argument is emptyRelease Note
NONESame PR for eventing operator: knative/eventing-operator#100
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
|
Hi @aliok. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
| recursive = flag.Bool("recursive", false, "If filename is a directory, process all manifests recursively") | ||
| MasterURL = flag.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") | ||
| Kubeconfig = flag.String("kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.") | ||
| Kubeconfig = flag.String("kubeconfig", os.Getenv("KUBECONFIG"), "Path to a kubeconfig. Only required if out-of-cluster.") |
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.
Can we actually remove these altogether? They should come via sharedmain anyway, I think? (modulo recursive)
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.
How can we access these arguments from sharedmain?
config, err := mf.NewManifest(filepath.Join(koDataDir, "knative-serving/"), *recursive, cfg)
To create Manifest, we need the cfg. The cfg is created by
cfg, err := clientcmd.BuildConfigFromFlags(*MasterURL, *Kubeconfig)
so we need MasterURL and Kubeconfig. How can we access them in sharedmain?
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.
You're right indeed, we can't reuse them cause they are captured in MainWithConfig.
I'd propose to make these flags package local (lowercase), use the plain Main function in our cmd/manager/main.go and reuse sharedmain.GetConfig(*masterURL, *kubeconfig) here locally. That function does all the defaulting needed by all controllers.
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.
Is it sharedmain.GetConfig("", "")?
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.
well, if you want to keep supporting the flags you gotta pass them in.
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.
@markusthoemmes I made some changes.
markusthoemmes
left a comment
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
/approve
/hold
for the nit. Feel free to unhold if you don't want to fix that.
| MasterURL = flag.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") | ||
| Kubeconfig = flag.String("kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.") | ||
| masterURL = flag.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") | ||
| kubeconfig = flag.String("kubeconfig", os.Getenv("KUBECONFIG"), "Path to a kubeconfig. Only required if out-of-cluster.") |
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 Getenv call is no longer needed as the GetConfig call below does that defaulting already.
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.
Right! Thanks for the heads up.
777c53a to
6287419
Compare
|
Squashed and ready for final review |
I can't. I lack permissions :) |
markusthoemmes
left a comment
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
/approve
/hold cancel
|
oh man this failed :( Can't redefine a flag. We either need to make the flags in sharedmain exposed or do some hack around reading the same flag again in our controller. @markusthoemmes wdyt? |
|
Dang. For this PR I'd roll back the change to the "normal" We can then discuss what to do with the rest. |
6287419 to
6beb48f
Compare
|
/retest |
|
@aliok: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
oh boy. |
|
/ok-to-test |
6beb48f to
a81cee7
Compare
markusthoemmes
left a comment
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
/approve
houshengbo
left a comment
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
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aliok, houshengbo, markusthoemmes The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* Support reading KubeConfig from KUBECONFIG env var (#293) * Add upgrade tests into the e2e-tests-latest-serving (#286) * Add upgrade tests into the e2e-tests-latest-serving This PR adds the tests to verify the correct number and names of knative serving deployments. The test tag postupgrade is added, marking the tests to run after upgrade to the latest HEAD of operator, with the latest generated manifest of knative serving. * Install the latest release of the operator and then upgrade * Split the long functions and rename the common package * Refactor the PR based on the comments * Update the library from jcrossley3/manifestival to manifestival * Update pkg/reconciler/knativeserving/common/gateway.go please fix Co-Authored-By: Matt Moore <[email protected]> Co-authored-by: Ali Ok <[email protected]> Co-authored-by: Kenny Leung <[email protected]> Co-authored-by: Matt Moore <[email protected]>
Fixes #292
Proposed Changes
KUBECONFIGif the command line argument is emptyRelease Note
Same PR for eventing operator: knative/eventing-operator#100