-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix embed certs by updating kubeconfig after certs are populated #7309
Conversation
Hi @linkvt. Thanks for your PR. I'm waiting for a kubernetes 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. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: linkvt The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov Report
@@ Coverage Diff @@
## master #7309 +/- ##
=======================================
Coverage 37.47% 37.47%
=======================================
Files 146 146
Lines 8869 8869
=======================================
Hits 3324 3324
Misses 5140 5140
Partials 405 405 |
Can one of the admins verify this patch? |
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.
Thanks for the PR, and especially for uncovering the issue!
pkg/minikube/node/start.go
Outdated
if apiServer { | ||
// Must be written before bootstrap, otherwise health checks may flake due to stale IP | ||
kubeconfig, err = setupKubeconfig(host, &cc, &n, cc.Name) | ||
kubeconfig = setupKubeconfig(host, &cc, &n, cc.Name) |
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.
Based on this, I don't think this call is necessary any longer. Do you mind trying to remove it?
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.
I don't think that this can be removed as the kubeconfig is constructed inside of the setupKubeconfig
function, see
minikube/pkg/minikube/node/start.go
Lines 242 to 266 in da7227e
func setupKubeconfig(h *host.Host, cc *config.ClusterConfig, n *config.Node, clusterName string) (*kubeconfig.Settings, error) { | |
addr, err := apiServerURL(*h, *cc, *n) | |
if err != nil { | |
exit.WithError("Failed to get API Server URL", err) | |
} | |
if cc.KubernetesConfig.APIServerName != constants.APIServerName { | |
addr = strings.Replace(addr, n.IP, cc.KubernetesConfig.APIServerName, -1) | |
} | |
kcs := &kubeconfig.Settings{ | |
ClusterName: clusterName, | |
ClusterServerAddress: addr, | |
ClientCertificate: localpath.ClientCert(cc.Name), | |
ClientKey: localpath.ClientKey(cc.Name), | |
CertificateAuthority: localpath.CACert(), | |
KeepContext: viper.GetBool(keepContext), | |
EmbedCerts: viper.GetBool(embedCerts), | |
} | |
kcs.SetPath(kubeconfig.PathFromEnv()) | |
if err := kubeconfig.Update(kcs); err != nil { | |
return kcs, err | |
} | |
return kcs, nil | |
} |
/ok-to-test |
Error: running mkcmp: exit status 1 |
The content of the kubeconfig is defined before certs are generated by the bootstrapper. When certs are embedded via --embed-certs writing the kubeconfig fails if the certificates are not generated so it must run after the bootstrap process which generates them.
Fixes #7293
The content of the kubeconfig is defined before certs are generated by
the bootstrapper. When certs are embedded via --embed-certs writing the
kubeconfig fails if the certificates are not generated so it must run
after the bootstrap process which generates them.
Not a nice solution but I think it is the easiest without major refactorings.
I found out why it worked after starting a minikube cluster initially without
--embed-certs
as it is already broken since a few versions with a fresh setup: The private keys were the same across multiple machines, they were reloaded inminikube/pkg/util/crypto.go
Line 112 in eb13446
With the change now for putting them into the profiles dir this didn't work anymore.