Skip to content
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

Simplify k8s client creation #179

Merged
merged 1 commit into from
Mar 22, 2022

Conversation

chenk008
Copy link
Contributor

@chenk008 chenk008 commented Mar 8, 2022

Why are these changes needed?

Currently when we create kubernetes client, it will check if it is running in K8s' pod. And this logic is implemented in sigs.k8s.io/controller-runtime/pkg/client/config. Additional the controller-runtime support enviroment KUBECONFIG .

The official tool can help to simplify the code.

Related issue number

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@chenk008
Copy link
Contributor Author

chenk008 commented Mar 8, 2022

/hold This change will result to compilation failed. We need to bump controller-runtime

@chenk008 chenk008 added the hold Somethins isn't ready label Mar 8, 2022
@Jeffwan
Copy link
Collaborator

Jeffwan commented Mar 15, 2022

@chenk008 I help merge #180 and please rebase the change

@chenk008 chenk008 force-pushed the simplify_k8s_client_creation branch from dd458a2 to dc6dbd9 Compare March 22, 2022 06:23
if err != nil {
return nil, errors.Wrap(err, "Failed to initialize kubernetes client.")
glog.Fatalf("Failed to create TokenReview client. Error: %v", err)
Copy link
Collaborator

@Jeffwan Jeffwan Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The precedence changes a little bit. config.GetConfig() checks --kubeconfig first and then in-cluster config. I can not remember why I choose to check in-cluster first and then external. The change should work for us.

Config precedence after the change. https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/client/config#GetConfig

* --kubeconfig flag pointing at a file
* KUBECONFIG environment variable pointing at a file
* In-cluster config if running in cluster
* $HOME/.kube/config if exists.

@Jeffwan Jeffwan merged commit 722a0eb into ray-project:master Mar 22, 2022
lowang-bh pushed a commit to lowang-bh/kuberay that referenced this pull request Sep 24, 2023
Co-authored-by: wuhua.ck <wuhua.ck@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hold Somethins isn't ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants