2.2 使用清单文件安装

本文档假设您熟悉 kubectl并且您已经安装了它。或者,请参阅 第 2.1 节 “使用 Helm Charts 安装”

可以使用带有 kubectl 的原始清单文件安装 MySQL Operator for Kubernetes;首先安装 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

接下来为 Kubernetes 部署 MySQL Operator,它还包括 输出中指出的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 集群