Skip to content

Commit

Permalink
Add no-init option to the install command (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmudrii authored Apr 15, 2020
1 parent 870b0fd commit 38f6ff4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type installOptions struct {
globalOptions
Manifest string
BackupFile string
NoInit bool
}

// installCmd setups install command
Expand Down Expand Up @@ -72,6 +73,7 @@ It's possible to source information about hosts from Terraform output, using the
}

cmd.Flags().StringVarP(&iopts.BackupFile, "backup", "b", "", "path to where the PKI backup .tar.gz file should be placed (default: location of cluster config file)")
cmd.Flags().BoolVarP(&iopts.NoInit, "no-init", "", false, "don't initialize the cluster (only install binaries)")

return cmd
}
Expand Down Expand Up @@ -125,6 +127,7 @@ func createInstallerOptions(clusterFile string, cluster *kubeoneapi.KubeOneClust
Manifest: options.Manifest,
CredentialsFile: options.CredentialsFilePath,
BackupFile: options.BackupFile,
NoInit: options.NoInit,
Verbose: options.Verbose,
}, nil
}
10 changes: 9 additions & 1 deletion pkg/installer/installation/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ import (
// Install performs all the steps required to install Kubernetes on
// an empty, pristine machine.
func Install(s *state.State) error {
initTask := &task.Task{Fn: installPrerequisites, ErrMsg: "failed to install prerequisites"}
if err := initTask.Run(s); err != nil {
return errors.Wrap(err, initTask.ErrMsg)
}
if s.NoInit {
s.Logger.Infoln("Skipping cluster provisioning because --no-init flag was provided.")
return nil
}

installSteps := []task.Task{
{Fn: installPrerequisites, ErrMsg: "failed to install prerequisites"},
{Fn: generateKubeadm, ErrMsg: "failed to generate kubeadm config files"},
{Fn: kubeadmCertsOnLeader, ErrMsg: "failed to provision certs and etcd on leader", Retries: 3},
{Fn: certificate.DownloadCA, ErrMsg: "unable to download ca from leader", Retries: 3},
Expand Down
2 changes: 2 additions & 0 deletions pkg/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Options struct {
Manifest string
CredentialsFile string
BackupFile string
NoInit bool
DestroyWorkers bool
RemoveBinaries bool
}
Expand Down Expand Up @@ -91,6 +92,7 @@ func (i *Installer) createState(options *Options) (*state.State, error) {
s.ManifestFilePath = options.Manifest
s.CredentialsFilePath = options.CredentialsFile
s.BackupFile = options.BackupFile
s.NoInit = options.NoInit
s.DestroyWorkers = options.DestroyWorkers
s.RemoveBinaries = options.RemoveBinaries
return s, nil
Expand Down
1 change: 1 addition & 0 deletions pkg/state/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type State struct {
DynamicClient dynclient.Client
Verbose bool
BackupFile string
NoInit bool
DestroyWorkers bool
RemoveBinaries bool
ForceUpgrade bool
Expand Down

0 comments on commit 38f6ff4

Please sign in to comment.