首页 > 其他分享 >Sealer 0.9 :帮助集群和分布式应用实现 Build、 Share、Run

Sealer 0.9 :帮助集群和分布式应用实现 Build、 Share、Run

时间:2023-01-18 13:22:30浏览次数:44  
标签:Sealer 0.9 APP 分布式应用 cluster 镜像 CNI sealer

作者:sealer 社区

新春之际,很高兴在此时宣布 Sealer [ 1] 0.9 版本的正式发布。Sealer 是一款致力于探索面向分布式应用的快速打包、交付和运行的解决方案。2021 年5月 Sealer 项目正式开源;短短一年时间,Sealer 在 2022 年 4 月成为 CNCF Sandbox 项目。

Sealer 0.9 版本中,其在核心定位上由专注 “集群维度的 Build,Share,Run” 升级为 “以集群为基础,以应用为中心,帮助集群和分布式应用实现 Build, Share,Run”,并重点增强了对应用的支持能力。

版本详解

增强对应用的支持

应用与集群解耦

Docker Image 很好的解决了单机应用的打包交付问题,而 **Sealer Image [ 2] **尝试在集群维度,解决类 Kubernetes 集群以及分布式应用的打包交付问题。Sealer Image 基于包含内容将 Sealer Image 分为集群镜像和应用镜像。其中:

  • 集群镜像,表示一个镜像包含 cluster runtime,如 Kubernetes、K0S、K3S 等。Run 阶段既会安装集群也会安装应用(如果包含了应用)
  • 应用镜像,表示一个镜像未包含 cluster runtime,其需要基于已有的集群进行安装。
Kubefile 支持 LABEL & KUBEVERSION 指令

Kubefile 中 LABEL 指令类似 Dockerfile LABEL 指令,允许用户针对 Sealer Image 指定一些元数据信息,这些元数据信息在构建完成后可通过 sealer inspect 命令查看。

其中,Sealer 官方保留以 *sealer.io/ 为前缀的 label key,如:
针对集群镜像,通过 LABEL 可声明集群镜像支持的能力列表等信息

  • cluster.alpha.sealer.io/cluster-runtime-type,支持的集群类型,如 kubernetes, k0s, k3s 等
  • cluster.alpha.sealer.io/cluster-runtime-version,支持的集群 runtime 的版本,如 kubernetes 版本
  • cluster.alpha.sealer.io/container-runtime-type,支持的 container runtime 类型,如 docker,containerd 等
  • cluster.alpha.sealer.io/container-runtime-version,支持的 container runtime 版本,如 docker 版本
  • cluster.alpha.sealer.io/kube-cni,支持的 CNI 列表,如 calico,flannel 等
  • cluster.alpha.sealer.io/kube-csi,支持的 CSI 列表,如 alibaba-cloud-csi-driver 等

针对应用镜像,通过 LABEL 可声明应用镜像兼容的 kube runtime 版本等信息,通过声明解耦集群镜像

  • app.alpha.sealer.io/supported-kube-version,应用镜像支持的 kube runtime 版本,其值定义 **Semantic Versioning 2.0.0 [ 3] **。另外,Kubefile 中也可通过  KUBEVERSION 指令快捷定义该 label 的值。

集群镜像 Kubefile:

FROM sealerio/kubernetes:v1.22.15

# Add some metadata to an image just like `Dockerfile LABEL instruction`.
# An image can have more than one label. You can specify multiple labels on a single line.
# 
# NOTE: 
# 1. In general, a base image should declare supported cluster runtimes, container runtimes, etc.
# 2. Sealer reserves all label keys prefixed with `sealer.io`.
# 3. All labels will be inherited by child image.
# LABEL <key>=<value> <key>=<value> <key>=<value> ...
# LABEL <key>=<value> \
#       <key>=<value> \
#       <key>=<value> ...
LABEL "cluster.alpha.sealer.io/cluster-runtime-version"="v1.22.15"
# such as kubernetes, k0s, k3s, etc
LABEL "cluster.alpha.sealer.io/cluster-runtime-type"="kubernetes" 
LABEL "cluster.alpha.sealer.io/container-runtime-type"="docker"
LABEL "cluster.alpha.sealer.io/container-runtime-version"="20.10.14"
......

应用镜像 Kubefile:

FROM scratch

# A SemVer range of compatible Kubernetes versions by the applications.
# If there are multiple apps in the `Kubefile`, you should take the intersection of the cluster versions they support
# The label `app.alpha.sealer.io/supported-kube-version` will be gernetated with `KUBEVERSION`.
# For a detailed explanation of supported semver constraints see [Masterminds/semver](https://github.com/Masterminds/semver).
KUBEVERSION 1.22 - 1.24

LABEL "created-by"="sealer.io"
......
Build 支持打标镜像类型

为了让使用者在获取到一个镜像后,能够清晰的知道一个镜像包含的内容以及行为。在  build image 阶段,Sealer 可以通过 sealer build --type kube-installer | app-installer 为构建出来的 Sealer Image 打标。

  1. kube-installer,集群镜像。

1.png

  1. app-installer,应用镜像。

2.png

Run 简简单单运行应用镜像

针对应用镜像(sealer build --type app-installer),部署在基于 Sealer 集群镜像部署的集群内,仅需简单单单一条命令即可,用户也不需要再关心集群节点信息等。

TODO: 针对应用镜像声明支持的 KUBEVERSION,运行应用镜像时验证此版本约束

sealer run {{.appImageName}}

Kubefile 让应用定义更简单

Kubefile 新增加APP 指令,其允许用户定义一个 APP 虚拟对象,通过 CNI、CSI 指令分别支持 CNI,CSI 插件的管理,通过 APPCMDS 指令为 APP 指定安装命令,并可以通过 LAUNCH 指令,以 APP 对象为维度选择启动对象。

APP 指令

APP 指令格式 APP APP_NAME scheme:path1 scheme:path2,其中:

  1. APP 指令在 Kubefile 范围内可定义多次
  2. APP_NAME 在 Sealer Image 范围内需保证唯一
  3. schema 目前支持如下格式:
    1. local://path_rel_2_build_context (build context 中的文件,文件路径为基于 build context 的相对路径)
    2. http(s)

      标签:Sealer,0.9,APP,分布式应用,cluster,镜像,CNI,sealer
      From: https://www.cnblogs.com/alisystemsoftware/p/17059597.html

相关文章