fix k8s node labels for "none" driver
parent
d45ff8f1ea
commit
d002316736
|
@ -620,7 +620,7 @@ func isValid(certPath, keyPath string) bool {
|
|||
}
|
||||
|
||||
if cert.NotAfter.Before(time.Now()) {
|
||||
out.WarningT("Certificate {{.certPath}} has expired. Generating a new one...", out.V{"certPath": path.Base(certPath)})
|
||||
out.WarningT("Certificate {{.certPath}} has expired. Generating a new one...", out.V{"certPath": filepath.Base(certPath)})
|
||||
klog.Infof("cert expired %s: expiration: %s, now: %s", certPath, cert.NotAfter, time.Now())
|
||||
os.Remove(certPath)
|
||||
os.Remove(keyPath)
|
||||
|
@ -642,7 +642,7 @@ func isKubeadmCertValid(cmd command.Runner, certPath string) bool {
|
|||
func properPerms(cert string) string {
|
||||
perms := "0644"
|
||||
|
||||
ext := strings.ToLower(path.Ext(cert))
|
||||
ext := strings.ToLower(filepath.Ext(cert))
|
||||
if ext == ".key" || ext == ".pem" {
|
||||
perms = "0600"
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"runtime"
|
||||
|
@ -1058,10 +1059,18 @@ func (k *Bootstrapper) labelAndUntaintNode(cfg config.ClusterConfig, n config.No
|
|||
ctx, cancel := context.WithTimeout(context.Background(), applyTimeoutSeconds*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// node name is usually based on profile/cluster name, except for "none" driver where it assumes hostname
|
||||
nodeName := config.MachineName(cfg, n)
|
||||
if driver.IsNone(cfg.Driver) {
|
||||
if n, err := os.Hostname(); err == nil {
|
||||
nodeName = n
|
||||
}
|
||||
}
|
||||
|
||||
// example:
|
||||
// sudo /var/lib/minikube/binaries/<version>/kubectl --kubeconfig=/var/lib/minikube/kubeconfig label --overwrite nodes test-357 minikube.k8s.io/version=<version> minikube.k8s.io/commit=aa91f39ffbcf27dcbb93c4ff3f457c54e585cf4a-dirty minikube.k8s.io/name=p1 minikube.k8s.io/updated_at=2020_02_20T12_05_35_0700
|
||||
cmd := exec.CommandContext(ctx, "sudo", kubectlPath(cfg), fmt.Sprintf("--kubeconfig=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")),
|
||||
"label", "--overwrite", "nodes", config.MachineName(cfg, n), createdAtLbl, verLbl, commitLbl, profileNameLbl, primaryLbl)
|
||||
"label", "--overwrite", "nodes", nodeName, createdAtLbl, verLbl, commitLbl, profileNameLbl, primaryLbl)
|
||||
if _, err := k.c.RunCmd(cmd); err != nil {
|
||||
if ctx.Err() == context.DeadlineExceeded {
|
||||
return errors.Wrapf(err, "timeout apply node labels")
|
||||
|
|
Loading…
Reference in New Issue