增强对应用的支持
应用与集群解耦
集群镜像,表示一个镜像包含 cluster runtime,如 Kubernetes、K0S、K3S 等。Run 阶段既会安装集群也会安装应用(如果包含了应用) 应用镜像,表示一个镜像未包含 cluster runtime,其需要基于已有的集群进行安装。
▧Kubefile 支持 LABEL & KUBEVERSION 指令
针对集群镜像,通过 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, etcLABEL "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.24LABEL "created-by"="sealer.io"......
▧Build 支持打标镜像类型
kube-installer,集群镜像。

app-installer,应用镜像。

▧Run 简简单单运行应用镜像
TODO: 针对应用镜像声明支持的 KUBEVERSION,运行应用镜像时验证此版本约束
sealer run {{.appImageName}}
Kubefile 让应用定义更简单
▧APP 指令
APP 指令在 Kubefile 范围内可定义多次 APP_NAME 在 Sealer Image 范围内需保证唯一 schema 目前支持如下格式:
local://path_rel_2_build_context (build context 中的文件,文件路径为基于 build context 的相对路径) http(s)://example.yaml (http(s) 远程地址,会在 build 节点自动下载)
path 的目录/文件类型目前支持如下类型:
.sh,shell 脚本 .yaml | .yml,kubernetes YAML 文件 Helm Chart 目录
▧CNI/CSI 指令
PS: CSI 与 CNI 基本类似,此处不再赘述
CNI 指令本质上是指定了 CNI 网络插件类型的 APP,所有特性与 APP 指令相同 CNI 指令相比 APP 指令,会自动生成 label key cluster.alpha.sealer.io/kube-cni 声明镜像支持的 CNI 网络插件列表,例如: "cluster.alpha.sealer.io/kube-cni": ["calico", "flannel"]
▧APPCMDS 指令
类似 Dockerfile CMD 指令,但其作用域为 APP 维度 针对同一个 APP_NAME,如果有多个 APPCMDS 被指定,仅最后一个生效
▧LAUNCH 指令
LAUNCH 指令在 Kubefile 范围内仅可定义一份 如果 APPCMDS 未指定,则 LAUNCH 指令会尝试自动解析文件类型,并自动生成执行行为 FROM 镜像中包含的 LAUCH 指令不生效,仅最后一个 LAUNCH 指令生效(例如:对于子镜像,如果需要,需要在子镜像中重新填写父镜像中的 LAUNCH 指令 ) APP_NAME 可以是 Sealer Image 范围内的,允许指定 FROM 镜像中声明的 APP_NAME
▧Kubefile 预览
FROM sealerio/kubernetes:v1.22.15# Override or provide CNI plugins, the syntax is same with `APP`. In fact, we can think of CNI as a special kind of `APP`.# And multiple `CNI` definitions can be specified. If the name is the same, the last one takes precedence.# In addition, the CNI plugin is not only an app, but also reflected in the label `cluster.alpha.sealer.io/kube-cni`.CNI calico local://install-calico.shCNI calico local://install-calico-new.shCNI flannel local://flannel.yaml# Override or provide CRI plugins just like `CNI`.# In addition, the CNI plugin is not only an app, but also reflected in the label `cluster.alpha.sealer.io/kube-csi`.CSI alibaba-cloud-csi-driver local://install-alibaba-cloud-csi-driver.sh
应用镜像 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# NOTE: This value will not be inherited.# 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# add redis app# ["kubectl apply -f redis.yaml"] will be executedAPP redis local://redis.yaml# add nginx app# ["kubectl apply -f nginx.yaml -n nginx-namespace"] will be executedAPP nginx local://nginx.yaml# `APPCMDS` specify the cmds for a specified app and the context is the dir of specified app.# The `APPCMDS` instruction format: ["executable","param1","param2"]# If there are more than one `APPCMDS` for a `APP` then only the last `APPCMDS` will take effect.APPCMDS nginx ["kubectl apply -f nginx.yaml -n nginx-namespace"]# add mysql app# ["helm install mysql . -f values.yaml --set key=value"] will be executedAPP mysql local://charts/mysql/ local://values.yaml# `APPCMDS` must be specified when the app has multiple filesAPPCMDS mysql ["helm install mysql .", "-f values.yaml", "--set key=value"]LABEL <key>=<value> <key>=<value> <key>=<value> ...LABEL "created-by"="sealer.io"# The following operation will be executed:# ["kubectl apply -f nginx.yaml -n nginx-namespace", "helm install mysql . -f values.yaml --set key=value"]LAUNCH ["nginx", "mysql"]
Clusterfile 扩展支持应用配置
通过 ClusterSpec.appNames 覆盖 Kubefile 中的 LAUNCH 指令值,如下所示,Kubefile 中包含了 nginx,mysql 两个 APP,在 appNames 中只需一条简单的配置 appNames: [ "nginx" ],即可变更运行镜像的启动行为为只运行 nginx 这个 APP。 通过 Application Config,同样可以非常便捷的覆盖 Kubefile 中针对 APP 指定的 APPCMDS 内容,在运行态自定义启动命令。(同时社区也正在推进支持 APP 包含的文件的修改能力,详情可参考 #1969[4] )
apiVersion: sealer.cloud/v2kind: Clustermetadata:name: my-clusterspec:image: myimage-with-nginx-mysql:v1appNames: [ "nginx" ]......---apiVersion: sealer.io/v2kind: Applicationmetadata:name: my-appsspec:configs:- name: app1launch:cmds:- kubectl apply -f ns.yaml- kubectl apply -f nginx.yaml -n namespace- name: app2launch:cmds:- helm install my-nginx bitnami/nginx- name: app3launch:cmds:- bash nginx.sh
其他值得关注点
镜像引擎升级,Sealer Image 拥抱 OCI 标准

基于标准的 K8S webhook 能力实现 image policy,不再有 hack
//daemon.json定义{"mirror-registries":[{"domain": "*","mirrors": ["http://sea.hub:5000", "https://mirror.test2.com"]}],"insecure-registries": ["sea.hub:5000", "mirror.test1.com"]}
上述方案确实很好的解决了镜像代理的问题,但其有一定的局限性:
不兼容用户已有 docker,要求环境内不存在或者卸载 docker 针对自定义 Docker 需求,同样需要进行如上的定制化配置 上述方案仅针对 Docker Engine 有效,对 containerd 等其他 container runtime 需要另做处理
经过探索,Sealer 社区讨论后考虑基于社区标准的 kubernetes 扩展机制来解决上述问题。经过调研, Kyverno[6]是一款 Kubernetes policy 引擎,其可以以一种非常简单的配置方式支持对 Kubernetes 资源进行校验和修改能力,同时其针对 K0s,K3s 等 cluster runtime 同样适用。

Cloud Native
接下来,Sealer 将会继续秉持 以集群为基础,以应用为中心,继续在打包、交付和运行的道路上持续探索,
以应用为中心,构建完善的分布式应用协作生态。
丰富应用模型,支持应用基于声明能力一键化部署 覆盖应用全生命周期,甚至运维监控能力 扩大生态,如支持更多 APP 类型,如 helm chart/ kube resource/kustomize/shell/ OAM 应用等 打造社区版 Sealer Image Hub,为基于 Sealer Image 的协作提供平台
以集群为基础,构建稳定易用的集群交付能力。
一键支撑大规模集群,解决大规模集群的安装部署、镜像分发等问题 丰富 container runtime,cluster runtime 支持生态 目前社区同学已经正在推进 containerd container runtime 和 k0s、k3s cluster runtime 的支持 丰富集群运行时运维工具箱,例如证书签发、健康检查、OS 审计等 支持集群镜像的升级能力,帮助用户可以持续使用最新最稳定的集群镜像
文章转载自k8s技术圈,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




