Skip to content

Commit

Permalink
add sealer apply -m loadImage command (#1857)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevent-fei authored Nov 15, 2022
1 parent f9cc112 commit 1440c38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/sealer/cmd/cluster/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -204,6 +216,7 @@ func createNewCluster(clusterImageName string, infraDriver infradriver.InfraDriv
if err = cf.SaveAll(); err != nil {
return err
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ const (
EnvIPv6DualStack = "IPv6DualStack"
)

const (
ApplyModeApply = "apply"
ApplyModeLoadImage = "loadImage"
)

// image module
const (
DefaultImageRootDir = "/var/lib/sealer/data"
Expand Down

0 comments on commit 1440c38

Please sign in to comment.