2.2 使用清单文件安装

本文档假设您熟悉 kubectl 并且已安装。或者,请参见 第 2.1 节,“使用 Helm 图表安装”

MySQL Operator for Kubernetes 可以使用 kubectl 和原始清单文件安装。

注意

在 URL 中使用 trunk 表示最新版本的 MySQL Operator for Kubernetes,因为 Github 在发布时会更新。或者,在 URL 中用特定 标记的已发布版本 替换 trunk

首先安装 MySQL Operator for Kubernetes 使用的自定义资源定义 (CRD)

$> kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-operator/trunk/deploy/deploy-crds.yaml

// Output is similar to:
customresourcedefinition.apiextensions.k8s.io/innodbclusters.mysql.oracle.com created
customresourcedefinition.apiextensions.k8s.io/mysqlbackups.mysql.oracle.com created
customresourcedefinition.apiextensions.k8s.io/clusterkopfpeerings.zalando.org created
customresourcedefinition.apiextensions.k8s.io/kopfpeerings.zalando.org created

接下来部署 MySQL Operator for Kubernetes,其中还包含 RBAC 定义,如输出中所述

$> kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-operator/trunk/deploy/deploy-operator.yaml

// Output is similar to:
clusterrole.rbac.authorization.k8s.io/mysql-operator created
clusterrole.rbac.authorization.k8s.io/mysql-sidecar created
clusterrolebinding.rbac.authorization.k8s.io/mysql-operator-rolebinding created
clusterkopfpeering.zalando.org/mysql-operator created
namespace/mysql-operator created
serviceaccount/mysql-operator-sa created
deployment.apps/mysql-operator created

通过检查 mysql-operator 命名空间(由 deploy-operator.yaml 定义的可配置命名空间)中管理操作员的部署,验证操作员是否正在运行

$> kubectl get deployment mysql-operator --namespace mysql-operator

MySQL Operator for Kubernetes 准备好后,输出应类似于以下内容

NAME             READY   UP-TO-DATE   AVAILABLE   AGE
mysql-operator   1/1     1            1           37s

要使用 MySQL Operator for Kubernetes 创建 MySQL InnoDB 集群,请参见 第 3 章,MySQL InnoDB 集群