Helm App Operator套件

该项目也是Operator Framework 下的一个组件,一个开源工具包,旨在以有效的,自动化的和可扩展的方式来管理Kubernetes的一种叫做 Operator 的原生应用。了解更多:https://coreos.com/blog/introducing-operator-framework

本库作为一个模版,用于轻松地创建被Kubernetes Deployment或者Helm Charts所管理的无状态应用。它的灵感来自于Lostromos project。使用 `operator-sdk new` 命令创建它所依赖的Operator.

安装基于Helm的自定义应用程序

虽然Operator Lifecycle Manager 可以管理Operator,但是并非所有的应用程序都需要开发人员编写一个自定义的Operator。Helm App Operator Kit 可以利用预先存在的Helm Charts将Kubernetes资源部署为统一的应用程序。

git clone https://github.com/coreos/helm-app-operator-kit
cd helm-app-operator-kit

先决条件

  • Kubernetes 1.9+ cluster

  • docker client

  • kubectl client

  • Helm Chart

说明:

  1. 运行以下命令:

$ git checkout git@github.com:operator-framework/helm-app-operator-kit.git && cd helm-app-operator-kit
$ cd helm-app-operator && dep ensure && cd ..
$ docker build -t quay.io/<namespace>/<chart>-operator --build-arg HELM_CHART=/path/to/helm/chart --build-arg API_VERSION=<group/version> --build-arg KIND=<Kind> .
$ docker push quay.io/<namespace>/<chart>-operator

在`helm-app-operator/deploy`中,修改以下Kubernetes YAML Manifest文件:

File

Action

deploy/crd.yaml

Define your CRD (kind, spec.version, spec.group must match the docker build args)

deploy/cr.yaml

Make an instance of your custom resource (kind, apiVersion *must match the docker build args)

deploy/operator.yaml

Replace <namespace> and <chart> appropriately

deploy/rbac.yaml

Ensure the resources created by your chart are properly listed

deploy/olm-catalog/csv.yaml

Replace fields appropriately. Define RBAC in spec.install.spec.permissions. Ensure spec.customresourcedefinitions.owned correctly contains your CRD

deploy/olm-catalog/crd.yaml

Define your CRD (kind, spec.version, spec.group must match the docker build args)

将manifest应用于您的Kubernetes集群(如果您在使用OLM的话):

$ kubectl create -f helm-app-operator/deploy/olm-catalog/crd.yaml
$ kubectl create -n <operator-namespace> -f helm-app-operator/deploy/olm-catalog/csv.yaml

否则,需要手动创建RBAC和部署资源:

$ kubectl create -f helm-app-operator/deploy/crd.yaml
$ kubectl create -n <operator-namespace> -f helm-app-operator/deploy/rbac.yaml
$ kubectl create -n <operator-namespace> -f helm-app-operator/deploy/operator.yaml

创建示例应用程序的一个实例:

在创建新应用程序的 CustomResourceDefinition and ClusterServiceVersion 资源之后, 可以创建该应用程序的新实例:

$ kubectl create -n <operator-namespace> -f helm-app-operator/deploy/cr.yaml

确认在Helm Charts中定义的资源被创建了。

最后更新于