Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

kubeadm join: fix TLS on Kubernetes >=1.9 #222

Merged
merged 1 commit into from
Nov 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pkg/nspawntool/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/kinvolk/kube-spawn/pkg/bootstrap"
"github.com/kinvolk/kube-spawn/pkg/config"
"github.com/kinvolk/kube-spawn/pkg/machinetool"
"github.com/kinvolk/kube-spawn/pkg/utils"
"github.com/kinvolk/kube-spawn/pkg/utils/fs"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -88,7 +89,18 @@ func JoinNode(cfg *config.ClusterConfiguration, mNo int) error {
}
joinCmd = append(joinCmd, []string{
"/usr/bin/kubeadm", "join", "--skip-preflight-checks",
"--token", cfg.Token,
cfg.Machines[0].IP + ":6443"}...)
"--token", cfg.Token}...)

// --discovery-token-unsafe-skip-ca-verification appeared in Kubernetes 1.8
// See: https://github.com/kubernetes/kubernetes/pull/49520
// It is mandatory since Kubernetes 1.9
// See: https://github.com/kubernetes/kubernetes/pull/55468
// Test is !<1.8 instead of >=1.8 in order to handle non-semver version 'latest'
if !utils.CheckVersionConstraint(cfg.KubernetesVersion, "<1.8") {
Copy link
Member

Choose a reason for hiding this comment

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

FYI, similar version checks are done in pkg/config/defaults.go, either if cfg.DevCluster || utils.CheckVersionConstraint(cfg.KubernetesVersion, ">=1.8.0") or if !cfg.DevCluster && utils.CheckVersionConstraint(cfg.KubernetesVersion, "<1.8.0"). In this file the check is now used a little differently. Basically this pattern is kind of error-prone, so I think we should be somehow consistent. We could make a helper to simplify it in another PR.

joinCmd = append(joinCmd, "--discovery-token-unsafe-skip-ca-verification")
}

joinCmd = append(joinCmd, cfg.Machines[0].IP+":6443")

return machinetool.Shell(shellOpts, cfg.Machines[mNo].Name, joinCmd...)
}