Use kubeconfig flag instead of kubeconfig-dir in kubeadm init phase bootstrap-token

This commit is contained in:
Yago Nobre 2018-12-06 14:42:45 -02:00
parent 0351853ea1
commit 05e5a3473d
No known key found for this signature in database
GPG Key ID: 09AE6CEC2B8E9DD3

View File

@ -18,7 +18,6 @@ package phases
import ( import (
"fmt" "fmt"
"path/filepath"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -26,7 +25,6 @@ import (
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options" "k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow" "k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
clusterinfophase "k8s.io/kubernetes/cmd/kubeadm/app/phases/bootstraptoken/clusterinfo" clusterinfophase "k8s.io/kubernetes/cmd/kubeadm/app/phases/bootstraptoken/clusterinfo"
nodebootstraptokenphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/bootstraptoken/node" nodebootstraptokenphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/bootstraptoken/node"
"k8s.io/kubernetes/pkg/util/normalizer" "k8s.io/kubernetes/pkg/util/normalizer"
@ -51,7 +49,7 @@ var (
type bootstrapTokenData interface { type bootstrapTokenData interface {
Cfg() *kubeadmapi.InitConfiguration Cfg() *kubeadmapi.InitConfiguration
Client() (clientset.Interface, error) Client() (clientset.Interface, error)
KubeConfigDir() string KubeConfigPath() string
SkipTokenPrint() bool SkipTokenPrint() bool
Tokens() []string Tokens() []string
} }
@ -66,7 +64,7 @@ func NewBootstrapTokenPhase() workflow.Phase {
Long: bootstrapTokenLongDesc, Long: bootstrapTokenLongDesc,
InheritFlags: []string{ InheritFlags: []string{
options.CfgPath, options.CfgPath,
options.KubeconfigDir, options.KubeconfigPath,
options.SkipTokenPrint, options.SkipTokenPrint,
}, },
Run: runBoostrapToken, Run: runBoostrapToken,
@ -113,8 +111,7 @@ func runBoostrapToken(c workflow.RunData) error {
} }
// Create the cluster-info ConfigMap with the associated RBAC rules // Create the cluster-info ConfigMap with the associated RBAC rules
adminKubeConfigPath := filepath.Join(data.KubeConfigDir(), kubeadmconstants.AdminKubeConfigFileName) if err := clusterinfophase.CreateBootstrapConfigMapIfNotExists(client, data.KubeConfigPath()); err != nil {
if err := clusterinfophase.CreateBootstrapConfigMapIfNotExists(client, adminKubeConfigPath); err != nil {
return errors.Wrap(err, "error creating bootstrap ConfigMap") return errors.Wrap(err, "error creating bootstrap ConfigMap")
} }
if err := clusterinfophase.CreateClusterInfoRBACRules(client); err != nil { if err := clusterinfophase.CreateClusterInfoRBACRules(client); err != nil {