mirror of https://github.com/k3s-io/k3s
Merge pull request #57661 from vbmade2000/KUBE-ISSUE-340
Automatic merge from submit-queue (batch tested with PRs 59027, 62333, 57661, 62086, 61584). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Implement verbosity feature for kubeadm [WIP] Adds verbosity feature to init command hierarchy of kubeadm utility. **What this PR does / why we need it**: Implements verbosity feature to kubeadm **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes kubernetes/kubeadm#340 **Special notes for your reviewer**: I will be splitting this work into a smaller PR to keep it separate and clean. **Release note**: ```release-note Implements verbosity logging feature for kubeadm commands ```pull/8/head
commit
0023c4112b
|
@ -12,6 +12,7 @@ go_library(
|
|||
deps = [
|
||||
"//cmd/kubeadm/app/apis/kubeadm/install:go_default_library",
|
||||
"//cmd/kubeadm/app/cmd:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -59,6 +59,7 @@ go_library(
|
|||
"//pkg/util/node:go_default_library",
|
||||
"//pkg/version:go_default_library",
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/renstrom/dedent:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/renstrom/dedent"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -133,6 +134,7 @@ func RunCompletion(out io.Writer, boilerPlate string, cmd *cobra.Command, args [
|
|||
}
|
||||
|
||||
func runCompletionBash(out io.Writer, kubeadm *cobra.Command) error {
|
||||
glog.V(1).Infoln("[completion] writing completion code for Bash")
|
||||
return kubeadm.GenBashCompletion(out)
|
||||
}
|
||||
|
||||
|
@ -278,10 +280,12 @@ __kubeadm_convert_bash_to_zsh() {
|
|||
-e "s/\\\$(type${RWORD}/\$(__kubeadm_type/g" \
|
||||
<<'BASH_COMPLETION_EOF'
|
||||
`
|
||||
glog.V(1).Infoln("[completion] writing completion code for Zsh")
|
||||
out.Write([]byte(zshInitialization))
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
kubeadm.GenBashCompletion(buf)
|
||||
glog.V(1).Infoln("[completion] writing completion code for Bash")
|
||||
out.Write(buf.Bytes())
|
||||
|
||||
zshTail := `
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/renstrom/dedent"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -89,6 +90,7 @@ func NewCmdConfigView(out io.Writer, kubeConfigFile *string) *cobra.Command {
|
|||
The configuration is located in the %q namespace in the %q ConfigMap.
|
||||
`), metav1.NamespaceSystem, constants.MasterConfigurationConfigMap),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
glog.V(1).Infoln("[config] retrieving ClientSet from file")
|
||||
client, err := kubeconfigutil.ClientSetFromFile(*kubeConfigFile)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
|
@ -117,12 +119,15 @@ func NewCmdConfigUploadFromFile(out io.Writer, kubeConfigFile *string) *cobra.Co
|
|||
kubeadmutil.CheckErr(fmt.Errorf("The --config flag is mandatory"))
|
||||
}
|
||||
|
||||
glog.V(1).Infoln("[config] retrieving ClientSet from file")
|
||||
client, err := kubeconfigutil.ClientSetFromFile(*kubeConfigFile)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
// The default configuration is empty; everything should come from the file on disk
|
||||
glog.V(1).Infoln("[config] creating empty default configuration")
|
||||
defaultcfg := &kubeadmapiext.MasterConfiguration{}
|
||||
// Upload the configuration using the file; don't care about the defaultcfg really
|
||||
glog.V(1).Infof("[config] uploading configuration")
|
||||
err = uploadConfiguration(client, cfgPath, defaultcfg)
|
||||
kubeadmutil.CheckErr(err)
|
||||
},
|
||||
|
@ -150,15 +155,17 @@ func NewCmdConfigUploadFromFlags(out io.Writer, kubeConfigFile *string) *cobra.C
|
|||
`), metav1.NamespaceSystem, constants.MasterConfigurationConfigMap),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var err error
|
||||
glog.V(1).Infoln("[config] creating new FeatureGates")
|
||||
if cfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, featureGatesString); err != nil {
|
||||
kubeadmutil.CheckErr(err)
|
||||
}
|
||||
|
||||
glog.V(1).Infoln("[config] retrieving ClientSet from file")
|
||||
client, err := kubeconfigutil.ClientSetFromFile(*kubeConfigFile)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
// Default both statically and dynamically, convert to internal API type, and validate everything
|
||||
// The cfgPath argument is unset here as we shouldn't load a config file from disk, just go with cfg
|
||||
glog.V(1).Infof("[config] uploading configuration")
|
||||
err = uploadConfiguration(client, "", cfg)
|
||||
kubeadmutil.CheckErr(err)
|
||||
},
|
||||
|
@ -170,6 +177,7 @@ func NewCmdConfigUploadFromFlags(out io.Writer, kubeConfigFile *string) *cobra.C
|
|||
// RunConfigView gets the configuration persisted in the cluster
|
||||
func RunConfigView(out io.Writer, client clientset.Interface) error {
|
||||
|
||||
glog.V(1).Infoln("[config] getting the cluster configuration")
|
||||
cfgConfigMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.MasterConfigurationConfigMap, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -184,6 +192,7 @@ func uploadConfiguration(client clientset.Interface, cfgPath string, defaultcfg
|
|||
|
||||
// Default both statically and dynamically, convert to internal API type, and validate everything
|
||||
// First argument is unset here as we shouldn't load a config file from disk
|
||||
glog.V(1).Infoln("[config] converting to internal API type")
|
||||
internalcfg, err := configutil.ConfigFileAndDefaultsToInternalConfig(cfgPath, defaultcfg)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/renstrom/dedent"
|
||||
"github.com/spf13/cobra"
|
||||
flag "github.com/spf13/pflag"
|
||||
|
@ -233,6 +234,7 @@ func AddInitOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipPreFlight, sk
|
|||
func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, ignorePreflightErrors sets.String, skipTokenPrint, dryRun bool) (*Init, error) {
|
||||
|
||||
if cfgPath != "" {
|
||||
glog.V(1).Infof("[init] reading config file from: " + cfgPath)
|
||||
b, err := ioutil.ReadFile(cfgPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read config from %q [%v]", cfgPath, err)
|
||||
|
@ -243,31 +245,34 @@ func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, ignorePrefligh
|
|||
}
|
||||
|
||||
// Set defaults dynamically that the API group defaulting can't (by fetching information from the internet, looking up network interfaces, etc.)
|
||||
glog.V(1).Infof("[init] setting dynamic defaults")
|
||||
err := configutil.SetInitDynamicDefaults(cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
glog.V(1).Infof("[init] validating Kubernetes version")
|
||||
if err := features.ValidateVersion(features.InitFeatureGates, cfg.FeatureGates, cfg.KubernetesVersion); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fmt.Printf("[init] Using Kubernetes version: %s\n", cfg.KubernetesVersion)
|
||||
fmt.Printf("[init] Using Authorization modes: %v\n", cfg.AuthorizationModes)
|
||||
glog.Infof("[init] using Kubernetes version: %s\n", cfg.KubernetesVersion)
|
||||
glog.Infof("[init] using Authorization modes: %v\n", cfg.AuthorizationModes)
|
||||
|
||||
// Warn about the limitations with the current cloudprovider solution.
|
||||
if cfg.CloudProvider != "" {
|
||||
fmt.Println("[init] WARNING: For cloudprovider integrations to work --cloud-provider must be set for all kubelets in the cluster.")
|
||||
fmt.Println("\t(/etc/systemd/system/kubelet.service.d/10-kubeadm.conf should be edited for this purpose)")
|
||||
glog.Warningln("[init] for cloudprovider integrations to work --cloud-provider must be set for all kubelets in the cluster")
|
||||
glog.Infoln("\t(/etc/systemd/system/kubelet.service.d/10-kubeadm.conf should be edited for this purpose)")
|
||||
}
|
||||
|
||||
fmt.Println("[preflight] Running pre-flight checks.")
|
||||
glog.Infoln("[preflight] running pre-flight checks")
|
||||
|
||||
if err := preflight.RunInitMasterChecks(utilsexec.New(), cfg, ignorePreflightErrors); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Try to start the kubelet service in case it's inactive
|
||||
glog.V(1).Infof("Starting kubelet")
|
||||
preflight.TryStartKubelet(ignorePreflightErrors)
|
||||
|
||||
return &Init{cfg: cfg, skipTokenPrint: skipTokenPrint, dryRun: dryRun}, nil
|
||||
|
@ -291,6 +296,7 @@ func (i *Init) Validate(cmd *cobra.Command) error {
|
|||
// Run executes master node provisioning, including certificates, needed static pod manifests, etc.
|
||||
func (i *Init) Run(out io.Writer) error {
|
||||
// Get directories to write files to; can be faked if we're dry-running
|
||||
glog.V(1).Infof("[init] Getting certificates directory from configuration")
|
||||
realCertsDir := i.cfg.CertificatesDir
|
||||
certsDirToWriteTo, kubeConfigDir, manifestDir, err := getDirectoriesToUse(i.dryRun, i.cfg.CertificatesDir)
|
||||
if err != nil {
|
||||
|
@ -304,17 +310,19 @@ func (i *Init) Run(out io.Writer) error {
|
|||
if res, _ := certsphase.UsingExternalCA(i.cfg); !res {
|
||||
|
||||
// PHASE 1: Generate certificates
|
||||
glog.V(1).Infof("[init] creating PKI Assets")
|
||||
if err := certsphase.CreatePKIAssets(i.cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// PHASE 2: Generate kubeconfig files for the admin and the kubelet
|
||||
glog.V(2).Infof("[init] generating kubeconfig files")
|
||||
if err := kubeconfigphase.CreateInitKubeConfigFiles(kubeConfigDir, i.cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.Println("[externalca] The file 'ca.key' was not found, yet all other certificates are present. Using external CA mode - certificates or kubeconfig will not be generated.")
|
||||
glog.Infoln("[externalca] the file 'ca.key' was not found, yet all other certificates are present. Using external CA mode - certificates or kubeconfig will not be generated")
|
||||
}
|
||||
|
||||
if features.Enabled(i.cfg.FeatureGates, features.Auditing) {
|
||||
|
@ -337,11 +345,14 @@ func (i *Init) Run(out io.Writer) error {
|
|||
i.cfg.CertificatesDir = realCertsDir
|
||||
|
||||
// PHASE 3: Bootstrap the control plane
|
||||
glog.V(1).Infof("[init] bootstraping the control plane")
|
||||
glog.V(1).Infof("[init] creating static pod manifest")
|
||||
if err := controlplanephase.CreateInitStaticPodManifestFiles(manifestDir, i.cfg); err != nil {
|
||||
return fmt.Errorf("error creating init static pod manifest files: %v", err)
|
||||
}
|
||||
// Add etcd static pod spec only if external etcd is not configured
|
||||
if len(i.cfg.Etcd.Endpoints) == 0 {
|
||||
glog.V(1).Infof("[init] no external etcd found. Creating manifest for local etcd static pod")
|
||||
if err := etcdphase.CreateLocalEtcdStaticPodManifestFile(manifestDir, i.cfg); err != nil {
|
||||
return fmt.Errorf("error creating local etcd static pod manifest file: %v", err)
|
||||
}
|
||||
|
@ -357,6 +368,8 @@ func (i *Init) Run(out io.Writer) error {
|
|||
|
||||
// NOTE: flag "--dynamic-config-dir" should be specified in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
||||
if features.Enabled(i.cfg.FeatureGates, features.DynamicKubeletConfig) {
|
||||
glog.V(1).Infof("[init] feature --dynamic-config-dir is enabled")
|
||||
glog.V(1).Infof("[init] writing base kubelet configuration to disk on master")
|
||||
// Write base kubelet configuration for dynamic kubelet configuration feature.
|
||||
if err := kubeletphase.WriteInitKubeletConfigToDiskOnMaster(i.cfg); err != nil {
|
||||
return fmt.Errorf("error writing base kubelet configuration to disk: %v", err)
|
||||
|
@ -364,12 +377,14 @@ func (i *Init) Run(out io.Writer) error {
|
|||
}
|
||||
|
||||
// Create a kubernetes client and wait for the API server to be healthy (if not dryrunning)
|
||||
glog.V(1).Infof("creating Kubernetes client")
|
||||
client, err := createClient(i.cfg, i.dryRun)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating client: %v", err)
|
||||
}
|
||||
|
||||
// waiter holds the apiclient.Waiter implementation of choice, responsible for querying the API server in various ways and waiting for conditions to be fulfilled
|
||||
glog.V(1).Infof("[init] waiting for the API server to be healthy")
|
||||
waiter := getWaiter(i, client)
|
||||
|
||||
if err := waitForAPIAndKubelet(waiter); err != nil {
|
||||
|
@ -389,6 +404,7 @@ func (i *Init) Run(out io.Writer) error {
|
|||
// NOTE: flag "--dynamic-config-dir" should be specified in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
||||
if features.Enabled(i.cfg.FeatureGates, features.DynamicKubeletConfig) {
|
||||
// Create base kubelet configuration for dynamic kubelet configuration feature.
|
||||
glog.V(1).Infof("[init] creating base kubelet configuration")
|
||||
if err := kubeletphase.CreateBaseKubeletConfiguration(i.cfg, client); err != nil {
|
||||
return fmt.Errorf("error creating base kubelet configuration: %v", err)
|
||||
}
|
||||
|
@ -397,60 +413,71 @@ func (i *Init) Run(out io.Writer) error {
|
|||
// Upload currently used configuration to the cluster
|
||||
// Note: This is done right in the beginning of cluster initialization; as we might want to make other phases
|
||||
// depend on centralized information from this source in the future
|
||||
glog.V(1).Infof("[init] uploading currently used configuration to the cluster")
|
||||
if err := uploadconfigphase.UploadConfiguration(i.cfg, client); err != nil {
|
||||
return fmt.Errorf("error uploading configuration: %v", err)
|
||||
}
|
||||
|
||||
// PHASE 4: Mark the master with the right label/taint
|
||||
glog.V(1).Infof("[init] marking the master with right label")
|
||||
if err := markmasterphase.MarkMaster(client, i.cfg.NodeName, !i.cfg.NoTaintMaster); err != nil {
|
||||
return fmt.Errorf("error marking master: %v", err)
|
||||
}
|
||||
|
||||
// PHASE 5: Set up the node bootstrap tokens
|
||||
if !i.skipTokenPrint {
|
||||
fmt.Printf("[bootstraptoken] Using token: %s\n", i.cfg.Token)
|
||||
glog.Infof("[bootstraptoken] using token: %s\n", i.cfg.Token)
|
||||
}
|
||||
|
||||
// Create the default node bootstrap token
|
||||
glog.V(1).Infof("[init] creating RBAC rules to generate default bootstrap token")
|
||||
tokenDescription := "The default bootstrap token generated by 'kubeadm init'."
|
||||
if err := nodebootstraptokenphase.UpdateOrCreateToken(client, i.cfg.Token, false, i.cfg.TokenTTL.Duration, i.cfg.TokenUsages, i.cfg.TokenGroups, tokenDescription); err != nil {
|
||||
return fmt.Errorf("error updating or creating token: %v", err)
|
||||
}
|
||||
// Create RBAC rules that makes the bootstrap tokens able to post CSRs
|
||||
glog.V(1).Infof("[init] creating RBAC rules to allow bootstrap tokens to post CSR")
|
||||
if err := nodebootstraptokenphase.AllowBootstrapTokensToPostCSRs(client); err != nil {
|
||||
return fmt.Errorf("error allowing bootstrap tokens to post CSRs: %v", err)
|
||||
}
|
||||
// Create RBAC rules that makes the bootstrap tokens able to get their CSRs approved automatically
|
||||
glog.V(1).Infof("[init] creating RBAC rules to automatic approval of CSRs automatically")
|
||||
if err := nodebootstraptokenphase.AutoApproveNodeBootstrapTokens(client); err != nil {
|
||||
return fmt.Errorf("error auto-approving node bootstrap tokens: %v", err)
|
||||
}
|
||||
|
||||
// Create/update RBAC rules that makes the nodes to rotate certificates and get their CSRs approved automatically
|
||||
glog.V(1).Infof("[init] creating/updating RBAC rules for rotating certificate")
|
||||
if err := nodebootstraptokenphase.AutoApproveNodeCertificateRotation(client); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Create the cluster-info ConfigMap with the associated RBAC rules
|
||||
glog.V(1).Infof("[init] creating bootstrap configmap")
|
||||
if err := clusterinfophase.CreateBootstrapConfigMapIfNotExists(client, adminKubeConfigPath); err != nil {
|
||||
return fmt.Errorf("error creating bootstrap configmap: %v", err)
|
||||
}
|
||||
glog.V(1).Infof("[init] creating ClusterInfo RBAC rules")
|
||||
if err := clusterinfophase.CreateClusterInfoRBACRules(client); err != nil {
|
||||
return fmt.Errorf("error creating clusterinfo RBAC rules: %v", err)
|
||||
}
|
||||
|
||||
glog.V(1).Infof("[init] ensuring DNS addon")
|
||||
if err := dnsaddonphase.EnsureDNSAddon(i.cfg, client); err != nil {
|
||||
return fmt.Errorf("error ensuring dns addon: %v", err)
|
||||
}
|
||||
|
||||
glog.V(1).Infof("[init] ensuring proxy addon")
|
||||
if err := proxyaddonphase.EnsureProxyAddon(i.cfg, client); err != nil {
|
||||
return fmt.Errorf("error ensuring proxy addon: %v", err)
|
||||
}
|
||||
|
||||
// PHASE 7: Make the control plane self-hosted if feature gate is enabled
|
||||
glog.V(1).Infof("[init] feature gate is enabled. Making control plane self-hosted")
|
||||
if features.Enabled(i.cfg.FeatureGates, features.SelfHosting) {
|
||||
// Temporary control plane is up, now we create our self hosted control
|
||||
// plane components and remove the static manifests:
|
||||
fmt.Println("[self-hosted] Creating self-hosted control plane.")
|
||||
glog.Infoln("[self-hosted] creating self-hosted control plane")
|
||||
if err := selfhostingphase.CreateSelfHostedControlPlane(manifestDir, kubeConfigDir, i.cfg, client, waiter, i.dryRun); err != nil {
|
||||
return fmt.Errorf("error creating self hosted control plane: %v", err)
|
||||
}
|
||||
|
@ -458,7 +485,7 @@ func (i *Init) Run(out io.Writer) error {
|
|||
|
||||
// Exit earlier if we're dryrunning
|
||||
if i.dryRun {
|
||||
fmt.Println("[dryrun] Finished dry-running successfully. Above are the resources that would be created.")
|
||||
fmt.Println("[dryrun] finished dry-running successfully. Above are the resources that would be created")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -509,9 +536,9 @@ func printFilesIfDryRunning(dryRun bool, manifestDir string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
fmt.Printf("[dryrun] Wrote certificates, kubeconfig files and control plane manifests to the %q directory.\n", manifestDir)
|
||||
fmt.Println("[dryrun] The certificates or kubeconfig files would not be printed due to their sensitive nature.")
|
||||
fmt.Printf("[dryrun] Please examine the %q directory for details about what would be written.\n", manifestDir)
|
||||
glog.Infof("[dryrun] wrote certificates, kubeconfig files and control plane manifests to the %q directory\n", manifestDir)
|
||||
glog.Infoln("[dryrun] the certificates or kubeconfig files would not be printed due to their sensitive nature")
|
||||
glog.Infof("[dryrun] please examine the %q directory for details about what would be written\n", manifestDir)
|
||||
|
||||
// Print the contents of the upgraded manifests and pretend like they were in /etc/kubernetes/manifests
|
||||
files := []dryrunutil.FileToPrint{}
|
||||
|
@ -545,8 +572,8 @@ func getWaiter(i *Init, client clientset.Interface) apiclient.Waiter {
|
|||
func waitForAPIAndKubelet(waiter apiclient.Waiter) error {
|
||||
errorChan := make(chan error)
|
||||
|
||||
fmt.Printf("[init] Waiting for the kubelet to boot up the control plane as Static Pods from directory %q.\n", kubeadmconstants.GetStaticPodDirectory())
|
||||
fmt.Println("[init] This might take a minute or longer if the control plane images have to be pulled.")
|
||||
glog.Infof("[init] waiting for the kubelet to boot up the control plane as Static Pods from directory %q \n", kubeadmconstants.GetStaticPodDirectory())
|
||||
glog.Infoln("[init] this might take a minute or longer if the control plane images have to be pulled")
|
||||
|
||||
go func(errC chan error, waiter apiclient.Waiter) {
|
||||
// This goroutine can only make kubeadm init fail. If this check succeeds, it won't do anything special
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/renstrom/dedent"
|
||||
"github.com/spf13/cobra"
|
||||
flag "github.com/spf13/pflag"
|
||||
|
@ -200,27 +201,33 @@ type Join struct {
|
|||
func NewJoin(cfgPath string, args []string, cfg *kubeadmapi.NodeConfiguration, ignorePreflightErrors sets.String) (*Join, error) {
|
||||
|
||||
if cfg.NodeName == "" {
|
||||
glog.V(1).Infoln("[join] found NodeName empty")
|
||||
glog.V(1).Infoln("[join] considered OS hostname as NodeName")
|
||||
cfg.NodeName = nodeutil.GetHostname("")
|
||||
}
|
||||
|
||||
if cfgPath != "" {
|
||||
glog.V(1).Infoln("[join] reading configuration from", cfgPath)
|
||||
b, err := ioutil.ReadFile(cfgPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read config from %q [%v]", cfgPath, err)
|
||||
}
|
||||
glog.V(1).Infoln("[join] decoding configuration information")
|
||||
if err := runtime.DecodeInto(legacyscheme.Codecs.UniversalDecoder(), b, cfg); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode config from %q [%v]", cfgPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("[preflight] Running pre-flight checks.")
|
||||
glog.Infoln("[preflight] running pre-flight checks")
|
||||
|
||||
// Then continue with the others...
|
||||
glog.V(1).Infoln("[preflight] running various checks on all nodes")
|
||||
if err := preflight.RunJoinNodeChecks(utilsexec.New(), cfg, ignorePreflightErrors); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Try to start the kubelet service in case it's inactive
|
||||
glog.V(1).Infoln("[preflight] starting kubelet service if it's inactive")
|
||||
preflight.TryStartKubelet(ignorePreflightErrors)
|
||||
|
||||
return &Join{cfg: cfg}, nil
|
||||
|
@ -236,6 +243,7 @@ func (j *Join) Validate(cmd *cobra.Command) error {
|
|||
|
||||
// Run executes worker node provisioning and tries to join an existing cluster.
|
||||
func (j *Join) Run(out io.Writer) error {
|
||||
glog.V(1).Infoln("[join] retrieving KubeConfig objects")
|
||||
cfg, err := discovery.For(j.cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -244,6 +252,7 @@ func (j *Join) Run(out io.Writer) error {
|
|||
kubeconfigFile := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletBootstrapKubeConfigFileName)
|
||||
|
||||
// Write the bootstrap kubelet config file or the TLS-Boostrapped kubelet config file down to disk
|
||||
glog.V(1).Infoln("[join] writing bootstrap kubelet config file at", kubeconfigFile)
|
||||
if err := kubeconfigutil.WriteToDisk(kubeconfigFile, cfg); err != nil {
|
||||
return fmt.Errorf("couldn't save bootstrap-kubelet.conf to disk: %v", err)
|
||||
}
|
||||
|
@ -256,6 +265,7 @@ func (j *Join) Run(out io.Writer) error {
|
|||
}
|
||||
|
||||
// NOTE: flag "--dynamic-config-dir" should be specified in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
||||
glog.V(1).Infoln("[join] consuming base kubelet configuration")
|
||||
if features.Enabled(j.cfg.FeatureGates, features.DynamicKubeletConfig) {
|
||||
if err := kubeletphase.ConsumeBaseKubeletConfiguration(j.cfg.NodeName); err != nil {
|
||||
return fmt.Errorf("error consuming base kubelet configuration: %v", err)
|
||||
|
|
|
@ -48,6 +48,7 @@ go_library(
|
|||
"//cmd/kubeadm/app/util/kubeconfig:go_default_library",
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/util/normalizer:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
|
@ -19,6 +19,7 @@ package phases
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
|
@ -80,6 +81,7 @@ func EnsureAllAddons(cfg *kubeadmapi.MasterConfiguration, client clientset.Inter
|
|||
proxyaddon.EnsureProxyAddon,
|
||||
}
|
||||
|
||||
glog.V(1).Infoln("[addon] installing all addons")
|
||||
for _, action := range addonActions {
|
||||
err := action(cfg, client)
|
||||
if err != nil {
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
|
@ -316,19 +317,20 @@ func createBootstrapToken(kubeConfigFile string, client clientset.Interface, cfg
|
|||
return err
|
||||
}
|
||||
|
||||
glog.V(1).Infoln("[bootstraptoken] creating/updating token")
|
||||
// Creates or updates the token
|
||||
if err := node.UpdateOrCreateToken(client, internalcfg.Token, false, internalcfg.TokenTTL.Duration, internalcfg.TokenUsages, internalcfg.TokenGroups, description); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("[bootstraptoken] Bootstrap token Created")
|
||||
fmt.Println("[bootstraptoken] You can now join any number of machines by running:")
|
||||
glog.Infoln("[bootstraptoken] bootstrap token created")
|
||||
glog.Infoln("[bootstraptoken] you can now join any number of machines by running:")
|
||||
|
||||
joinCommand, err := cmdutil.GetJoinCommand(kubeConfigFile, internalcfg.Token, skipTokenPrint)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get join command: %v", err)
|
||||
}
|
||||
fmt.Println(joinCommand)
|
||||
glog.Infoln(joinCommand)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
@ -93,7 +94,7 @@ type Reset struct {
|
|||
|
||||
// NewReset instantiate Reset struct
|
||||
func NewReset(ignorePreflightErrors sets.String, certsDir, criSocketPath string) (*Reset, error) {
|
||||
fmt.Println("[preflight] Running pre-flight checks.")
|
||||
glog.Infoln("[preflight] running pre-flight checks")
|
||||
|
||||
if err := preflight.RunRootCheckOnly(ignorePreflightErrors); err != nil {
|
||||
return nil, err
|
||||
|
@ -109,27 +110,30 @@ func NewReset(ignorePreflightErrors sets.String, certsDir, criSocketPath string)
|
|||
func (r *Reset) Run(out io.Writer) error {
|
||||
|
||||
// Try to stop the kubelet service
|
||||
glog.V(1).Infof("[reset] getting init system")
|
||||
initSystem, err := initsystem.GetInitSystem()
|
||||
if err != nil {
|
||||
fmt.Println("[reset] WARNING: The kubelet service could not be stopped by kubeadm. Unable to detect a supported init system!")
|
||||
fmt.Println("[reset] WARNING: Please ensure kubelet is stopped manually.")
|
||||
glog.Warningln("[reset] the kubelet service could not be stopped by kubeadm. Unable to detect a supported init system!")
|
||||
glog.Warningln("[reset] please ensure kubelet is stopped manually")
|
||||
} else {
|
||||
fmt.Println("[reset] Stopping the kubelet service.")
|
||||
glog.Infoln("[reset] stopping the kubelet service")
|
||||
if err := initSystem.ServiceStop("kubelet"); err != nil {
|
||||
fmt.Printf("[reset] WARNING: The kubelet service could not be stopped by kubeadm: [%v]\n", err)
|
||||
fmt.Println("[reset] WARNING: Please ensure kubelet is stopped manually.")
|
||||
glog.Warningf("[reset] the kubelet service could not be stopped by kubeadm: [%v]\n", err)
|
||||
glog.Warningln("[reset] please ensure kubelet is stopped manually")
|
||||
}
|
||||
}
|
||||
|
||||
// Try to unmount mounted directories under /var/lib/kubelet in order to be able to remove the /var/lib/kubelet directory later
|
||||
fmt.Printf("[reset] Unmounting mounted directories in %q\n", "/var/lib/kubelet")
|
||||
glog.Infof("[reset] unmounting mounted directories in %q\n", "/var/lib/kubelet")
|
||||
umountDirsCmd := "awk '$2 ~ path {print $2}' path=/var/lib/kubelet /proc/mounts | xargs -r umount"
|
||||
|
||||
glog.V(1).Infof("[reset] executing command %q", umountDirsCmd)
|
||||
umountOutputBytes, err := exec.Command("sh", "-c", umountDirsCmd).Output()
|
||||
if err != nil {
|
||||
fmt.Printf("[reset] Failed to unmount mounted directories in /var/lib/kubelet: %s\n", string(umountOutputBytes))
|
||||
glog.Errorf("[reset] failed to unmount mounted directories in /var/lib/kubelet: %s\n", string(umountOutputBytes))
|
||||
}
|
||||
|
||||
fmt.Println("[reset] Removing kubernetes-managed containers.")
|
||||
glog.Infoln("[reset] removing kubernetes-managed containers")
|
||||
dockerCheck := preflight.ServiceCheck{Service: "docker", CheckIfActive: true}
|
||||
execer := utilsexec.New()
|
||||
|
||||
|
@ -140,21 +144,25 @@ func (r *Reset) Run(out io.Writer) error {
|
|||
// Only clear etcd data when the etcd manifest is found. In case it is not found, we must assume that the user
|
||||
// provided external etcd endpoints. In that case, it is his own responsibility to reset etcd
|
||||
etcdManifestPath := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName, "etcd.yaml")
|
||||
glog.V(1).Infof("[reset] checking for etcd manifest")
|
||||
if _, err := os.Stat(etcdManifestPath); err == nil {
|
||||
glog.V(1).Infof("Found one at %s", etcdManifestPath)
|
||||
dirsToClean = append(dirsToClean, "/var/lib/etcd")
|
||||
} else {
|
||||
fmt.Printf("[reset] No etcd manifest found in %q. Assuming external etcd.\n", etcdManifestPath)
|
||||
glog.Infof("[reset] no etcd manifest found in %q. Assuming external etcd\n", etcdManifestPath)
|
||||
}
|
||||
|
||||
// Then clean contents from the stateful kubelet, etcd and cni directories
|
||||
fmt.Printf("[reset] Deleting contents of stateful directories: %v\n", dirsToClean)
|
||||
glog.Infof("[reset] deleting contents of stateful directories: %v\n", dirsToClean)
|
||||
for _, dir := range dirsToClean {
|
||||
glog.V(1).Infof("[reset] deleting content of %s", dir)
|
||||
cleanDir(dir)
|
||||
}
|
||||
|
||||
// Remove contents from the config and pki directories
|
||||
glog.V(1).Infoln("[reset] removing contents from the config and pki directories")
|
||||
if r.certsDir != kubeadmapiext.DefaultCertificatesDir {
|
||||
fmt.Printf("[reset] WARNING: Cleaning a non-default certificates directory: %q\n", r.certsDir)
|
||||
glog.Warningf("[reset] WARNING: cleaning a non-default certificates directory: %q\n", r.certsDir)
|
||||
}
|
||||
resetConfigDir(kubeadmconstants.KubernetesDir, r.certsDir)
|
||||
|
||||
|
@ -173,40 +181,46 @@ func reset(execer utilsexec.Interface, dockerCheck preflight.Checker, criSocketP
|
|||
func resetWithDocker(execer utilsexec.Interface, dockerCheck preflight.Checker) {
|
||||
if _, errors := dockerCheck.Check(); len(errors) == 0 {
|
||||
if err := execer.Command("sh", "-c", "docker ps -a --filter name=k8s_ -q | xargs -r docker rm --force --volumes").Run(); err != nil {
|
||||
fmt.Println("[reset] Failed to stop the running containers.")
|
||||
glog.Errorln("[reset] Failed to stop the running containers")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("[reset] Docker doesn't seem to be running. Skipping the removal of running Kubernetes containers.")
|
||||
glog.Infoln("[reset] docker doesn't seem to be running. Skipping the removal of running Kubernetes containers")
|
||||
}
|
||||
}
|
||||
|
||||
func resetWithCrictl(execer utilsexec.Interface, dockerCheck preflight.Checker, criSocketPath, crictlPath string) {
|
||||
if criSocketPath != "" {
|
||||
fmt.Printf("[reset] Cleaning up running containers using crictl with socket %s\n", criSocketPath)
|
||||
glog.Infof("[reset] cleaning up running containers using crictl with socket %s\n", criSocketPath)
|
||||
glog.V(1).Infoln("[reset] listing running pods using crictl")
|
||||
|
||||
listcmd := fmt.Sprintf(crictlSandboxesParamsFormat, crictlPath, criSocketPath)
|
||||
glog.V(1).Infof("[reset] executing comand %q", listcmd)
|
||||
output, err := execer.Command(listcmd).CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Println("[reset] Failed to list running pods using crictl. Trying using docker instead.")
|
||||
glog.Infoln("[reset] failed to list running pods using crictl. Trying using docker instead")
|
||||
resetWithDocker(execer, dockerCheck)
|
||||
return
|
||||
}
|
||||
sandboxes := strings.Split(string(output), " ")
|
||||
glog.V(1).Infoln("[reset] stopping and removing running containers using crictl")
|
||||
for _, s := range sandboxes {
|
||||
stopcmd := fmt.Sprintf(crictlStopParamsFormat, crictlPath, criSocketPath, s)
|
||||
glog.V(1).Infof("[reset] executing command %q", stopcmd)
|
||||
if err := execer.Command(stopcmd).Run(); err != nil {
|
||||
fmt.Println("[reset] Failed to stop the running containers using crictl. Trying using docker instead.")
|
||||
glog.Infoln("[reset] failed to stop the running containers using crictl. Trying using docker instead")
|
||||
resetWithDocker(execer, dockerCheck)
|
||||
return
|
||||
}
|
||||
removecmd := fmt.Sprintf(crictlRemoveParamsFormat, crictlPath, criSocketPath, s)
|
||||
glog.V(1).Infof("[reset] executing command %q", removecmd)
|
||||
if err := execer.Command(removecmd).Run(); err != nil {
|
||||
fmt.Println("[reset] Failed to remove the running containers using crictl. Trying using docker instead.")
|
||||
glog.Infoln("[reset] failed to remove the running containers using crictl. Trying using docker instead")
|
||||
resetWithDocker(execer, dockerCheck)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fmt.Println("[reset] CRI socket path not provided for crictl. Trying docker instead.")
|
||||
glog.Infoln("[reset] CRI socket path not provided for crictl. Trying docker instead")
|
||||
resetWithDocker(execer, dockerCheck)
|
||||
}
|
||||
}
|
||||
|
@ -242,10 +256,10 @@ func resetConfigDir(configPathDir, pkiPathDir string) {
|
|||
filepath.Join(configPathDir, kubeadmconstants.ManifestsSubDirName),
|
||||
pkiPathDir,
|
||||
}
|
||||
fmt.Printf("[reset] Deleting contents of config directories: %v\n", dirsToClean)
|
||||
glog.Infof("[reset] deleting contents of config directories: %v\n", dirsToClean)
|
||||
for _, dir := range dirsToClean {
|
||||
if err := cleanDir(dir); err != nil {
|
||||
fmt.Printf("[reset] Failed to remove directory: %q [%v]\n", dir, err)
|
||||
glog.Errorf("[reset] failed to remove directory: %q [%v]\n", dir, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,10 +270,10 @@ func resetConfigDir(configPathDir, pkiPathDir string) {
|
|||
filepath.Join(configPathDir, kubeadmconstants.ControllerManagerKubeConfigFileName),
|
||||
filepath.Join(configPathDir, kubeadmconstants.SchedulerKubeConfigFileName),
|
||||
}
|
||||
fmt.Printf("[reset] Deleting files: %v\n", filesToClean)
|
||||
glog.Infof("[reset] deleting files: %v\n", filesToClean)
|
||||
for _, path := range filesToClean {
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
fmt.Printf("[reset] Failed to remove file: %q [%v]\n", path, err)
|
||||
glog.Errorf("[reset] failed to remove file: %q [%v]\n", path, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/renstrom/dedent"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -115,10 +116,11 @@ func NewCmdToken(out io.Writer, errW io.Writer) *cobra.Command {
|
|||
if len(args) != 0 {
|
||||
cfg.Token = args[0]
|
||||
}
|
||||
|
||||
glog.V(1).Infoln("[token] validating mixed arguments")
|
||||
err := validation.ValidateMixedArguments(tokenCmd.Flags())
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
glog.V(1).Infoln("[token] getting Clientsets from KubeConfig file")
|
||||
client, err := getClientset(kubeConfigFile, dryRun)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
|
@ -211,11 +213,13 @@ func NewCmdTokenGenerate(out io.Writer) *cobra.Command {
|
|||
// RunCreateToken generates a new bootstrap token and stores it as a secret on the server.
|
||||
func RunCreateToken(out io.Writer, client clientset.Interface, cfgPath string, cfg *kubeadmapiext.MasterConfiguration, description string, printJoinCommand bool, kubeConfigFile string) error {
|
||||
// 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
|
||||
glog.V(1).Infoln("[token] loading configurations")
|
||||
internalcfg, err := configutil.ConfigFileAndDefaultsToInternalConfig(cfgPath, cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
glog.V(1).Infoln("[token] creating token")
|
||||
err = tokenphase.CreateNewToken(client, internalcfg.Token, internalcfg.TokenTTL.Duration, internalcfg.TokenUsages, internalcfg.TokenGroups, description)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -238,6 +242,7 @@ func RunCreateToken(out io.Writer, client clientset.Interface, cfgPath string, c
|
|||
|
||||
// RunGenerateToken just generates a random token for the user
|
||||
func RunGenerateToken(out io.Writer) error {
|
||||
glog.V(1).Infoln("[token] generating randodm token")
|
||||
token, err := tokenutil.GenerateToken()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -250,6 +255,7 @@ func RunGenerateToken(out io.Writer) error {
|
|||
// RunListTokens lists details on all existing bootstrap tokens on the server.
|
||||
func RunListTokens(out io.Writer, errW io.Writer, client clientset.Interface) error {
|
||||
// First, build our selector for bootstrap tokens only
|
||||
glog.V(1).Infoln("[token] preparing selector for bootstrap token")
|
||||
tokenSelector := fields.SelectorFromSet(
|
||||
map[string]string{
|
||||
api.SecretTypeField: string(bootstrapapi.SecretTypeBootstrapToken),
|
||||
|
@ -259,6 +265,7 @@ func RunListTokens(out io.Writer, errW io.Writer, client clientset.Interface) er
|
|||
FieldSelector: tokenSelector.String(),
|
||||
}
|
||||
|
||||
glog.V(1).Infoln("[token] retrieving list of bootstrap tokens")
|
||||
secrets, err := client.CoreV1().Secrets(metav1.NamespaceSystem).List(listOptions)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to list bootstrap tokens [%v]", err)
|
||||
|
@ -338,6 +345,7 @@ func RunListTokens(out io.Writer, errW io.Writer, client clientset.Interface) er
|
|||
func RunDeleteToken(out io.Writer, client clientset.Interface, tokenIDOrToken string) error {
|
||||
// Assume the given first argument is a token id and try to parse it
|
||||
tokenID := tokenIDOrToken
|
||||
glog.V(1).Infoln("[token] parsing token ID")
|
||||
if err := tokenutil.ParseTokenID(tokenIDOrToken); err != nil {
|
||||
if tokenID, _, err = tokenutil.ParseToken(tokenIDOrToken); err != nil {
|
||||
return fmt.Errorf("given token or token id %q didn't match pattern [%q] or [%q]", tokenIDOrToken, tokenutil.TokenIDRegexpString, tokenutil.TokenRegexpString)
|
||||
|
@ -345,6 +353,7 @@ func RunDeleteToken(out io.Writer, client clientset.Interface, tokenIDOrToken st
|
|||
}
|
||||
|
||||
tokenSecretName := fmt.Sprintf("%s%s", bootstrapapi.BootstrapTokenSecretPrefix, tokenID)
|
||||
glog.V(1).Infoln("[token] deleting token")
|
||||
if err := client.CoreV1().Secrets(metav1.NamespaceSystem).Delete(tokenSecretName, nil); err != nil {
|
||||
return fmt.Errorf("failed to delete bootstrap token [%v]", err)
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ go_library(
|
|||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/util/version:go_default_library",
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/client-go/discovery/fake:go_default_library",
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
|
@ -78,11 +79,13 @@ func NewCmdApply(parentFlags *cmdUpgradeFlags) *cobra.Command {
|
|||
kubeadmutil.CheckErr(err)
|
||||
|
||||
// Ensure the user is root
|
||||
glog.V(1).Infof("running preflight checks")
|
||||
err = runPreflightChecks(flags.parent.ignorePreflightErrorsSet)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
// If the version is specified in config file, pick up that value.
|
||||
if flags.parent.cfgPath != "" {
|
||||
glog.V(1).Infof("fetching configuration from file", flags.parent.cfgPath)
|
||||
cfg, err := upgrade.FetchConfigurationFromFile(flags.parent.cfgPath)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
|
@ -136,16 +139,20 @@ func NewCmdApply(parentFlags *cmdUpgradeFlags) *cobra.Command {
|
|||
func RunApply(flags *applyFlags) error {
|
||||
|
||||
// Start with the basics, verify that the cluster is healthy and get the configuration from the cluster (using the ConfigMap)
|
||||
glog.V(1).Infof("[upgrade/apply] verifying health of cluster")
|
||||
glog.V(1).Infof("[upgrade/apply] retrieving configuration from cluster")
|
||||
upgradeVars, err := enforceRequirements(flags.parent, flags.dryRun, flags.newK8sVersionStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Grab the external, versioned configuration and convert it to the internal type for usage here later
|
||||
glog.V(1).Infof("[upgrade/apply] converting configuration for internal use")
|
||||
internalcfg := &kubeadmapi.MasterConfiguration{}
|
||||
legacyscheme.Scheme.Convert(upgradeVars.cfg, internalcfg, nil)
|
||||
|
||||
// Validate requested and validate actual version
|
||||
glog.V(1).Infof("[upgrade/apply] validating requested and actual version")
|
||||
if err := configutil.NormalizeKubernetesVersion(internalcfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -163,6 +170,7 @@ func RunApply(flags *applyFlags) error {
|
|||
}
|
||||
|
||||
// Enforce the version skew policies
|
||||
glog.V(1).Infof("[upgrade/version] enforcing version skew policies")
|
||||
if err := EnforceVersionPolicies(flags, upgradeVars.versionGetter); err != nil {
|
||||
return fmt.Errorf("[upgrade/version] FATAL: %v", err)
|
||||
}
|
||||
|
@ -176,28 +184,31 @@ func RunApply(flags *applyFlags) error {
|
|||
|
||||
// Use a prepuller implementation based on creating DaemonSets
|
||||
// and block until all DaemonSets are ready; then we know for sure that all control plane images are cached locally
|
||||
glog.V(1).Infof("[upgrade/apply] creating prepuller")
|
||||
prepuller := upgrade.NewDaemonSetPrepuller(upgradeVars.client, upgradeVars.waiter, internalcfg)
|
||||
upgrade.PrepullImagesInParallel(prepuller, flags.imagePullTimeout)
|
||||
|
||||
// Now; perform the upgrade procedure
|
||||
glog.V(1).Infof("[upgrade/apply] performing upgrade")
|
||||
if err := PerformControlPlaneUpgrade(flags, upgradeVars.client, upgradeVars.waiter, internalcfg); err != nil {
|
||||
return fmt.Errorf("[upgrade/apply] FATAL: %v", err)
|
||||
}
|
||||
|
||||
// Upgrade RBAC rules and addons.
|
||||
glog.V(1).Infof("[upgrade/postupgrade] upgrading RBAC rules and addons")
|
||||
if err := upgrade.PerformPostUpgradeTasks(upgradeVars.client, internalcfg, flags.newK8sVersion, flags.dryRun); err != nil {
|
||||
return fmt.Errorf("[upgrade/postupgrade] FATAL post-upgrade error: %v", err)
|
||||
}
|
||||
|
||||
if flags.dryRun {
|
||||
fmt.Println("[dryrun] Finished dryrunning successfully!")
|
||||
glog.Infoln("[dryrun] Finished dryrunning successfully!")
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Println("")
|
||||
fmt.Printf("[upgrade/successful] SUCCESS! Your cluster was upgraded to %q. Enjoy!\n", flags.newK8sVersionStr)
|
||||
fmt.Println("")
|
||||
fmt.Println("[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets in turn.")
|
||||
glog.Infoln("")
|
||||
glog.Infof("[upgrade/successful] SUCCESS! Your cluster was upgraded to %q. Enjoy!\n", flags.newK8sVersionStr)
|
||||
glog.Infoln("")
|
||||
glog.Infoln("[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets in turn.")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -219,7 +230,7 @@ func SetImplicitFlags(flags *applyFlags) error {
|
|||
// EnforceVersionPolicies makes sure that the version the user specified is valid to upgrade to
|
||||
// There are both fatal and skippable (with --force) errors
|
||||
func EnforceVersionPolicies(flags *applyFlags, versionGetter upgrade.VersionGetter) error {
|
||||
fmt.Printf("[upgrade/version] You have chosen to change the cluster version to %q\n", flags.newK8sVersionStr)
|
||||
glog.Infof("[upgrade/version] You have chosen to change the cluster version to %q\n", flags.newK8sVersionStr)
|
||||
|
||||
versionSkewErrs := upgrade.EnforceVersionPolicies(versionGetter, flags.newK8sVersionStr, flags.newK8sVersion, flags.parent.allowExperimentalUpgrades, flags.parent.allowRCUpgrades)
|
||||
if versionSkewErrs != nil {
|
||||
|
@ -234,7 +245,7 @@ func EnforceVersionPolicies(flags *applyFlags, versionGetter upgrade.VersionGett
|
|||
return fmt.Errorf("The --version argument is invalid due to these errors:\n\n%v\nCan be bypassed if you pass the --force flag", kubeadmutil.FormatErrMsg(versionSkewErrs.Skippable))
|
||||
}
|
||||
// Soft errors found, but --force was specified
|
||||
fmt.Printf("[upgrade/version] Found %d potential version compatibility errors but skipping since the --force flag is set: \n\n%v", len(versionSkewErrs.Skippable), kubeadmutil.FormatErrMsg(versionSkewErrs.Skippable))
|
||||
glog.Infof("[upgrade/version] Found %d potential version compatibility errors but skipping since the --force flag is set: \n\n%v", len(versionSkewErrs.Skippable), kubeadmutil.FormatErrMsg(versionSkewErrs.Skippable))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -244,10 +255,12 @@ func EnforceVersionPolicies(flags *applyFlags, versionGetter upgrade.VersionGett
|
|||
func PerformControlPlaneUpgrade(flags *applyFlags, client clientset.Interface, waiter apiclient.Waiter, internalcfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
// Check if the cluster is self-hosted and act accordingly
|
||||
glog.V(1).Infoln("checking if cluster is self-hosted")
|
||||
if upgrade.IsControlPlaneSelfHosted(client) {
|
||||
fmt.Printf("[upgrade/apply] Upgrading your Self-Hosted control plane to version %q...\n", flags.newK8sVersionStr)
|
||||
|
||||
// Upgrade the self-hosted cluster
|
||||
glog.V(1).Infoln("[upgrade/apply] ugrading self-hosted cluster")
|
||||
return upgrade.SelfHostedControlPlane(client, waiter, internalcfg, flags.newK8sVersion)
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"sort"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||
|
@ -55,6 +56,8 @@ func NewCmdPlan(parentFlags *cmdUpgradeFlags) *cobra.Command {
|
|||
// RunPlan takes care of outputting available versions to upgrade to for the user
|
||||
func RunPlan(parentFlags *cmdUpgradeFlags) error {
|
||||
// Start with the basics, verify that the cluster is healthy, build a client and a versionGetter. Never dry-run when planning.
|
||||
glog.V(1).Infof("[upgrade/plan] verifying health of cluster")
|
||||
glog.V(1).Infof("[upgrade/plan] retrieving configuration from cluster")
|
||||
upgradeVars, err := enforceRequirements(parentFlags, false, "")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -64,6 +67,7 @@ func RunPlan(parentFlags *cmdUpgradeFlags) error {
|
|||
etcdCluster := kubeadmutil.LocalEtcdCluster{}
|
||||
|
||||
// Compute which upgrade possibilities there are
|
||||
glog.V(1).Infof("[upgrade/plan] computing upgrade possibilities")
|
||||
availUpgrades, err := upgrade.GetAvailableUpgrades(upgradeVars.versionGetter, parentFlags.allowExperimentalUpgrades, parentFlags.allowRCUpgrades, etcdCluster, upgradeVars.cfg.FeatureGates)
|
||||
if err != nil {
|
||||
return fmt.Errorf("[upgrade/versions] FATAL: %v", err)
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"io"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apimachineryversion "k8s.io/apimachinery/pkg/version"
|
||||
|
@ -53,6 +54,7 @@ func NewCmdVersion(out io.Writer) *cobra.Command {
|
|||
// RunVersion provides the version information of kubeadm in format depending on arguments
|
||||
// specified in cobra.Command.
|
||||
func RunVersion(out io.Writer, cmd *cobra.Command) error {
|
||||
glog.V(1).Infoln("[version] retrieving version info")
|
||||
clientVersion := version.Get()
|
||||
v := Version{
|
||||
ClientVersion: &clientVersion,
|
||||
|
|
|
@ -17,8 +17,10 @@ limitations under the License.
|
|||
package app
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
_ "github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
_ "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/install"
|
||||
|
@ -31,6 +33,9 @@ func Run() error {
|
|||
pflag.CommandLine.MarkHidden("version")
|
||||
pflag.CommandLine.MarkHidden("google-json-key")
|
||||
pflag.CommandLine.MarkHidden("log-flush-frequency")
|
||||
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
|
||||
|
||||
pflag.Set("logtostderr", "true")
|
||||
|
||||
cmd := cmd.NewKubeadmCommand(os.Stdin, os.Stdout, os.Stderr)
|
||||
return cmd.Execute()
|
||||
|
|
|
@ -26,6 +26,7 @@ go_library(
|
|||
deps = [
|
||||
"//cmd/kubeadm/app/util/apiclient:go_default_library",
|
||||
"//pkg/apis/rbac/v1:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/rbac/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
|
@ -19,6 +19,7 @@ package clusterinfo
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/api/core/v1"
|
||||
rbac "k8s.io/api/rbac/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -39,8 +40,9 @@ const (
|
|||
// CreateBootstrapConfigMapIfNotExists creates the kube-public ConfigMap if it doesn't exist already
|
||||
func CreateBootstrapConfigMapIfNotExists(client clientset.Interface, file string) error {
|
||||
|
||||
fmt.Printf("[bootstraptoken] Creating the %q ConfigMap in the %q namespace\n", bootstrapapi.ConfigMapClusterInfo, metav1.NamespacePublic)
|
||||
glog.Infof("[bootstraptoken] creating the %q ConfigMap in the %q namespace\n", bootstrapapi.ConfigMapClusterInfo, metav1.NamespacePublic)
|
||||
|
||||
glog.V(1).Infoln("[bootstraptoken] loading admin kubeconfig")
|
||||
adminConfig, err := clientcmd.LoadFromFile(file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load admin kubeconfig [%v]", err)
|
||||
|
@ -48,6 +50,7 @@ func CreateBootstrapConfigMapIfNotExists(client clientset.Interface, file string
|
|||
|
||||
adminCluster := adminConfig.Contexts[adminConfig.CurrentContext].Cluster
|
||||
// Copy the cluster from admin.conf to the bootstrap kubeconfig, contains the CA cert and the server URL
|
||||
glog.V(1).Infoln("[bootstraptoken] copying the cluster from admin.conf to the bootstrap kubeconfig")
|
||||
bootstrapConfig := &clientcmdapi.Config{
|
||||
Clusters: map[string]*clientcmdapi.Cluster{
|
||||
"": adminConfig.Clusters[adminCluster],
|
||||
|
@ -59,6 +62,7 @@ func CreateBootstrapConfigMapIfNotExists(client clientset.Interface, file string
|
|||
}
|
||||
|
||||
// Create or update the ConfigMap in the kube-public namespace
|
||||
glog.V(1).Infoln("[bootstraptoken] creating/updating ConfigMap in kube-public namespace")
|
||||
return apiclient.CreateOrUpdateConfigMap(client, &v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: bootstrapapi.ConfigMapClusterInfo,
|
||||
|
@ -72,6 +76,7 @@ func CreateBootstrapConfigMapIfNotExists(client clientset.Interface, file string
|
|||
|
||||
// CreateClusterInfoRBACRules creates the RBAC rules for exposing the cluster-info ConfigMap in the kube-public namespace to unauthenticated users
|
||||
func CreateClusterInfoRBACRules(client clientset.Interface) error {
|
||||
glog.V(1).Infoln("creating the RBAC rules for exposing the cluster-info ConfigMap in the kube-public namespace")
|
||||
err := apiclient.CreateOrUpdateRole(client, &rbac.Role{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: BootstrapSignerClusterRoleName,
|
||||
|
|
|
@ -24,6 +24,7 @@ go_library(
|
|||
"//cmd/kubeadm/app/constants:go_default_library",
|
||||
"//cmd/kubeadm/app/util/apiclient:go_default_library",
|
||||
"//cmd/kubeadm/app/util/token:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/rbac/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package node
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/golang/glog"
|
||||
|
||||
rbac "k8s.io/api/rbac/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -47,7 +47,7 @@ const (
|
|||
|
||||
// AllowBootstrapTokensToPostCSRs creates RBAC rules in a way the makes Node Bootstrap Tokens able to post CSRs
|
||||
func AllowBootstrapTokensToPostCSRs(client clientset.Interface) error {
|
||||
fmt.Println("[bootstraptoken] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials")
|
||||
glog.Infoln("[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials")
|
||||
|
||||
return apiclient.CreateOrUpdateClusterRoleBinding(client, &rbac.ClusterRoleBinding{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
@ -69,7 +69,7 @@ func AllowBootstrapTokensToPostCSRs(client clientset.Interface) error {
|
|||
|
||||
// AutoApproveNodeBootstrapTokens creates RBAC rules in a way that makes Node Bootstrap Tokens' CSR auto-approved by the csrapprover controller
|
||||
func AutoApproveNodeBootstrapTokens(client clientset.Interface) error {
|
||||
fmt.Println("[bootstraptoken] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token")
|
||||
glog.Infoln("[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token")
|
||||
|
||||
// Always create this kubeadm-specific binding though
|
||||
return apiclient.CreateOrUpdateClusterRoleBinding(client, &rbac.ClusterRoleBinding{
|
||||
|
@ -92,7 +92,7 @@ func AutoApproveNodeBootstrapTokens(client clientset.Interface) error {
|
|||
|
||||
// AutoApproveNodeCertificateRotation creates RBAC rules in a way that makes Node certificate rotation CSR auto-approved by the csrapprover controller
|
||||
func AutoApproveNodeCertificateRotation(client clientset.Interface) error {
|
||||
fmt.Println("[bootstraptoken] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster")
|
||||
glog.Infoln("[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster")
|
||||
|
||||
return apiclient.CreateOrUpdateClusterRoleBinding(client, &rbac.ClusterRoleBinding{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
|
@ -30,6 +30,7 @@ go_library(
|
|||
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
|
||||
"//cmd/kubeadm/app/constants:go_default_library",
|
||||
"//cmd/kubeadm/app/phases/certs/pkiutil:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/cert:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -23,6 +23,8 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
certutil "k8s.io/client-go/util/cert"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
|
@ -32,7 +34,7 @@ import (
|
|||
// CreatePKIAssets will create and write to disk all PKI assets necessary to establish the control plane.
|
||||
// If the PKI assets already exists in the target folder, they are used only if evaluated equal; otherwise an error is returned.
|
||||
func CreatePKIAssets(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating PKI assets")
|
||||
certActions := []func(cfg *kubeadmapi.MasterConfiguration) error{
|
||||
CreateCACertAndKeyFiles,
|
||||
CreateAPIServerCertAndKeyFiles,
|
||||
|
@ -54,7 +56,7 @@ func CreatePKIAssets(cfg *kubeadmapi.MasterConfiguration) error {
|
|||
}
|
||||
}
|
||||
|
||||
fmt.Printf("[certificates] Valid certificates and keys now exist in %q\n", cfg.CertificatesDir)
|
||||
glog.Infof("[certificates] valid certificates and keys now exist in %q\n", cfg.CertificatesDir)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -62,7 +64,7 @@ func CreatePKIAssets(cfg *kubeadmapi.MasterConfiguration) error {
|
|||
// CreateCACertAndKeyFiles create a new self signed cluster CA certificate and key files.
|
||||
// If the CA certificate and key files already exists in the target folder, they are used only if evaluated equal; otherwise an error is returned.
|
||||
func CreateCACertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("create a new self signed cluster CA certificate and key files")
|
||||
caCert, caKey, err := NewCACertAndKey()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -80,7 +82,7 @@ func CreateCACertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
|||
// If the apiserver certificate and key files already exists in the target folder, they are used only if evaluated equal; otherwise an error is returned.
|
||||
// It assumes the cluster CA certificate and key files exist in the CertificatesDir.
|
||||
func CreateAPIServerCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a new certificate and key files for the apiserver")
|
||||
caCert, caKey, err := loadCertificateAuthority(cfg.CertificatesDir, kubeadmconstants.CACertAndKeyBaseName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -104,7 +106,7 @@ func CreateAPIServerCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
|||
// If the apiserver-kubelet-client certificate and key files already exists in the target folder, they are used only if evaluated equals; otherwise an error is returned.
|
||||
// It assumes the cluster CA certificate and key files exist in the CertificatesDir.
|
||||
func CreateAPIServerKubeletClientCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a new certificate for kubelets calling apiserver")
|
||||
caCert, caKey, err := loadCertificateAuthority(cfg.CertificatesDir, kubeadmconstants.CACertAndKeyBaseName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -129,7 +131,7 @@ func CreateAPIServerKubeletClientCertAndKeyFiles(cfg *kubeadmapi.MasterConfigura
|
|||
// This is a separate CA, so that kubernetes client identities cannot connect to etcd directly or peer with the etcd cluster.
|
||||
// If the etcd CA certificate and key files already exists in the target folder, they are used only if evaluated equals; otherwise an error is returned.
|
||||
func CreateEtcdCACertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a self signed etcd CA certificate and key files")
|
||||
etcdCACert, etcdCAKey, err := NewEtcdCACertAndKey()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -147,7 +149,7 @@ func CreateEtcdCACertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
|||
// If the etcd serving certificate and key file already exist in the target folder, they are used only if evaluated equal; otherwise an error is returned.
|
||||
// It assumes the etcd CA certificate and key file exist in the CertificatesDir
|
||||
func CreateEtcdServerCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a new server certificate and key files for etcd")
|
||||
etcdCACert, etcdCAKey, err := loadCertificateAuthority(cfg.CertificatesDir, kubeadmconstants.EtcdCACertAndKeyBaseName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -171,7 +173,7 @@ func CreateEtcdServerCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error
|
|||
// If the etcd peer certificate and key file already exist in the target folder, they are used only if evaluated equal; otherwise an error is returned.
|
||||
// It assumes the etcd CA certificate and key file exist in the CertificatesDir
|
||||
func CreateEtcdPeerCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a new certificate and key files for etcd peering")
|
||||
etcdCACert, etcdCAKey, err := loadCertificateAuthority(cfg.CertificatesDir, kubeadmconstants.EtcdCACertAndKeyBaseName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -219,7 +221,7 @@ func CreateEtcdHealthcheckClientCertAndKeyFiles(cfg *kubeadmapi.MasterConfigurat
|
|||
// If the apiserver-etcd-client certificate and key file already exist in the target folder, they are used only if evaluated equal; otherwise an error is returned.
|
||||
// It assumes the etcd CA certificate and key file exist in the CertificatesDir
|
||||
func CreateAPIServerEtcdClientCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a new client certificate for the apiserver calling etcd")
|
||||
etcdCACert, etcdCAKey, err := loadCertificateAuthority(cfg.CertificatesDir, kubeadmconstants.EtcdCACertAndKeyBaseName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -242,7 +244,7 @@ func CreateAPIServerEtcdClientCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguratio
|
|||
// CreateServiceAccountKeyAndPublicKeyFiles create a new public/private key files for signing service account users.
|
||||
// If the sa public/private key files already exists in the target folder, they are used only if evaluated equals; otherwise an error is returned.
|
||||
func CreateServiceAccountKeyAndPublicKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a new public/private key files for signing service account users")
|
||||
saSigningKey, err := NewServiceAccountSigningKey()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -261,7 +263,7 @@ func CreateServiceAccountKeyAndPublicKeyFiles(cfg *kubeadmapi.MasterConfiguratio
|
|||
// as front proxies.
|
||||
// If the front proxy CA certificate and key files already exists in the target folder, they are used only if evaluated equals; otherwise an error is returned.
|
||||
func CreateFrontProxyCACertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a self signed front proxy CA certificate and key files")
|
||||
frontProxyCACert, frontProxyCAKey, err := NewFrontProxyCACertAndKey()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -279,7 +281,7 @@ func CreateFrontProxyCACertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) erro
|
|||
// If the front-proxy-client certificate and key files already exists in the target folder, they are used only if evaluated equals; otherwise an error is returned.
|
||||
// It assumes the front proxy CA certificate and key files exist in the CertificatesDir.
|
||||
func CreateFrontProxyClientCertAndKeyFiles(cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating a new certificate for proxy server client")
|
||||
frontProxyCACert, frontProxyCAKey, err := loadCertificateAuthority(cfg.CertificatesDir, kubeadmconstants.FrontProxyCACertAndKeyBaseName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -46,6 +46,7 @@ go_library(
|
|||
"//pkg/master/reconcilers:go_default_library",
|
||||
"//pkg/util/pointer:go_default_library",
|
||||
"//pkg/util/version:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
],
|
||||
|
|
|
@ -24,6 +24,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
|
@ -50,21 +52,25 @@ const (
|
|||
|
||||
// CreateInitStaticPodManifestFiles will write all static pod manifest files needed to bring up the control plane.
|
||||
func CreateInitStaticPodManifestFiles(manifestDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("[controlplane] creating static pod files")
|
||||
return createStaticPodFiles(manifestDir, cfg, kubeadmconstants.KubeAPIServer, kubeadmconstants.KubeControllerManager, kubeadmconstants.KubeScheduler)
|
||||
}
|
||||
|
||||
// CreateAPIServerStaticPodManifestFile will write APIserver static pod manifest file.
|
||||
func CreateAPIServerStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("creating APIserver static pod files")
|
||||
return createStaticPodFiles(manifestDir, cfg, kubeadmconstants.KubeAPIServer)
|
||||
}
|
||||
|
||||
// CreateControllerManagerStaticPodManifestFile will write controller manager static pod manifest file.
|
||||
func CreateControllerManagerStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("creating controller manager static pod files")
|
||||
return createStaticPodFiles(manifestDir, cfg, kubeadmconstants.KubeControllerManager)
|
||||
}
|
||||
|
||||
// CreateSchedulerStaticPodManifestFile will write scheduler static pod manifest file.
|
||||
func CreateSchedulerStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("creating scheduler static pod files")
|
||||
return createStaticPodFiles(manifestDir, cfg, kubeadmconstants.KubeScheduler)
|
||||
}
|
||||
|
||||
|
@ -132,6 +138,7 @@ func createStaticPodFiles(manifestDir string, cfg *kubeadmapi.MasterConfiguratio
|
|||
}
|
||||
|
||||
// gets the StaticPodSpecs, actualized for the current MasterConfiguration
|
||||
glog.V(1).Infoln("[controlplane] getting StaticPodSpecs")
|
||||
specs := GetStaticPodSpecs(cfg, k8sVersion)
|
||||
|
||||
// creates required static pod specs
|
||||
|
@ -147,7 +154,7 @@ func createStaticPodFiles(manifestDir string, cfg *kubeadmapi.MasterConfiguratio
|
|||
return fmt.Errorf("failed to create static pod manifest file for %q: %v", componentName, err)
|
||||
}
|
||||
|
||||
fmt.Printf("[controlplane] Wrote Static Pod manifest for component %s to %q\n", componentName, kubeadmconstants.GetStaticPodFilepath(componentName, manifestDir))
|
||||
glog.Infof("[controlplane] wrote Static Pod manifest for component %s to %q\n", componentName, kubeadmconstants.GetStaticPodFilepath(componentName, manifestDir))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -213,13 +220,13 @@ func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration, k8sVersion *versio
|
|||
|
||||
// Warn for unused user supplied variables
|
||||
if cfg.Etcd.CAFile != "" {
|
||||
fmt.Printf("[controlplane] WARNING: Configuration for %s CAFile, %s, is unused without providing Endpoints for external %s\n", kubeadmconstants.Etcd, cfg.Etcd.CAFile, kubeadmconstants.Etcd)
|
||||
glog.Warningf("[controlplane] configuration for %s CAFile, %s, is unused without providing Endpoints for external %s\n", kubeadmconstants.Etcd, cfg.Etcd.CAFile, kubeadmconstants.Etcd)
|
||||
}
|
||||
if cfg.Etcd.CertFile != "" {
|
||||
fmt.Printf("[controlplane] WARNING: Configuration for %s CertFile, %s, is unused without providing Endpoints for external %s\n", kubeadmconstants.Etcd, cfg.Etcd.CertFile, kubeadmconstants.Etcd)
|
||||
glog.Warningf("[controlplane] configuration for %s CertFile, %s, is unused without providing Endpoints for external %s\n", kubeadmconstants.Etcd, cfg.Etcd.CertFile, kubeadmconstants.Etcd)
|
||||
}
|
||||
if cfg.Etcd.KeyFile != "" {
|
||||
fmt.Printf("[controlplane] WARNING: Configuration for %s KeyFile, %s, is unused without providing Endpoints for external %s\n", kubeadmconstants.Etcd, cfg.Etcd.KeyFile, kubeadmconstants.Etcd)
|
||||
glog.Warningf("[controlplane] configuration for %s KeyFile, %s, is unused without providing Endpoints for external %s\n", kubeadmconstants.Etcd, cfg.Etcd.KeyFile, kubeadmconstants.Etcd)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ go_library(
|
|||
"//cmd/kubeadm/app/images:go_default_library",
|
||||
"//cmd/kubeadm/app/util:go_default_library",
|
||||
"//cmd/kubeadm/app/util/staticpod:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -20,6 +20,8 @@ import (
|
|||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
|
@ -35,7 +37,7 @@ const (
|
|||
|
||||
// CreateLocalEtcdStaticPodManifestFile will write local etcd static pod manifest file.
|
||||
func CreateLocalEtcdStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
|
||||
glog.V(1).Infoln("creating local etcd static pod manifest file")
|
||||
// gets etcd StaticPodSpec, actualized for the current MasterConfiguration
|
||||
spec := GetEtcdPodSpec(cfg)
|
||||
// writes etcd StaticPod to disk
|
||||
|
|
|
@ -19,6 +19,7 @@ go_library(
|
|||
"//cmd/kubeadm/app/phases/certs/pkiutil:go_default_library",
|
||||
"//cmd/kubeadm/app/util:go_default_library",
|
||||
"//cmd/kubeadm/app/util/kubeconfig:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/clientcmd/api:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/cert:go_default_library",
|
||||
|
|
|
@ -26,6 +26,8 @@ import (
|
|||
|
||||
"crypto/rsa"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||
certutil "k8s.io/client-go/util/cert"
|
||||
|
@ -60,6 +62,7 @@ type kubeConfigSpec struct {
|
|||
// to establish the control plane, including also the admin kubeconfig file.
|
||||
// If kubeconfig files already exists, they are used only if evaluated equal; otherwise an error is returned.
|
||||
func CreateInitKubeConfigFiles(outDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("creating all kubeconfig files")
|
||||
return createKubeConfigFiles(
|
||||
outDir,
|
||||
cfg,
|
||||
|
@ -73,24 +76,28 @@ func CreateInitKubeConfigFiles(outDir string, cfg *kubeadmapi.MasterConfiguratio
|
|||
// CreateAdminKubeConfigFile create a kubeconfig file for the admin to use and for kubeadm itself.
|
||||
// If the kubeconfig file already exists, it is used only if evaluated equal; otherwise an error is returned.
|
||||
func CreateAdminKubeConfigFile(outDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("create a kubeconfig file for the admin and for kubeadm itself")
|
||||
return createKubeConfigFiles(outDir, cfg, kubeadmconstants.AdminKubeConfigFileName)
|
||||
}
|
||||
|
||||
// CreateKubeletKubeConfigFile create a kubeconfig file for the Kubelet to use.
|
||||
// If the kubeconfig file already exists, it is used only if evaluated equal; otherwise an error is returned.
|
||||
func CreateKubeletKubeConfigFile(outDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("creating a kubeconfig file for the Kubelet")
|
||||
return createKubeConfigFiles(outDir, cfg, kubeadmconstants.KubeletKubeConfigFileName)
|
||||
}
|
||||
|
||||
// CreateControllerManagerKubeConfigFile create a kubeconfig file for the ControllerManager to use.
|
||||
// If the kubeconfig file already exists, it is used only if evaluated equal; otherwise an error is returned.
|
||||
func CreateControllerManagerKubeConfigFile(outDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("creating kubeconfig file for the ControllerManager")
|
||||
return createKubeConfigFiles(outDir, cfg, kubeadmconstants.ControllerManagerKubeConfigFileName)
|
||||
}
|
||||
|
||||
// CreateSchedulerKubeConfigFile create a create a kubeconfig file for the Scheduler to use.
|
||||
// If the kubeconfig file already exists, it is used only if evaluated equal; otherwise an error is returned.
|
||||
func CreateSchedulerKubeConfigFile(outDir string, cfg *kubeadmapi.MasterConfiguration) error {
|
||||
glog.V(1).Infoln("creating kubeconfig file for Scheduler")
|
||||
return createKubeConfigFiles(outDir, cfg, kubeadmconstants.SchedulerKubeConfigFileName)
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ go_library(
|
|||
deps = [
|
||||
"//cmd/kubeadm/app/constants:go_default_library",
|
||||
"//pkg/kubelet/apis:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
|
@ -20,6 +20,8 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
apierrs "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -35,9 +37,9 @@ import (
|
|||
func MarkMaster(client clientset.Interface, masterName string, taint bool) error {
|
||||
|
||||
if taint {
|
||||
fmt.Printf("[markmaster] Will mark node %s as master by adding a label and a taint\n", masterName)
|
||||
glog.Infof("[markmaster] will mark node %s as master by adding a label and a taint\n", masterName)
|
||||
} else {
|
||||
fmt.Printf("[markmaster] Will mark node %s as master by adding a label\n", masterName)
|
||||
glog.Infof("[markmaster] will mark node %s as master by adding a label\n", masterName)
|
||||
}
|
||||
|
||||
// Loop on every falsy return. Return with an error if raised. Exit successfully if true is returned.
|
||||
|
|
|
@ -38,6 +38,7 @@ go_library(
|
|||
"//cmd/kubeadm/app/util:go_default_library",
|
||||
"//cmd/kubeadm/app/util/apiclient:go_default_library",
|
||||
"//pkg/volume/util:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
|
@ -21,6 +21,8 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
apps "k8s.io/api/apps/v1"
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -53,11 +55,12 @@ const (
|
|||
// Otherwise, there is a race condition when we proceed without kubelet having restarted the API server correctly and the next .Create call flakes
|
||||
// 9. Do that for the kube-apiserver, kube-controller-manager and kube-scheduler in a loop
|
||||
func CreateSelfHostedControlPlane(manifestsDir, kubeConfigDir string, cfg *kubeadmapi.MasterConfiguration, client clientset.Interface, waiter apiclient.Waiter, dryRun bool) error {
|
||||
|
||||
glog.V(1).Infoln("creating self hosted control plane")
|
||||
// Adjust the timeout slightly to something self-hosting specific
|
||||
waiter.SetTimeout(selfHostingWaitTimeout)
|
||||
|
||||
// Here the map of different mutators to use for the control plane's PodSpec is stored
|
||||
glog.V(1).Infoln("getting mutators")
|
||||
mutators := GetMutatorsFromFeatureGates(cfg.FeatureGates)
|
||||
|
||||
// Some extra work to be done if we should store the control plane certificates in Secrets
|
||||
|
@ -124,7 +127,7 @@ func CreateSelfHostedControlPlane(manifestsDir, kubeConfigDir string, cfg *kubea
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("[self-hosted] self-hosted %s ready after %f seconds\n", componentName, time.Since(start).Seconds())
|
||||
glog.Infof("[self-hosted] self-hosted %s ready after %f seconds\n", componentName, time.Since(start).Seconds())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ go_library(
|
|||
"//cmd/kubeadm/app/util/apiclient:go_default_library",
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
|
|
|
@ -17,9 +17,8 @@ limitations under the License.
|
|||
package uploadconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -34,7 +33,7 @@ import (
|
|||
// UploadConfiguration saves the MasterConfiguration used for later reference (when upgrading for instance)
|
||||
func UploadConfiguration(cfg *kubeadmapi.MasterConfiguration, client clientset.Interface) error {
|
||||
|
||||
fmt.Printf("[uploadconfig] Storing the configuration used in ConfigMap %q in the %q Namespace\n", kubeadmconstants.MasterConfigurationConfigMap, metav1.NamespaceSystem)
|
||||
glog.Infof("[uploadconfig] storing the configuration used in ConfigMap %q in the %q Namespace\n", kubeadmconstants.MasterConfigurationConfigMap, metav1.NamespaceSystem)
|
||||
|
||||
// Convert cfg to the external version as that's the only version of the API that can be deserialized later
|
||||
externalcfg := &kubeadmapiext.MasterConfiguration{}
|
||||
|
|
|
@ -63,6 +63,7 @@ go_library(
|
|||
"//test/e2e_node/system:go_default_library",
|
||||
"//vendor/github.com/PuerkitoBio/purell:go_default_library",
|
||||
"//vendor/github.com/blang/semver:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
|
|
|
@ -37,6 +37,7 @@ import (
|
|||
|
||||
"github.com/PuerkitoBio/purell"
|
||||
"github.com/blang/semver"
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"net/url"
|
||||
|
@ -99,6 +100,7 @@ func (CRICheck) Name() string {
|
|||
|
||||
// Check validates the container runtime through the CRI.
|
||||
func (criCheck CRICheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infoln("validating the container runtime through the CRI")
|
||||
crictlPath, err := criCheck.exec.LookPath("crictl")
|
||||
if err != nil {
|
||||
errors = append(errors, fmt.Errorf("unable to find command crictl: %s", err))
|
||||
|
@ -130,6 +132,7 @@ func (sc ServiceCheck) Name() string {
|
|||
|
||||
// Check validates if the service is enabled and active.
|
||||
func (sc ServiceCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infoln("validating if the service is enabled and active")
|
||||
initSystem, err := initsystem.GetInitSystem()
|
||||
if err != nil {
|
||||
return []error{err}, nil
|
||||
|
@ -170,6 +173,7 @@ func (FirewalldCheck) Name() string {
|
|||
|
||||
// Check validates if the firewall is enabled and active.
|
||||
func (fc FirewalldCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infoln("validating if the firewall is enabled and active")
|
||||
initSystem, err := initsystem.GetInitSystem()
|
||||
if err != nil {
|
||||
return []error{err}, nil
|
||||
|
@ -206,6 +210,7 @@ func (poc PortOpenCheck) Name() string {
|
|||
|
||||
// Check validates if the particular port is available.
|
||||
func (poc PortOpenCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infof("validating availability of port %d", poc.port)
|
||||
errors = []error{}
|
||||
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", poc.port))
|
||||
if err != nil {
|
||||
|
@ -242,6 +247,7 @@ func (dac DirAvailableCheck) Name() string {
|
|||
|
||||
// Check validates if a directory does not exist or empty.
|
||||
func (dac DirAvailableCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infof("validating the existence and emptiness of directory %s", dac.Path)
|
||||
errors = []error{}
|
||||
// If it doesn't exist we are good:
|
||||
if _, err := os.Stat(dac.Path); os.IsNotExist(err) {
|
||||
|
@ -279,6 +285,7 @@ func (fac FileAvailableCheck) Name() string {
|
|||
|
||||
// Check validates if the given file does not already exist.
|
||||
func (fac FileAvailableCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infof("validating the existence of file %s", fac.Path)
|
||||
errors = []error{}
|
||||
if _, err := os.Stat(fac.Path); err == nil {
|
||||
errors = append(errors, fmt.Errorf("%s already exists", fac.Path))
|
||||
|
@ -302,6 +309,7 @@ func (fac FileExistingCheck) Name() string {
|
|||
|
||||
// Check validates if the given file already exists.
|
||||
func (fac FileExistingCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infof("validating the existence of file %s", fac.Path)
|
||||
errors = []error{}
|
||||
if _, err := os.Stat(fac.Path); err != nil {
|
||||
errors = append(errors, fmt.Errorf("%s doesn't exist", fac.Path))
|
||||
|
@ -326,6 +334,7 @@ func (fcc FileContentCheck) Name() string {
|
|||
|
||||
// Check validates if the given file contains the given content.
|
||||
func (fcc FileContentCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infof("validating the contents of file %s", fcc.Path)
|
||||
f, err := os.Open(fcc.Path)
|
||||
if err != nil {
|
||||
return nil, []error{fmt.Errorf("%s does not exist", fcc.Path)}
|
||||
|
@ -366,6 +375,7 @@ func (ipc InPathCheck) Name() string {
|
|||
|
||||
// Check validates if the given executable is present in the path.
|
||||
func (ipc InPathCheck) Check() (warnings, errs []error) {
|
||||
glog.V(1).Infof("validating the presence of executable %s", ipc.executable)
|
||||
_, err := ipc.exec.LookPath(ipc.executable)
|
||||
if err != nil {
|
||||
if ipc.mandatory {
|
||||
|
@ -395,6 +405,7 @@ func (HostnameCheck) Name() string {
|
|||
|
||||
// Check validates if hostname match dns sub domain regex.
|
||||
func (hc HostnameCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infof("validating if hostname match dns sub domain")
|
||||
errors = []error{}
|
||||
warnings = []error{}
|
||||
for _, msg := range validation.ValidateNodeName(hc.nodeName, false) {
|
||||
|
@ -424,7 +435,7 @@ func (hst HTTPProxyCheck) Name() string {
|
|||
|
||||
// Check validates http connectivity type, direct or via proxy.
|
||||
func (hst HTTPProxyCheck) Check() (warnings, errors []error) {
|
||||
|
||||
glog.V(1).Infof("validating if the connectivity type is via proxy or direct")
|
||||
u := (&url.URL{Scheme: hst.Proto, Host: hst.Host}).String()
|
||||
|
||||
req, err := http.NewRequest("GET", u, nil)
|
||||
|
@ -460,7 +471,7 @@ func (HTTPProxyCIDRCheck) Name() string {
|
|||
// Check validates http connectivity to first IP address in the CIDR.
|
||||
// If it is not directly connected and goes via proxy it will produce warning.
|
||||
func (subnet HTTPProxyCIDRCheck) Check() (warnings, errors []error) {
|
||||
|
||||
glog.V(1).Infoln("validating http connectivity to first IP address in the CIDR")
|
||||
if len(subnet.CIDR) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -511,6 +522,7 @@ func (ExtraArgsCheck) Name() string {
|
|||
|
||||
// Check validates additional arguments of the control plane components.
|
||||
func (eac ExtraArgsCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infoln("validating additional arguments of the control plane components")
|
||||
argsCheck := func(name string, args map[string]string, f *pflag.FlagSet) []error {
|
||||
errs := []error{}
|
||||
for k, v := range args {
|
||||
|
@ -558,6 +570,7 @@ func (SystemVerificationCheck) Name() string {
|
|||
|
||||
// Check runs all individual checks
|
||||
func (sysver SystemVerificationCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infoln("running all checks")
|
||||
// Create a buffered writer and choose a quite large value (1M) and suppose the output from the system verification test won't exceed the limit
|
||||
// Run the system verification check, but write to out buffered writer instead of stdout
|
||||
bufw := bufio.NewWriterSize(os.Stdout, 1*1024*1024)
|
||||
|
@ -615,7 +628,7 @@ func (KubernetesVersionCheck) Name() string {
|
|||
|
||||
// Check validates kubernetes and kubeadm versions
|
||||
func (kubever KubernetesVersionCheck) Check() (warnings, errors []error) {
|
||||
|
||||
glog.V(1).Infoln("validating kubernetes and kubeadm version")
|
||||
// Skip this check for "super-custom builds", where apimachinery/the overall codebase version is not set.
|
||||
if strings.HasPrefix(kubever.KubeadmVersion, "v0.0.0") {
|
||||
return nil, nil
|
||||
|
@ -656,6 +669,7 @@ func (KubeletVersionCheck) Name() string {
|
|||
|
||||
// Check validates kubelet version. It should be not less than minimal supported version
|
||||
func (kubever KubeletVersionCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infoln("validating kubelet version")
|
||||
kubeletVersion, err := GetKubeletVersion(kubever.exec)
|
||||
if err != nil {
|
||||
return nil, []error{fmt.Errorf("couldn't get kubelet version: %v", err)}
|
||||
|
@ -686,6 +700,7 @@ func (SwapCheck) Name() string {
|
|||
|
||||
// Check validates whether swap is enabled or not
|
||||
func (swc SwapCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infoln("validating whether swap is enabled or not")
|
||||
f, err := os.Open("/proc/swaps")
|
||||
if err != nil {
|
||||
// /proc/swaps not available, thus no reasons to warn
|
||||
|
@ -725,6 +740,7 @@ func (ExternalEtcdVersionCheck) Name() string {
|
|||
|
||||
// Check validates external etcd version
|
||||
func (evc ExternalEtcdVersionCheck) Check() (warnings, errors []error) {
|
||||
glog.V(1).Infoln("validating the external etcd version")
|
||||
var config *tls.Config
|
||||
var err error
|
||||
if config, err = evc.configRootCAs(config); err != nil {
|
||||
|
@ -858,6 +874,7 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfi
|
|||
}
|
||||
|
||||
// check if we can use crictl to perform checks via the CRI
|
||||
glog.V(1).Infoln("checking if we can use crictl to perform checks via the CRI")
|
||||
criCtlChecker := InPathCheck{
|
||||
executable: "crictl",
|
||||
mandatory: false,
|
||||
|
@ -1079,13 +1096,13 @@ func TryStartKubelet(ignorePreflightErrors sets.String) {
|
|||
// If we notice that the kubelet service is inactive, try to start it
|
||||
initSystem, err := initsystem.GetInitSystem()
|
||||
if err != nil {
|
||||
fmt.Println("[preflight] No supported init system detected, won't ensure kubelet is running.")
|
||||
glog.Infoln("[preflight] no supported init system detected, won't ensure kubelet is running.")
|
||||
} else if initSystem.ServiceExists("kubelet") && !initSystem.ServiceIsActive("kubelet") {
|
||||
|
||||
fmt.Println("[preflight] Starting the kubelet service")
|
||||
glog.Infoln("[preflight] starting the kubelet service")
|
||||
if err := initSystem.ServiceStart("kubelet"); err != nil {
|
||||
fmt.Printf("[preflight] WARNING: Unable to start the kubelet service: [%v]\n", err)
|
||||
fmt.Println("[preflight] WARNING: Please ensure kubelet is running manually.")
|
||||
glog.Warningf("[preflight] unable to start the kubelet service: [%v]\n", err)
|
||||
glog.Warningf("[preflight] please ensure kubelet is running manually.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ go_library(
|
|||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/util/node:go_default_library",
|
||||
"//pkg/util/version:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
||||
],
|
||||
|
|
|
@ -21,6 +21,8 @@ import (
|
|||
"io/ioutil"
|
||||
"net"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
netutil "k8s.io/apimachinery/pkg/util/net"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
|
@ -91,10 +93,12 @@ func TryLoadMasterConfiguration(cfgPath string, cfg *kubeadmapiext.MasterConfigu
|
|||
// Right thereafter, the configuration is defaulted again with dynamic values (like IP addresses of a machine, etc)
|
||||
// Lastly, the internal config is validated and returned.
|
||||
func ConfigFileAndDefaultsToInternalConfig(cfgPath string, defaultversionedcfg *kubeadmapiext.MasterConfiguration) (*kubeadmapi.MasterConfiguration, error) {
|
||||
glog.V(1).Infoln("configuring files and defaults to internal config")
|
||||
internalcfg := &kubeadmapi.MasterConfiguration{}
|
||||
|
||||
// Loads configuration from config file, if provided
|
||||
// Nb. --config overrides command line flags
|
||||
glog.V(1).Infoln("attempting to load configuration from config file")
|
||||
if err := TryLoadMasterConfiguration(cfgPath, defaultversionedcfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue