Skip to content

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

Merged
crazy-max merged 2 commits intodocker:masterfrom
crazy-max:builder-move-kube-cfg
Aug 7, 2024
Merged

builder: move kube config handling to k8s driver package#2606
crazy-max merged 2 commits intodocker:masterfrom
crazy-max:builder-move-kube-cfg

Conversation

@crazy-max
Copy link
Copy Markdown
Member

fixes #2597

Comment thread driver/kubernetes/factory.go Outdated
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
Copy Markdown
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.

@crazy-max crazy-max force-pushed the builder-move-kube-cfg branch from 111de87 to b74993b Compare July 17, 2024 08:26
Comment thread driver/manager.go Outdated
@crazy-max crazy-max added this to the v0.17.0 milestone Jul 17, 2024
@crazy-max
Copy link
Copy Markdown
Member Author

crazy-max commented Aug 7, 2024

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

Copy link
Copy Markdown
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

Comment thread driver/manager.go Outdated
Comment thread driver/kubernetes/factory.go Outdated
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
Copy Markdown
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
Copy Markdown
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 force-pushed the builder-move-kube-cfg branch from b74993b to acf0216 Compare August 7, 2024 12:01
@crazy-max crazy-max merged commit 9a0c320 into docker:master Aug 7, 2024
@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