一个operator bundle是一个特殊的container image。这个特殊的image存储了k8 manifests和与一个opearator相关联的metadata。一个bundle可以理解为一个特定版本的operator。
一个operator bundle通常是non-runnable的,但是其可以在oci-compliant container registry上一个push和pull。最终的,这个operator bundle可以被operator registry和OLM所用,用来在支持OLM的cluster上安装operator。
operator bundle格式
$ tree operator-bundle-tetoperator-bundle-tet├── my-manifests│ ├── etcdcluster.crd.yaml│ └── etcdoperator.clusterserviceversion.yaml├── metadata│ └── annotations.yaml└── Dockerfile
bundle manfiest格式
$ tree/├── manifests│ ├── etcdcluster.crd.yaml│ └── etcdoperator.clusterserviceversion.yaml└── metadata├── annotations.yaml└── dependencies.yaml
其中, manifests和metadata的名字是可以改的,需要和annotations中的定义保持一致即可。
Bundle Annotations
annodations.yml
annotations:operators.operatorframework.io.bundle.mediatype.v1: "registry+v1"operators.operatorframework.io.bundle.manifests.v1: "manifests/"operators.operatorframework.io.bundle.metadata.v1: "metadata/"operators.operatorframework.io.bundle.package.v1: "test-operator"reflects the list of channels the bundle is subscribing to when added into an operator registryoperators.operatorframework.io.bundle.channels.v1: "beta,stable"operators.operatorframework.io.bundle.channel.default.v1: "stable"
Bundle Dependencies
一个operator的依赖被定义在dependencies.yaml文件中。
dependencies:- type: olm.packagevalue:packageName: prometheusversion: ">0.27.0"- type: olm.gvkvalue:group: etcd.kind: EtcdClusterversion: v1beta2
Bundle Dockerfile
FROM scratch# We are pushing an operator-registry bundle# that has both metadata and manifests.LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/LABEL operators.operatorframework.io.bundle.package.v1=test-operatorLABEL operators.operatorframework.io.bundle.channels.v1=beta,stableLABEL operators.operatorframework.io.bundle.channel.default.v1=stableADD test/*.yaml /manifestsADD test/metadata/annotations.yaml /metadata/annotations.yaml