mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
kubeadm alpha commands
This commit is contained in:
parent
50dffba0f3
commit
0c31c79e7b
62
cmd/kubeadm/app/cmd/alpha/alpha.go
Normal file
62
cmd/kubeadm/app/cmd/alpha/alpha.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package alpha
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases"
|
||||||
|
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewCmdAlpha returns "kubeadm alpha" command.
|
||||||
|
func NewCmdAlpha(out io.Writer) *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "alpha",
|
||||||
|
Short: "Kubeadm experimental sub-commands",
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(newCmdCertsUtility())
|
||||||
|
cmd.AddCommand(newCmdKubeletUtility())
|
||||||
|
cmd.AddCommand(newCmdKubeConfigUtility(out))
|
||||||
|
cmd.AddCommand(newCmdPreFlightUtility())
|
||||||
|
|
||||||
|
// TODO: This command should be removed as soon as the kubeadm init phase refactoring is completed.
|
||||||
|
// current phases implemented as cobra.Commands should become workflow.Phases, while other utilities
|
||||||
|
// hosted under kubeadm alpha phases command should found a new home under kubeadm alpha (without phases)
|
||||||
|
cmd.AddCommand(newCmdPhase(out))
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCmdPhase(out io.Writer) *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "phase",
|
||||||
|
Short: "Invoke subsets of kubeadm functions separately for a manual install",
|
||||||
|
Long: cmdutil.MacroCommandLongDescription,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(phases.NewCmdAddon())
|
||||||
|
cmd.AddCommand(phases.NewCmdBootstrapToken())
|
||||||
|
cmd.AddCommand(phases.NewCmdEtcd())
|
||||||
|
cmd.AddCommand(phases.NewCmdMarkMaster())
|
||||||
|
cmd.AddCommand(phases.NewCmdSelfhosting())
|
||||||
|
cmd.AddCommand(phases.NewCmdUploadConfig())
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
@ -14,13 +14,12 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package renew
|
package alpha
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||||
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||||
@ -46,8 +45,20 @@ var (
|
|||||||
`)
|
`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCmdCertsRenewal creates a new `cert renew` command.
|
// newCmdCertsUtility returns main command for certs phase
|
||||||
func NewCmdCertsRenewal() *cobra.Command {
|
func newCmdCertsUtility() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "certs",
|
||||||
|
Aliases: []string{"certificates"},
|
||||||
|
Short: "Commands related to handling kubernetes certificates",
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(newCmdCertsRenewal())
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// newCmdCertsRenewal creates a new `cert renew` command.
|
||||||
|
func newCmdCertsRenewal() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "renew",
|
Use: "renew",
|
||||||
Short: "Renews certificates for a Kubernetes cluster",
|
Short: "Renews certificates for a Kubernetes cluster",
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package renew
|
package alpha
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
@ -29,7 +29,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/pkiutil"
|
"k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/pkiutil"
|
||||||
testutil "k8s.io/kubernetes/cmd/kubeadm/test"
|
testutil "k8s.io/kubernetes/cmd/kubeadm/test"
|
||||||
@ -58,7 +57,7 @@ func TestCommandsGenerated(t *testing.T) {
|
|||||||
"renew etcd-healthcheck-client",
|
"renew etcd-healthcheck-client",
|
||||||
}
|
}
|
||||||
|
|
||||||
renewCmd := NewCmdCertsRenewal()
|
renewCmd := newCmdCertsRenewal()
|
||||||
|
|
||||||
fakeRoot := &cobra.Command{}
|
fakeRoot := &cobra.Command{}
|
||||||
fakeRoot.AddCommand(renewCmd)
|
fakeRoot.AddCommand(renewCmd)
|
106
cmd/kubeadm/app/cmd/alpha/kubeconfig.go
Normal file
106
cmd/kubeadm/app/cmd/alpha/kubeconfig.go
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package alpha
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||||
|
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
||||||
|
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||||
|
kubeconfigphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig"
|
||||||
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
|
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
|
||||||
|
"k8s.io/kubernetes/pkg/util/normalizer"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
kubeconfigLongDesc = normalizer.LongDesc(`
|
||||||
|
Kubeconfig file utilities.
|
||||||
|
` + cmdutil.AlphaDisclaimer)
|
||||||
|
|
||||||
|
userKubeconfigLongDesc = normalizer.LongDesc(`
|
||||||
|
Outputs a kubeconfig file for an additional user.
|
||||||
|
` + cmdutil.AlphaDisclaimer)
|
||||||
|
|
||||||
|
userKubeconfigExample = normalizer.Examples(`
|
||||||
|
# Outputs a kubeconfig file for an additional user named foo
|
||||||
|
kubeadm alpha kubeconfig user --client-name=foo
|
||||||
|
`)
|
||||||
|
)
|
||||||
|
|
||||||
|
// newCmdKubeConfigUtility returns main command for kubeconfig phase
|
||||||
|
func newCmdKubeConfigUtility(out io.Writer) *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "kubeconfig",
|
||||||
|
Short: "Kubeconfig file utilities",
|
||||||
|
Long: kubeconfigLongDesc,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(newCmdUserKubeConfig(out))
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// newCmdUserKubeConfig returns sub commands for kubeconfig phase
|
||||||
|
func newCmdUserKubeConfig(out io.Writer) *cobra.Command {
|
||||||
|
|
||||||
|
cfg := &kubeadmapiv1beta1.InitConfiguration{}
|
||||||
|
|
||||||
|
// Default values for the cobra help text
|
||||||
|
kubeadmscheme.Scheme.Default(cfg)
|
||||||
|
|
||||||
|
var token, clientName string
|
||||||
|
var organizations []string
|
||||||
|
|
||||||
|
// Creates the UX Command
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "user",
|
||||||
|
Short: "Outputs a kubeconfig file for an additional user",
|
||||||
|
Long: userKubeconfigLongDesc,
|
||||||
|
Example: userKubeconfigExample,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
if clientName == "" {
|
||||||
|
kubeadmutil.CheckErr(errors.New("missing required argument --client-name"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// This call returns the ready-to-use configuration based on the configuration file that might or might not exist and the default cfg populated by flags
|
||||||
|
internalcfg, err := configutil.ConfigFileAndDefaultsToInternalConfig("", cfg)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
|
// if the kubeconfig file for an additional user has to use a token, use it
|
||||||
|
if token != "" {
|
||||||
|
kubeadmutil.CheckErr(kubeconfigphase.WriteKubeConfigWithToken(out, internalcfg, clientName, token))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, write a kubeconfig file with a generate client cert
|
||||||
|
kubeadmutil.CheckErr(kubeconfigphase.WriteKubeConfigWithClientCert(out, internalcfg, clientName, organizations))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add flags to the command
|
||||||
|
cmd.Flags().StringVar(&cfg.CertificatesDir, "cert-dir", cfg.CertificatesDir, "The path where certificates are stored")
|
||||||
|
cmd.Flags().StringVar(&cfg.APIEndpoint.AdvertiseAddress, "apiserver-advertise-address", cfg.APIEndpoint.AdvertiseAddress, "The IP address the API server is accessible on")
|
||||||
|
cmd.Flags().Int32Var(&cfg.APIEndpoint.BindPort, "apiserver-bind-port", cfg.APIEndpoint.BindPort, "The port the API server is accessible on")
|
||||||
|
cmd.Flags().StringVar(&token, "token", token, "The token that should be used as the authentication mechanism for this kubeconfig, instead of client certificates")
|
||||||
|
cmd.Flags().StringVar(&clientName, "client-name", clientName, "The name of user. It will be used as the CN if client certificates are created")
|
||||||
|
cmd.Flags().StringSliceVar(&organizations, "org", organizations, "The orgnizations of the client certificate. It will be used as the O if client certificates are created")
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 The Kubernetes Authors.
|
Copyright 2018 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package phases
|
package alpha
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -22,32 +22,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/pkiutil"
|
"k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/pkiutil"
|
||||||
testutil "k8s.io/kubernetes/cmd/kubeadm/test"
|
testutil "k8s.io/kubernetes/cmd/kubeadm/test"
|
||||||
cmdtestutil "k8s.io/kubernetes/cmd/kubeadm/test/cmd"
|
|
||||||
kubeconfigtestutil "k8s.io/kubernetes/cmd/kubeadm/test/kubeconfig"
|
kubeconfigtestutil "k8s.io/kubernetes/cmd/kubeadm/test/kubeconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestKubeConfigCSubCommandsHasFlags(t *testing.T) {
|
|
||||||
cmd := NewCmdUserKubeConfig(nil, "", phaseTestK8sVersion)
|
|
||||||
|
|
||||||
flags := []string{
|
|
||||||
"cert-dir",
|
|
||||||
"apiserver-advertise-address",
|
|
||||||
"apiserver-bind-port",
|
|
||||||
"kubeconfig-dir",
|
|
||||||
"token",
|
|
||||||
"client-name",
|
|
||||||
}
|
|
||||||
|
|
||||||
cmdtestutil.AssertSubCommandHasFlags(t, []*cobra.Command{cmd}, "user", flags...)
|
|
||||||
}
|
|
||||||
|
|
||||||
const phaseTestK8sVersion = "v1.11.0"
|
|
||||||
|
|
||||||
func TestKubeConfigSubCommandsThatWritesToOut(t *testing.T) {
|
func TestKubeConfigSubCommandsThatWritesToOut(t *testing.T) {
|
||||||
|
|
||||||
// Temporary folders for the test case
|
// Temporary folders for the test case
|
||||||
@ -57,8 +38,6 @@ func TestKubeConfigSubCommandsThatWritesToOut(t *testing.T) {
|
|||||||
// Adds a pki folder with a ca cert to the temp folder
|
// Adds a pki folder with a ca cert to the temp folder
|
||||||
pkidir := testutil.SetupPkiDirWithCertificateAuthorithy(t, tmpdir)
|
pkidir := testutil.SetupPkiDirWithCertificateAuthorithy(t, tmpdir)
|
||||||
|
|
||||||
outputdir := tmpdir
|
|
||||||
|
|
||||||
// Retrieves ca cert for assertions
|
// Retrieves ca cert for assertions
|
||||||
caCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(pkidir, kubeadmconstants.CACertAndKeyBaseName)
|
caCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(pkidir, kubeadmconstants.CACertAndKeyBaseName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -70,7 +49,6 @@ func TestKubeConfigSubCommandsThatWritesToOut(t *testing.T) {
|
|||||||
"--apiserver-bind-port=1234",
|
"--apiserver-bind-port=1234",
|
||||||
"--client-name=myUser",
|
"--client-name=myUser",
|
||||||
fmt.Sprintf("--cert-dir=%s", pkidir),
|
fmt.Sprintf("--cert-dir=%s", pkidir),
|
||||||
fmt.Sprintf("--kubeconfig-dir=%s", outputdir),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
@ -94,11 +72,14 @@ func TestKubeConfigSubCommandsThatWritesToOut(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
// Get subcommands working in the temporary directory
|
// Get subcommands working in the temporary directory
|
||||||
cmd := NewCmdUserKubeConfig(buf, tmpdir, phaseTestK8sVersion)
|
cmd := newCmdUserKubeConfig(buf)
|
||||||
|
|
||||||
// Execute the subcommand
|
// Execute the subcommand
|
||||||
allFlags := append(commonFlags, test.additionalFlags...)
|
allFlags := append(commonFlags, test.additionalFlags...)
|
||||||
cmdtestutil.RunSubCommand(t, []*cobra.Command{cmd}, test.command, allFlags...)
|
cmd.SetArgs(allFlags)
|
||||||
|
if err := cmd.Execute(); err != nil {
|
||||||
|
t.Fatal("Could not execute subcommand")
|
||||||
|
}
|
||||||
|
|
||||||
// reads kubeconfig written to stdout
|
// reads kubeconfig written to stdout
|
||||||
config, err := clientcmd.Load(buf.Bytes())
|
config, err := clientcmd.Load(buf.Bytes())
|
162
cmd/kubeadm/app/cmd/alpha/kubelet.go
Normal file
162
cmd/kubeadm/app/cmd/alpha/kubelet.go
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package alpha
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/util/version"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||||
|
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
|
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/preflight"
|
||||||
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
|
kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
|
||||||
|
"k8s.io/kubernetes/pkg/util/normalizer"
|
||||||
|
utilsexec "k8s.io/utils/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
kubeletConfigDownloadLongDesc = normalizer.LongDesc(`
|
||||||
|
Downloads the kubelet configuration from a ConfigMap of the form "kubelet-config-1.X" in the cluster,
|
||||||
|
where X is the minor version of the kubelet. Either kubeadm autodetects the kubelet version by exec-ing
|
||||||
|
"kubelet --version" or respects the --kubelet-version parameter.
|
||||||
|
` + cmdutil.AlphaDisclaimer)
|
||||||
|
|
||||||
|
kubeletConfigDownloadExample = normalizer.Examples(`
|
||||||
|
# Downloads the kubelet configuration from the ConfigMap in the cluster. Autodetects the kubelet version.
|
||||||
|
kubeadm alpha phase kubelet config download
|
||||||
|
|
||||||
|
# Downloads the kubelet configuration from the ConfigMap in the cluster. Uses a specific desired kubelet version.
|
||||||
|
kubeadm alpha phase kubelet config download --kubelet-version v1.12.0
|
||||||
|
`)
|
||||||
|
|
||||||
|
kubeletConfigEnableDynamicLongDesc = normalizer.LongDesc(`
|
||||||
|
Enables or updates dynamic kubelet configuration for a Node, against the kubelet-config-1.X ConfigMap in the cluster,
|
||||||
|
where X is the minor version of the desired kubelet version.
|
||||||
|
|
||||||
|
WARNING: This feature is still experimental, and disabled by default. Enable only if you know what you are doing, as it
|
||||||
|
may have surprising side-effects at this stage.
|
||||||
|
|
||||||
|
` + cmdutil.AlphaDisclaimer)
|
||||||
|
|
||||||
|
kubeletConfigEnableDynamicExample = normalizer.Examples(`
|
||||||
|
# Enables dynamic kubelet configuration for a Node.
|
||||||
|
kubeadm alpha phase kubelet enable-dynamic-config --node-name node-1 --kubelet-version v1.12.0
|
||||||
|
|
||||||
|
WARNING: This feature is still experimental, and disabled by default. Enable only if you know what you are doing, as it
|
||||||
|
may have surprising side-effects at this stage.
|
||||||
|
`)
|
||||||
|
)
|
||||||
|
|
||||||
|
// newCmdKubeletUtility returns command for `kubeadm phase kubelet`
|
||||||
|
func newCmdKubeletUtility() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "kubelet",
|
||||||
|
Short: "Commands related to handling the kubelet",
|
||||||
|
Long: cmdutil.MacroCommandLongDescription,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(newCmdKubeletConfig())
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// newCmdKubeletConfig returns command for `kubeadm phase kubelet config`
|
||||||
|
func newCmdKubeletConfig() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "config",
|
||||||
|
Short: "Utilities for kubelet configuration",
|
||||||
|
Long: cmdutil.MacroCommandLongDescription,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(newCmdKubeletConfigDownload())
|
||||||
|
cmd.AddCommand(newCmdKubeletConfigEnableDynamic())
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// newCmdKubeletConfigDownload calls cobra.Command for downloading the kubelet configuration from the kubelet-config-1.X ConfigMap in the cluster
|
||||||
|
func newCmdKubeletConfigDownload() *cobra.Command {
|
||||||
|
var kubeletVersionStr string
|
||||||
|
// TODO: Be smarter about this and be able to load multiple kubeconfig files in different orders of precedence
|
||||||
|
kubeConfigFile := constants.GetKubeletKubeConfigPath()
|
||||||
|
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "download",
|
||||||
|
Short: "Downloads the kubelet configuration from the cluster ConfigMap kubelet-config-1.X, where X is the minor version of the kubelet.",
|
||||||
|
Long: kubeletConfigDownloadLongDesc,
|
||||||
|
Example: kubeletConfigDownloadExample,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
kubeletVersion, err := getKubeletVersion(kubeletVersionStr)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
|
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
|
err = kubeletphase.DownloadConfig(client, kubeletVersion, constants.KubeletRunDirectory)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
options.AddKubeConfigFlag(cmd.Flags(), &kubeConfigFile)
|
||||||
|
cmd.Flags().StringVar(&kubeletVersionStr, "kubelet-version", kubeletVersionStr, "The desired version for the kubelet. Defaults to being autodetected from 'kubelet --version'.")
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func getKubeletVersion(kubeletVersionStr string) (*version.Version, error) {
|
||||||
|
if len(kubeletVersionStr) > 0 {
|
||||||
|
return version.ParseSemantic(kubeletVersionStr)
|
||||||
|
}
|
||||||
|
return preflight.GetKubeletVersion(utilsexec.New())
|
||||||
|
}
|
||||||
|
|
||||||
|
// newCmdKubeletConfigEnableDynamic calls cobra.Command for enabling dynamic kubelet configuration on node
|
||||||
|
// This feature is still in alpha and an experimental state
|
||||||
|
func newCmdKubeletConfigEnableDynamic() *cobra.Command {
|
||||||
|
var nodeName, kubeletVersionStr string
|
||||||
|
kubeConfigFile := constants.GetAdminKubeConfigPath()
|
||||||
|
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "enable-dynamic",
|
||||||
|
Short: "EXPERIMENTAL: Enables or updates dynamic kubelet configuration for a Node",
|
||||||
|
Long: kubeletConfigEnableDynamicLongDesc,
|
||||||
|
Example: kubeletConfigEnableDynamicExample,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
if len(nodeName) == 0 {
|
||||||
|
kubeadmutil.CheckErr(errors.New("The --node-name argument is required"))
|
||||||
|
}
|
||||||
|
if len(kubeletVersionStr) == 0 {
|
||||||
|
kubeadmutil.CheckErr(errors.New("The --kubelet-version argument is required"))
|
||||||
|
}
|
||||||
|
|
||||||
|
kubeletVersion, err := version.ParseSemantic(kubeletVersionStr)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
|
kubeConfigFile = cmdutil.FindExistingKubeConfig(kubeConfigFile)
|
||||||
|
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
|
err = kubeletphase.EnableDynamicConfigForNode(client, nodeName, kubeletVersion)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
options.AddKubeConfigFlag(cmd.Flags(), &kubeConfigFile)
|
||||||
|
cmd.Flags().StringVar(&nodeName, "node-name", nodeName, "Name of the node that should enable the dynamic kubelet configuration")
|
||||||
|
cmd.Flags().StringVar(&kubeletVersionStr, "kubelet-version", kubeletVersionStr, "The desired version for the kubelet")
|
||||||
|
return cmd
|
||||||
|
}
|
100
cmd/kubeadm/app/cmd/alpha/preflight.go
Normal file
100
cmd/kubeadm/app/cmd/alpha/preflight.go
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package alpha
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||||
|
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||||
|
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/preflight"
|
||||||
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
|
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
|
||||||
|
"k8s.io/kubernetes/pkg/util/normalizer"
|
||||||
|
utilsexec "k8s.io/utils/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
nodePreflightLongDesc = normalizer.LongDesc(`
|
||||||
|
Run node pre-flight checks, functionally equivalent to what implemented by kubeadm join.
|
||||||
|
` + cmdutil.AlphaDisclaimer)
|
||||||
|
|
||||||
|
nodePreflightExample = normalizer.Examples(`
|
||||||
|
# Run node pre-flight checks.
|
||||||
|
kubeadm alpha preflight node
|
||||||
|
`)
|
||||||
|
|
||||||
|
errorMissingConfigFlag = errors.New("the --config flag is mandatory")
|
||||||
|
)
|
||||||
|
|
||||||
|
// newCmdPreFlightUtility calls cobra.Command for preflight checks
|
||||||
|
func newCmdPreFlightUtility() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "preflight",
|
||||||
|
Short: "Commands related to pre-flight checks",
|
||||||
|
Long: cmdutil.MacroCommandLongDescription,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(newCmdPreFlightNode())
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// newCmdPreFlightNode calls cobra.Command for node preflight checks
|
||||||
|
func newCmdPreFlightNode() *cobra.Command {
|
||||||
|
var cfgPath string
|
||||||
|
var ignorePreflightErrors []string
|
||||||
|
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "node",
|
||||||
|
Short: "Run node pre-flight checks",
|
||||||
|
Long: nodePreflightLongDesc,
|
||||||
|
Example: nodePreflightExample,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
if len(cfgPath) == 0 {
|
||||||
|
kubeadmutil.CheckErr(errorMissingConfigFlag)
|
||||||
|
}
|
||||||
|
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(ignorePreflightErrors)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
|
cfg := &kubeadmapiv1beta1.JoinConfiguration{}
|
||||||
|
kubeadmscheme.Scheme.Default(cfg)
|
||||||
|
|
||||||
|
internalcfg, err := configutil.JoinConfigFileAndDefaultsToInternalConfig(cfgPath, cfg)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
err = configutil.VerifyAPIServerBindAddress(internalcfg.APIEndpoint.AdvertiseAddress)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
|
fmt.Println("[preflight] running pre-flight checks")
|
||||||
|
|
||||||
|
err = preflight.RunJoinNodeChecks(utilsexec.New(), internalcfg, ignorePreflightErrorsSet)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
|
fmt.Println("[preflight] pre-flight checks passed")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
options.AddConfigFlag(cmd.PersistentFlags(), &cfgPath)
|
||||||
|
options.AddIgnorePreflightErrorsFlag(cmd.PersistentFlags(), &ignorePreflightErrors)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
@ -22,8 +22,7 @@ import (
|
|||||||
"github.com/renstrom/dedent"
|
"github.com/renstrom/dedent"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/alpha"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases"
|
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/upgrade"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/upgrade"
|
||||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
// Register the kubeadm configuration types because CLI flag generation
|
// Register the kubeadm configuration types because CLI flag generation
|
||||||
@ -90,14 +89,7 @@ func NewKubeadmCommand(in io.Reader, out, err io.Writer) *cobra.Command {
|
|||||||
cmds.AddCommand(NewCmdVersion(out))
|
cmds.AddCommand(NewCmdVersion(out))
|
||||||
cmds.AddCommand(NewCmdToken(out, err))
|
cmds.AddCommand(NewCmdToken(out, err))
|
||||||
cmds.AddCommand(upgrade.NewCmdUpgrade(out))
|
cmds.AddCommand(upgrade.NewCmdUpgrade(out))
|
||||||
|
cmds.AddCommand(alpha.NewCmdAlpha(out))
|
||||||
// Wrap not yet fully supported commands in an alpha subcommand
|
|
||||||
experimentalCmd := &cobra.Command{
|
|
||||||
Use: "alpha",
|
|
||||||
Short: "Experimental sub-commands not yet fully functional.",
|
|
||||||
}
|
|
||||||
experimentalCmd.AddCommand(phases.NewCmdPhase(out))
|
|
||||||
cmds.AddCommand(experimentalCmd)
|
|
||||||
|
|
||||||
AddKubeadmOtherFlags(cmds.PersistentFlags(), &rootfsPath)
|
AddKubeadmOtherFlags(cmds.PersistentFlags(), &rootfsPath)
|
||||||
|
|
||||||
|
@ -21,11 +21,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||||
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
||||||
certscmdphase "k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/certs"
|
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
||||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
@ -68,24 +66,6 @@ func NewCertsPhase() workflow.Phase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCmdCerts returns main command for certs phase
|
|
||||||
func NewCmdCerts() *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "certs",
|
|
||||||
Aliases: []string{"certificates"},
|
|
||||||
Short: "Generates certificates for a Kubernetes cluster",
|
|
||||||
Long: cmdutil.MacroCommandLongDescription,
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.AddCommand(getCertsSubCommands()...)
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// getCertsSubCommands returns sub commands for certs phase
|
|
||||||
func getCertsSubCommands() []*cobra.Command {
|
|
||||||
return []*cobra.Command{certscmdphase.NewCmdCertsRenewal()}
|
|
||||||
}
|
|
||||||
|
|
||||||
// newCertSubPhases returns sub phases for certs phase
|
// newCertSubPhases returns sub phases for certs phase
|
||||||
func newCertSubPhases() []workflow.Phase {
|
func newCertSubPhases() []workflow.Phase {
|
||||||
subPhases := []workflow.Phase{}
|
subPhases := []workflow.Phase{}
|
||||||
|
@ -25,6 +25,8 @@ import (
|
|||||||
cmdtestutil "k8s.io/kubernetes/cmd/kubeadm/test/cmd"
|
cmdtestutil "k8s.io/kubernetes/cmd/kubeadm/test/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const phaseTestK8sVersion = "v1.11.0"
|
||||||
|
|
||||||
func TestEtcdSubCommandsHasFlags(t *testing.T) {
|
func TestEtcdSubCommandsHasFlags(t *testing.T) {
|
||||||
|
|
||||||
subCmds := getEtcdSubCommands("", phaseTestK8sVersion)
|
subCmds := getEtcdSubCommands("", phaseTestK8sVersion)
|
||||||
|
@ -18,34 +18,16 @@ package phases
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
|
||||||
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
||||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
|
||||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
kubeconfigphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig"
|
kubeconfigphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig"
|
||||||
"k8s.io/kubernetes/pkg/util/normalizer"
|
"k8s.io/kubernetes/pkg/util/normalizer"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
kubeconfigLongDesc = normalizer.LongDesc(`
|
|
||||||
kubeconfig file utilities.
|
|
||||||
` + cmdutil.AlphaDisclaimer)
|
|
||||||
|
|
||||||
userKubeconfigLongDesc = normalizer.LongDesc(`
|
|
||||||
Outputs a kubeconfig file for an additional user.
|
|
||||||
` + cmdutil.AlphaDisclaimer)
|
|
||||||
|
|
||||||
userKubeconfigExample = normalizer.Examples(`
|
|
||||||
# Outputs a kubeconfig file for an additional user named foo
|
|
||||||
kubeadm alpha kubeconfig user --client-name=foo
|
|
||||||
`)
|
|
||||||
|
|
||||||
kubeconfigFilePhaseProperties = map[string]struct {
|
kubeconfigFilePhaseProperties = map[string]struct {
|
||||||
name string
|
name string
|
||||||
short string
|
short string
|
||||||
@ -148,59 +130,3 @@ func runKubeConfigFile(kubeConfigFileName string) func(workflow.RunData) error {
|
|||||||
return kubeconfigphase.CreateKubeConfigFile(kubeConfigFileName, data.KubeConfigDir(), data.Cfg())
|
return kubeconfigphase.CreateKubeConfigFile(kubeConfigFileName, data.KubeConfigDir(), data.Cfg())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCmdKubeConfig returns main command for kubeconfig phase
|
|
||||||
func NewCmdKubeConfig(out io.Writer) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "kubeconfig",
|
|
||||||
Short: "kubeconfig file utilities",
|
|
||||||
Long: kubeconfigLongDesc,
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.AddCommand(NewCmdUserKubeConfig(out, kubeadmconstants.KubernetesDir, ""))
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCmdUserKubeConfig returns sub commands for kubeconfig phase
|
|
||||||
func NewCmdUserKubeConfig(out io.Writer, outDir, defaultKubernetesVersion string) *cobra.Command {
|
|
||||||
|
|
||||||
cfg := &kubeadmapiv1beta1.InitConfiguration{}
|
|
||||||
|
|
||||||
// Default values for the cobra help text
|
|
||||||
kubeadmscheme.Scheme.Default(cfg)
|
|
||||||
|
|
||||||
var cfgPath, token, clientName string
|
|
||||||
var organizations []string
|
|
||||||
|
|
||||||
// Creates the UX Command
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "user",
|
|
||||||
Short: "Outputs a kubeconfig file for an additional user",
|
|
||||||
Long: userKubeconfigLongDesc,
|
|
||||||
Example: userKubeconfigExample,
|
|
||||||
Run: runCmdPhase(func(outDir string, cfg *kubeadmapi.InitConfiguration) error {
|
|
||||||
if clientName == "" {
|
|
||||||
return errors.New("missing required argument --client-name")
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the kubeconfig file for an additional user has to use a token, use it
|
|
||||||
if token != "" {
|
|
||||||
return kubeconfigphase.WriteKubeConfigWithToken(out, cfg, clientName, token)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, write a kubeconfig file with a generate client cert
|
|
||||||
return kubeconfigphase.WriteKubeConfigWithClientCert(out, cfg, clientName, organizations)
|
|
||||||
}, &outDir, &cfgPath, cfg, defaultKubernetesVersion),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add flags to the command
|
|
||||||
cmd.Flags().StringVar(&cfg.CertificatesDir, "cert-dir", cfg.CertificatesDir, "The path where certificates are stored")
|
|
||||||
cmd.Flags().StringVar(&cfg.APIEndpoint.AdvertiseAddress, "apiserver-advertise-address", cfg.APIEndpoint.AdvertiseAddress, "The IP address the API server is accessible on")
|
|
||||||
cmd.Flags().Int32Var(&cfg.APIEndpoint.BindPort, "apiserver-bind-port", cfg.APIEndpoint.BindPort, "The port the API server is accessible on")
|
|
||||||
cmd.Flags().StringVar(&outDir, "kubeconfig-dir", outDir, "The path where to save the kubeconfig file")
|
|
||||||
cmd.Flags().StringVar(&token, "token", token, "The token that should be used as the authentication mechanism for this kubeconfig, instead of client certificates")
|
|
||||||
cmd.Flags().StringVar(&clientName, "client-name", clientName, "The name of user. It will be used as the CN if client certificates are created")
|
|
||||||
cmd.Flags().StringSliceVar(&organizations, "org", organizations, "The orgnizations of the client certificate. It will be used as the O if client certificates are created")
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/apimachinery/pkg/util/version"
|
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||||
@ -29,12 +28,10 @@ import (
|
|||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
|
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
|
||||||
patchnodephase "k8s.io/kubernetes/cmd/kubeadm/app/phases/patchnode"
|
patchnodephase "k8s.io/kubernetes/cmd/kubeadm/app/phases/patchnode"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/preflight"
|
|
||||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
|
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
|
||||||
kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
|
kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
|
||||||
"k8s.io/kubernetes/pkg/util/normalizer"
|
"k8s.io/kubernetes/pkg/util/normalizer"
|
||||||
utilsexec "k8s.io/utils/exec"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -60,37 +57,6 @@ var (
|
|||||||
kubeletConfigAnnotateCRIExample = normalizer.Examples(`
|
kubeletConfigAnnotateCRIExample = normalizer.Examples(`
|
||||||
kubeadm alpha phase kubelet config annotate-cri --config kubeadm.yaml
|
kubeadm alpha phase kubelet config annotate-cri --config kubeadm.yaml
|
||||||
`)
|
`)
|
||||||
|
|
||||||
kubeletConfigDownloadLongDesc = normalizer.LongDesc(`
|
|
||||||
Downloads the kubelet configuration from a ConfigMap of the form "kubelet-config-1.X" in the cluster,
|
|
||||||
where X is the minor version of the kubelet. Either kubeadm autodetects the kubelet version by exec-ing
|
|
||||||
"kubelet --version" or respects the --kubelet-version parameter.
|
|
||||||
` + cmdutil.AlphaDisclaimer)
|
|
||||||
|
|
||||||
kubeletConfigDownloadExample = normalizer.Examples(`
|
|
||||||
# Downloads the kubelet configuration from the ConfigMap in the cluster. Autodetects the kubelet version.
|
|
||||||
kubeadm alpha phase kubelet config download
|
|
||||||
|
|
||||||
# Downloads the kubelet configuration from the ConfigMap in the cluster. Uses a specific desired kubelet version.
|
|
||||||
kubeadm alpha phase kubelet config download --kubelet-version v1.12.0
|
|
||||||
`)
|
|
||||||
|
|
||||||
kubeletConfigEnableDynamicLongDesc = normalizer.LongDesc(`
|
|
||||||
Enables or updates dynamic kubelet configuration for a Node, against the kubelet-config-1.X ConfigMap in the cluster,
|
|
||||||
where X is the minor version of the desired kubelet version.
|
|
||||||
|
|
||||||
WARNING: This feature is still experimental, and disabled by default. Enable only if you know what you are doing, as it
|
|
||||||
may have surprising side-effects at this stage.
|
|
||||||
|
|
||||||
` + cmdutil.AlphaDisclaimer)
|
|
||||||
|
|
||||||
kubeletConfigEnableDynamicExample = normalizer.Examples(`
|
|
||||||
# Enables dynamic kubelet configuration for a Node.
|
|
||||||
kubeadm alpha phase kubelet enable-dynamic-config --node-name node-1 --kubelet-version v1.12.0
|
|
||||||
|
|
||||||
WARNING: This feature is still experimental, and disabled by default. Enable only if you know what you are doing, as it
|
|
||||||
may have surprising side-effects at this stage.
|
|
||||||
`)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// kubeletStartData defines the behavior that a runtime data struct passed to the kubelet start phase
|
// kubeletStartData defines the behavior that a runtime data struct passed to the kubelet start phase
|
||||||
@ -170,8 +136,6 @@ func NewCmdKubeletConfig() *cobra.Command {
|
|||||||
|
|
||||||
cmd.AddCommand(NewCmdKubeletConfigUpload())
|
cmd.AddCommand(NewCmdKubeletConfigUpload())
|
||||||
cmd.AddCommand(NewCmdKubeletAnnotateCRI())
|
cmd.AddCommand(NewCmdKubeletAnnotateCRI())
|
||||||
cmd.AddCommand(NewCmdKubeletConfigDownload())
|
|
||||||
cmd.AddCommand(NewCmdKubeletConfigEnableDynamic())
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,75 +214,3 @@ func NewCmdKubeletAnnotateCRI() *cobra.Command {
|
|||||||
options.AddConfigFlag(cmd.Flags(), &cfgPath)
|
options.AddConfigFlag(cmd.Flags(), &cfgPath)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCmdKubeletConfigDownload calls cobra.Command for downloading the kubelet configuration from the kubelet-config-1.X ConfigMap in the cluster
|
|
||||||
func NewCmdKubeletConfigDownload() *cobra.Command {
|
|
||||||
var kubeletVersionStr string
|
|
||||||
// TODO: Be smarter about this and be able to load multiple kubeconfig files in different orders of precedence
|
|
||||||
kubeConfigFile := constants.GetKubeletKubeConfigPath()
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "download",
|
|
||||||
Short: "Downloads the kubelet configuration from the cluster ConfigMap kubelet-config-1.X, where X is the minor version of the kubelet.",
|
|
||||||
Long: kubeletConfigDownloadLongDesc,
|
|
||||||
Example: kubeletConfigDownloadExample,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
kubeletVersion, err := getKubeletVersion(kubeletVersionStr)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
|
|
||||||
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
|
|
||||||
err = kubeletphase.DownloadConfig(client, kubeletVersion, constants.KubeletRunDirectory)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
options.AddKubeConfigFlag(cmd.Flags(), &kubeConfigFile)
|
|
||||||
cmd.Flags().StringVar(&kubeletVersionStr, "kubelet-version", kubeletVersionStr, "The desired version for the kubelet. Defaults to being autodetected from 'kubelet --version'.")
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
func getKubeletVersion(kubeletVersionStr string) (*version.Version, error) {
|
|
||||||
if len(kubeletVersionStr) > 0 {
|
|
||||||
return version.ParseSemantic(kubeletVersionStr)
|
|
||||||
}
|
|
||||||
return preflight.GetKubeletVersion(utilsexec.New())
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCmdKubeletConfigEnableDynamic calls cobra.Command for enabling dynamic kubelet configuration on node
|
|
||||||
// This feature is still in alpha and an experimental state
|
|
||||||
func NewCmdKubeletConfigEnableDynamic() *cobra.Command {
|
|
||||||
var nodeName, kubeletVersionStr string
|
|
||||||
kubeConfigFile := constants.GetAdminKubeConfigPath()
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "enable-dynamic",
|
|
||||||
Short: "EXPERIMENTAL: Enables or updates dynamic kubelet configuration for a Node",
|
|
||||||
Long: kubeletConfigEnableDynamicLongDesc,
|
|
||||||
Example: kubeletConfigEnableDynamicExample,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
if len(nodeName) == 0 {
|
|
||||||
kubeadmutil.CheckErr(errors.New("The --node-name argument is required"))
|
|
||||||
}
|
|
||||||
if len(kubeletVersionStr) == 0 {
|
|
||||||
kubeadmutil.CheckErr(errors.New("The --kubelet-version argument is required"))
|
|
||||||
}
|
|
||||||
|
|
||||||
kubeletVersion, err := version.ParseSemantic(kubeletVersionStr)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
|
|
||||||
kubeConfigFile = cmdutil.FindExistingKubeConfig(kubeConfigFile)
|
|
||||||
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
|
|
||||||
err = kubeletphase.EnableDynamicConfigForNode(client, nodeName, kubeletVersion)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
options.AddKubeConfigFlag(cmd.Flags(), &kubeConfigFile)
|
|
||||||
cmd.Flags().StringVar(&nodeName, "node-name", nodeName, "Name of the node that should enable the dynamic kubelet configuration")
|
|
||||||
cmd.Flags().StringVar(&kubeletVersionStr, "kubelet-version", kubeletVersionStr, "The desired version for the kubelet")
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2018 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package phases
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
cmdtestutil "k8s.io/kubernetes/cmd/kubeadm/test/cmd"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestKubeletSubCommandsHasFlags(t *testing.T) {
|
|
||||||
subCmds := []*cobra.Command{
|
|
||||||
NewCmdKubeletConfigUpload(),
|
|
||||||
NewCmdKubeletConfigDownload(),
|
|
||||||
NewCmdKubeletConfigEnableDynamic(),
|
|
||||||
}
|
|
||||||
|
|
||||||
commonFlags := []string{}
|
|
||||||
|
|
||||||
var tests = []struct {
|
|
||||||
command string
|
|
||||||
additionalFlags []string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
command: "upload",
|
|
||||||
additionalFlags: []string{
|
|
||||||
"kubeconfig",
|
|
||||||
"config",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
command: "download",
|
|
||||||
additionalFlags: []string{
|
|
||||||
"kubeconfig",
|
|
||||||
"kubelet-version",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
command: "enable-dynamic",
|
|
||||||
additionalFlags: []string{
|
|
||||||
"kubeconfig",
|
|
||||||
"node-name",
|
|
||||||
"kubelet-version",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
expectedFlags := append(commonFlags, test.additionalFlags...)
|
|
||||||
cmdtestutil.AssertSubCommandHasFlags(t, subCmds, test.command, expectedFlags...)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package phases
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewCmdPhase returns the cobra command for the "kubeadm phase" command (currently alpha-gated)
|
|
||||||
func NewCmdPhase(out io.Writer) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "phase",
|
|
||||||
Short: "Invoke subsets of kubeadm functions separately for a manual install.",
|
|
||||||
Long: cmdutil.MacroCommandLongDescription,
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.AddCommand(NewCmdAddon())
|
|
||||||
cmd.AddCommand(NewCmdBootstrapToken())
|
|
||||||
cmd.AddCommand(NewCmdCerts())
|
|
||||||
cmd.AddCommand(NewCmdEtcd())
|
|
||||||
cmd.AddCommand(NewCmdKubelet())
|
|
||||||
cmd.AddCommand(NewCmdKubeConfig(out))
|
|
||||||
cmd.AddCommand(NewCmdMarkMaster())
|
|
||||||
cmd.AddCommand(NewCmdPreFlight())
|
|
||||||
cmd.AddCommand(NewCmdSelfhosting())
|
|
||||||
cmd.AddCommand(NewCmdUploadConfig())
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
@ -17,21 +17,13 @@ limitations under the License.
|
|||||||
package phases
|
package phases
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/pkg/errors"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
|
||||||
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
|
||||||
"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"
|
||||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/preflight"
|
"k8s.io/kubernetes/cmd/kubeadm/app/preflight"
|
||||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
|
||||||
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
|
|
||||||
"k8s.io/kubernetes/pkg/util/normalizer"
|
"k8s.io/kubernetes/pkg/util/normalizer"
|
||||||
utilsexec "k8s.io/utils/exec"
|
utilsexec "k8s.io/utils/exec"
|
||||||
)
|
)
|
||||||
@ -41,17 +33,6 @@ var (
|
|||||||
# Run master pre-flight checks using a config file.
|
# Run master pre-flight checks using a config file.
|
||||||
kubeadm init phase preflight --config kubeadm-config.yml
|
kubeadm init phase preflight --config kubeadm-config.yml
|
||||||
`)
|
`)
|
||||||
|
|
||||||
nodePreflightLongDesc = normalizer.LongDesc(`
|
|
||||||
Run node pre-flight checks, functionally equivalent to what implemented by kubeadm join.
|
|
||||||
` + cmdutil.AlphaDisclaimer)
|
|
||||||
|
|
||||||
nodePreflightExample = normalizer.Examples(`
|
|
||||||
# Run node pre-flight checks.
|
|
||||||
kubeadm alpha phase preflight node
|
|
||||||
`)
|
|
||||||
|
|
||||||
errorMissingConfigFlag = errors.New("the --config flag is mandatory")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// preflightMasterData defines the behavior that a runtime data struct passed to the PreflightMaster master phase
|
// preflightMasterData defines the behavior that a runtime data struct passed to the PreflightMaster master phase
|
||||||
@ -99,56 +80,3 @@ func runPreflightMaster(c workflow.RunData) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCmdPreFlight calls cobra.Command for preflight checks
|
|
||||||
func NewCmdPreFlight() *cobra.Command {
|
|
||||||
var cfgPath string
|
|
||||||
var ignorePreflightErrors []string
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "preflight",
|
|
||||||
Short: "Run pre-flight checks",
|
|
||||||
Long: cmdutil.MacroCommandLongDescription,
|
|
||||||
}
|
|
||||||
|
|
||||||
options.AddConfigFlag(cmd.PersistentFlags(), &cfgPath)
|
|
||||||
options.AddIgnorePreflightErrorsFlag(cmd.PersistentFlags(), &ignorePreflightErrors)
|
|
||||||
|
|
||||||
cmd.AddCommand(NewCmdPreFlightNode(&cfgPath, &ignorePreflightErrors))
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCmdPreFlightNode calls cobra.Command for node preflight checks
|
|
||||||
func NewCmdPreFlightNode(cfgPath *string, ignorePreflightErrors *[]string) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "node",
|
|
||||||
Short: "Run node pre-flight checks",
|
|
||||||
Long: nodePreflightLongDesc,
|
|
||||||
Example: nodePreflightExample,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
if len(*cfgPath) == 0 {
|
|
||||||
kubeadmutil.CheckErr(errorMissingConfigFlag)
|
|
||||||
}
|
|
||||||
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(*ignorePreflightErrors)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
|
|
||||||
cfg := &kubeadmapiv1beta1.JoinConfiguration{}
|
|
||||||
kubeadmscheme.Scheme.Default(cfg)
|
|
||||||
|
|
||||||
internalcfg, err := configutil.JoinConfigFileAndDefaultsToInternalConfig(*cfgPath, cfg)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
err = configutil.VerifyAPIServerBindAddress(internalcfg.APIEndpoint.AdvertiseAddress)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
|
|
||||||
fmt.Println("[preflight] running pre-flight checks")
|
|
||||||
|
|
||||||
err = preflight.RunJoinNodeChecks(utilsexec.New(), internalcfg, ignorePreflightErrorsSet)
|
|
||||||
kubeadmutil.CheckErr(err)
|
|
||||||
|
|
||||||
fmt.Println("[preflight] pre-flight checks passed")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
@ -268,7 +268,7 @@ func WriteKubeConfigWithClientCert(out io.Writer, cfg *kubeadmapi.InitConfigurat
|
|||||||
// creates the KubeConfigSpecs, actualized for the current InitConfiguration
|
// creates the KubeConfigSpecs, actualized for the current InitConfiguration
|
||||||
caCert, caKey, err := pkiutil.TryLoadCertAndKeyFromDisk(cfg.CertificatesDir, kubeadmconstants.CACertAndKeyBaseName)
|
caCert, caKey, err := pkiutil.TryLoadCertAndKeyFromDisk(cfg.CertificatesDir, kubeadmconstants.CACertAndKeyBaseName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "couldn't create a kubeconfig; the CA files couldn't be loaded: %v")
|
return errors.Wrap(err, "couldn't create a kubeconfig; the CA files couldn't be loaded")
|
||||||
}
|
}
|
||||||
|
|
||||||
masterEndpoint, err := kubeadmutil.GetMasterEndpoint(cfg)
|
masterEndpoint, err := kubeadmutil.GetMasterEndpoint(cfg)
|
||||||
@ -295,7 +295,7 @@ func WriteKubeConfigWithToken(out io.Writer, cfg *kubeadmapi.InitConfiguration,
|
|||||||
// creates the KubeConfigSpecs, actualized for the current InitConfiguration
|
// creates the KubeConfigSpecs, actualized for the current InitConfiguration
|
||||||
caCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(cfg.CertificatesDir, kubeadmconstants.CACertAndKeyBaseName)
|
caCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(cfg.CertificatesDir, kubeadmconstants.CACertAndKeyBaseName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "couldn't create a kubeconfig; the CA files couldn't be loaded")
|
return errors.Wrap(err, "couldn't create a kubeconfig; the CA files couldn't be loaded")
|
||||||
}
|
}
|
||||||
|
|
||||||
masterEndpoint, err := kubeadmutil.GetMasterEndpoint(cfg)
|
masterEndpoint, err := kubeadmutil.GetMasterEndpoint(cfg)
|
||||||
|
Loading…
Reference in New Issue
Block a user