diff --git a/cmd/sealer/cmd/cluster/apply.go b/cmd/sealer/cmd/cluster/apply.go index dd600580643..30927c30143 100644 --- a/cmd/sealer/cmd/cluster/apply.go +++ b/cmd/sealer/cmd/cluster/apply.go @@ -39,6 +39,8 @@ import ( var applyClusterFile string +var applyMode string + const MasterRoleLabel = "node-role.kubernetes.io/master" var longApplyCmdDescription = `apply command is used to apply a Kubernetes cluster via specified Clusterfile. @@ -133,6 +135,7 @@ func NewApplyCmd() *cobra.Command { } applyCmd.Flags().BoolVar(&ForceDelete, "force", false, "force to delete the specified cluster if set true") applyCmd.Flags().StringVarP(&applyClusterFile, "Clusterfile", "f", "", "Clusterfile path to apply a Kubernetes cluster") + applyCmd.Flags().StringVarP(&applyMode, "applyMode", "m", common.ApplyModeApply, "the run mode") return applyCmd } @@ -169,6 +172,15 @@ func createNewCluster(clusterImageName string, infraDriver infradriver.InfraDriv return err } + if applyMode == common.ApplyModeLoadImage { + logrus.Infof("start to apply with mode(%s)", applyMode) + + if err = distributor.DistributeRegistry(infraDriver.GetHostIPList()[0], infraDriver.GetClusterRootfsPath()); err != nil { + return err + } + logrus.Infof("load image success") + return nil + } plugins, err := loadPluginsFromImage(imageMountInfo) if err != nil { return err @@ -204,6 +216,7 @@ func createNewCluster(clusterImageName string, infraDriver infradriver.InfraDriv if err = cf.SaveAll(); err != nil { return err } + return nil } diff --git a/common/common.go b/common/common.go index e499512d448..4eee0a0cc28 100644 --- a/common/common.go +++ b/common/common.go @@ -75,6 +75,11 @@ const ( EnvIPv6DualStack = "IPv6DualStack" ) +const ( + ApplyModeApply = "apply" + ApplyModeLoadImage = "loadImage" +) + // image module const ( DefaultImageRootDir = "/var/lib/sealer/data"