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

builder: move kube config handling to k8s driver package #2606

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

crazy-max
Copy link
Member

fixes #2597

Comment on lines 143 to 170
var err error
var cc ClientConfig
cc, err = ctxkube.ConfigFromEndpoint(endpoint, contextStore)
if err != nil {
// err is returned if n.Endpoint is non-context name like "unix:///var/run/docker.sock".
// try again with name="default".
// FIXME(@AkihiroSuda): n should retain real context name.
cc, err = ctxkube.ConfigFromEndpoint("default", contextStore)
if err != nil {
logrus.Error(err)
}
}

tryToUseKubeConfigInCluster := false
if cc == nil {
tryToUseKubeConfigInCluster = true
} else {
if _, err := cc.ClientConfig(); err != nil {
tryToUseKubeConfigInCluster = true
}
}
if tryToUseKubeConfigInCluster {
ccInCluster := ClientConfigInCluster{}
if _, err := ccInCluster.ClientConfig(); err == nil {
logrus.Debug("using kube config in cluster")
cc = ccInCluster
}
}
Copy link
Member Author

@crazy-max crazy-max Jul 16, 2024

Choose a reason for hiding this comment

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

didn't touch this logic and just moved it from builder package for now but should look at it more closely as follow-up.

driver/manager.go Outdated Show resolved Hide resolved
@crazy-max crazy-max added this to the v0.17.0 milestone Jul 17, 2024
@crazy-max
Copy link
Member Author

crazy-max commented Aug 7, 2024

@AkihiroSuda When you have time could you take another look please? Thanks

Copy link
Collaborator

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

driver/manager.go Outdated Show resolved Hide resolved
if err != nil {
// err is returned if n.Endpoint is non-context name like "unix:///var/run/docker.sock".
// try again with name="default".
// FIXME(@AkihiroSuda): n should retain real context name.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What was "n"?

Maybe the variable was renamed since then? (hard to check from phone now)

Copy link
Member Author

@crazy-max crazy-max Aug 7, 2024

Choose a reason for hiding this comment

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

Seems it was the driver config

func(i int, n store.Node) {

I will update this comment.

Also as we now have ContextStore in driver InitConfig maybe it would be fine to have ContextName as well and use it here?

@crazy-max crazy-max merged commit 9a0c320 into docker:master Aug 7, 2024
106 checks passed
@crazy-max crazy-max deleted the builder-move-kube-cfg branch August 7, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

optimize k8s config initialization
2 participants