change `skip-install-packages` to `with-packages`

Signed-off-by: 24sama <leo@kubesphere.io>
This commit is contained in:
24sama 2022-01-24 17:25:41 +08:00
parent ffd7b4640b
commit 5cd9ed8705
8 changed files with 88 additions and 78 deletions

View File

@ -25,13 +25,13 @@ import (
)
type AddNodesOptions struct {
CommonOptions *options.CommonOptions
ClusterCfgFile string
SkipPullImages bool
ContainerManager string
DownloadCmd string
Artifact string
SkipInstallPackages bool
CommonOptions *options.CommonOptions
ClusterCfgFile string
SkipPullImages bool
ContainerManager string
DownloadCmd string
Artifact string
InstallPackages bool
}
func NewAddNodesOptions() *AddNodesOptions {
@ -59,23 +59,23 @@ func NewCmdAddNodes() *cobra.Command {
func (o *AddNodesOptions) Complete(_ *cobra.Command, _ []string) error {
if o.Artifact == "" {
o.SkipInstallPackages = false
o.InstallPackages = false
}
return nil
}
func (o *AddNodesOptions) Run() error {
arg := common.Argument{
FilePath: o.ClusterCfgFile,
KsEnable: false,
Debug: o.CommonOptions.Verbose,
IgnoreErr: o.CommonOptions.IgnoreErr,
SkipConfirmCheck: o.CommonOptions.SkipConfirmCheck,
SkipPullImages: o.SkipPullImages,
InCluster: o.CommonOptions.InCluster,
ContainerManager: o.ContainerManager,
Artifact: o.Artifact,
SkipInstallPackages: o.SkipInstallPackages,
FilePath: o.ClusterCfgFile,
KsEnable: false,
Debug: o.CommonOptions.Verbose,
IgnoreErr: o.CommonOptions.IgnoreErr,
SkipConfirmCheck: o.CommonOptions.SkipConfirmCheck,
SkipPullImages: o.SkipPullImages,
InCluster: o.CommonOptions.InCluster,
ContainerManager: o.ContainerManager,
Artifact: o.Artifact,
InstallPackages: o.InstallPackages,
}
return pipelines.AddNodes(arg, o.DownloadCmd)
}
@ -87,5 +87,5 @@ func (o *AddNodesOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&o.DownloadCmd, "download-cmd", "", "curl -L -o %s %s",
`The user defined command to download the necessary binary files. The first param '%s' is output path, the second param '%s', is the URL`)
cmd.Flags().StringVarP(&o.Artifact, "artifact", "a", "", "Path to a KubeKey artifact")
cmd.Flags().BoolVarP(&o.SkipInstallPackages, "skip-install-packages", "", false, "Skip install packages by artifact")
cmd.Flags().BoolVarP(&o.InstallPackages, "with-packages", "", false, "install operation system packages by artifact")
}

View File

@ -31,18 +31,18 @@ import (
type CreateClusterOptions struct {
CommonOptions *options.CommonOptions
ClusterCfgFile string
Kubernetes string
EnableKubeSphere bool
KubeSphere string
LocalStorage bool
SkipPullImages bool
SkipPushImages bool
ContainerManager string
DownloadCmd string
Artifact string
SkipInstallPackages bool
CertificatesDir string
ClusterCfgFile string
Kubernetes string
EnableKubeSphere bool
KubeSphere string
LocalStorage bool
SkipPullImages bool
SkipPushImages bool
ContainerManager string
DownloadCmd string
Artifact string
InstallPackages bool
CertificatesDir string
}
func NewCreateClusterOptions() *CreateClusterOptions {
@ -72,7 +72,7 @@ func NewCmdCreateCluster() *cobra.Command {
return cmd
}
func (o *CreateClusterOptions) Complete(cmd *cobra.Command, args []string) error {
func (o *CreateClusterOptions) Complete(_ *cobra.Command, args []string) error {
var ksVersion string
if o.EnableKubeSphere && len(args) > 0 {
ksVersion = args[0]
@ -82,13 +82,13 @@ func (o *CreateClusterOptions) Complete(cmd *cobra.Command, args []string) error
o.KubeSphere = ksVersion
if o.Artifact == "" {
o.SkipInstallPackages = false
o.InstallPackages = false
o.SkipPushImages = false
}
return nil
}
func (o *CreateClusterOptions) Validate(cmd *cobra.Command, args []string) error {
func (o *CreateClusterOptions) Validate(_ *cobra.Command, _ []string) error {
switch o.ContainerManager {
case common.Docker, common.Conatinerd, common.Crio, common.Isula:
default:
@ -99,21 +99,21 @@ func (o *CreateClusterOptions) Validate(cmd *cobra.Command, args []string) error
func (o *CreateClusterOptions) Run() error {
arg := common.Argument{
FilePath: o.ClusterCfgFile,
KubernetesVersion: o.Kubernetes,
KsEnable: o.EnableKubeSphere,
KsVersion: o.KubeSphere,
SkipPullImages: o.SkipPullImages,
SKipPushImages: o.SkipPushImages,
InCluster: o.CommonOptions.InCluster,
DeployLocalStorage: o.LocalStorage,
Debug: o.CommonOptions.Verbose,
IgnoreErr: o.CommonOptions.IgnoreErr,
SkipConfirmCheck: o.CommonOptions.SkipConfirmCheck,
ContainerManager: o.ContainerManager,
Artifact: o.Artifact,
SkipInstallPackages: o.SkipInstallPackages,
CertificatesDir: o.CertificatesDir,
FilePath: o.ClusterCfgFile,
KubernetesVersion: o.Kubernetes,
KsEnable: o.EnableKubeSphere,
KsVersion: o.KubeSphere,
SkipPullImages: o.SkipPullImages,
SKipPushImages: o.SkipPushImages,
InCluster: o.CommonOptions.InCluster,
DeployLocalStorage: o.LocalStorage,
Debug: o.CommonOptions.Verbose,
IgnoreErr: o.CommonOptions.IgnoreErr,
SkipConfirmCheck: o.CommonOptions.SkipConfirmCheck,
ContainerManager: o.ContainerManager,
Artifact: o.Artifact,
InstallPackages: o.InstallPackages,
CertificatesDir: o.CertificatesDir,
}
return pipelines.CreateCluster(arg, o.DownloadCmd)
@ -131,7 +131,7 @@ func (o *CreateClusterOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&o.DownloadCmd, "download-cmd", "", "curl -L -o %s %s",
`The user defined command to download the necessary binary files. The first param '%s' is output path, the second param '%s', is the URL`)
cmd.Flags().StringVarP(&o.Artifact, "artifact", "a", "", "Path to a KubeKey artifact")
cmd.Flags().BoolVarP(&o.SkipInstallPackages, "skip-install-packages", "", false, "Skip install packages by artifact")
cmd.Flags().BoolVarP(&o.InstallPackages, "with-packages", "", false, "install operation system packages by artifact")
}
func completionSetting(cmd *cobra.Command) (err error) {

View File

@ -247,6 +247,10 @@ type LocalCopy struct {
func (l *LocalCopy) Execute(runtime connector.Runtime) error {
for _, sys := range l.Manifest.Spec.OperationSystems {
if sys.Repository.Iso.LocalPath == "" {
continue
}
dir := filepath.Join(runtime.GetWorkDir(), common.Artifact, "repository", sys.Arch, sys.Id, sys.Version)
if err := coreutil.Mkdir(dir); err != nil {
return errors.Wrapf(errors.WithStack(err), "mkdir %s failed", dir)

View File

@ -44,8 +44,8 @@ spec:
osImage: {{ $v.OsImage }}
repository:
iso:
localPath: {{ $v.Repository.Iso.LocalPath }}
url: {{ $v.Repository.Iso.Url }}
localPath:
url:
{{- end }}
kubernetesDistributions:
{{- range $i, $v := .Options.KubernetesDistributions }}

View File

@ -32,27 +32,27 @@ type KubeRuntime struct {
}
type Argument struct {
NodeName string
FilePath string
KubernetesVersion string
KsEnable bool
KsVersion string
Debug bool
IgnoreErr bool
SkipPullImages bool
SKipPushImages bool
AddImagesRepo bool
DeployLocalStorage bool
SourcesDir string
DownloadCommand func(path, url string) string
SkipConfirmCheck bool
InCluster bool
ContainerManager string
FromCluster bool
KubeConfig string
Artifact string
SkipInstallPackages bool
CertificatesDir string
NodeName string
FilePath string
KubernetesVersion string
KsEnable bool
KsVersion string
Debug bool
IgnoreErr bool
SkipPullImages bool
SKipPushImages bool
AddImagesRepo bool
DeployLocalStorage bool
SourcesDir string
DownloadCommand func(path, url string) string
SkipConfirmCheck bool
InCluster bool
ContainerManager string
FromCluster bool
KubeConfig string
Artifact string
InstallPackages bool
CertificatesDir string
}
func NewKubeRuntime(flag string, arg Argument) (*KubeRuntime, error) {

View File

@ -147,9 +147,15 @@ func (p *PushImage) Execute(runtime connector.Runtime) error {
}
for _, file := range files {
name := file.Name()
if err := CmdPush(name, imagesPath, p.KubeConf, arches); err != nil {
return err
for i := 5; i > 0; i-- {
name := file.Name()
if err := CmdPush(name, imagesPath, p.KubeConf, arches); err != nil {
if i == 1 {
return err
}
continue
}
break
}
}
return nil

View File

@ -46,7 +46,7 @@ func NewAddNodesPipeline(runtime *common.KubeRuntime) error {
&precheck.NodePreCheckModule{},
&confirm.InstallConfirmModule{Skip: runtime.Arg.SkipConfirmCheck},
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || runtime.Arg.SkipInstallPackages},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.NodeBinariesModule{},
&os.ConfigureOSModule{},
&registry.RegistryCertsModule{Skip: len(runtime.GetHostsByRole(common.Registry)) == 0},

View File

@ -56,7 +56,7 @@ func NewCreateClusterPipeline(runtime *common.KubeRuntime) error {
&precheck.NodePreCheckModule{},
&confirm.InstallConfirmModule{Skip: runtime.Arg.SkipConfirmCheck},
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || runtime.Arg.SkipInstallPackages},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.NodeBinariesModule{},
&os.ConfigureOSModule{},
&kubernetes.StatusModule{},