|
| 1 | +English | [简体中文](../zh-cn/deploy_radondb-mysql_operator_on_kubesphere.md) |
| 2 | + |
| 3 | +Contents |
| 4 | +============= |
| 5 | + |
| 6 | + * [Deploy RadonDB MySQL Operator and RadonDB MySQL Cluster on KubeSphere](#deploy-radondb-mysql-operator-and-radondb-mysql-cluster-on-kubesphere) |
| 7 | + * [Prerequisites](#prerequisites) |
| 8 | + * [Deployment](#deployment) |
| 9 | + * [Step 1: Add an app repository](#step-1-add-an-app-repository) |
| 10 | + * [Step 2: Deploy RadonDB MySQL Operator](#step-2-deploy-radondb-mysql-operator) |
| 11 | + * [Step 3: Deploy a RadonDB MySQL cluster](#step-3-deploy-a-radondb-mysql-cluster) |
| 12 | + * [Deployment Validation](#deployment-validation) |
| 13 | + * [Access the RadonDB MySQL cluster](#access-the-radondb-mysql-cluster) |
| 14 | + * [Method 1: Via terminal](#method-1-via-terminal) |
| 15 | + * [Method 2: Via Kubectl tool](#method-2-via-kubectl-tool) |
| 16 | + |
| 17 | +# Deploy RadonDB MySQL Operator and RadonDB MySQL Cluster on KubeSphere |
| 18 | + |
| 19 | +[RadonDB MySQL](https://github.com/radondb/radondb-mysql-kubernetes) is an open source, cloud-native, and highly available cluster solution based on [MySQL](https://MySQL.org) database. With the Raft protocol, RadonDB MySQL enables fast failover without losing any transactions. |
| 20 | + |
| 21 | +This tutorial demonstrates how to deploy RadonDB MySQL Operator and a RadonDB MySQL Cluster on KubeSphere. |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +- You need to enable [the OpenPitrix system](https://kubesphere.io/docs/pluggable-components/app-store/). |
| 26 | +- You need to create a workspace, a project, and two user accounts for this tutorial. This tutorial uses `demo` and `demo-project` for demonstration. If they are not ready, refer to [Create Workspaces, Projects, Users and Roles](https://kubesphere.io/docs/quick-start/create-workspace-and-project/). |
| 27 | +- You need to enable the gateway in your project to provide external access. If they are not ready, refer to [Project Gateway](https://kubesphere.io/docs/project-administration/project-gateway/). |
| 28 | + |
| 29 | +## Deployment |
| 30 | + |
| 31 | +### Step 1: Add an app repository |
| 32 | + |
| 33 | +1. Log in to the KubeSphere Web console. |
| 34 | + |
| 35 | +2. In `demo` workspace, go to **App Repositories** under **App Management**, and then click **Create**. |
| 36 | + |
| 37 | +3. In the dialog that appears, enter an app repository name and URL. |
| 38 | + |
| 39 | + Enter `radondb-mysql-operator` for the app repository name 。 |
| 40 | + Enter `https://radondb.github.io/radondb-mysql-kubernetes/` for the MeterSphere repository URL. Click **Validate** to verify the URL. |
| 41 | + |
| 42 | +4. You will see a green check mark next to the URL if it is available. Click **OK** to continue. |
| 43 | + |
| 44 | + Your repository displays in the list after it is successfully imported to KubeSphere. |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +### Step 2: Deploy RadonDB MySQL Operator |
| 49 | + |
| 50 | +1. In `demo-project`, go to **Apps** under **Application Workloads** and click **Deploy New App**. |
| 51 | + |
| 52 | +2. In the dialog that appears, select **From App Template**. |
| 53 | + |
| 54 | +3. On the new page that appears, select `radondb-mysql-operator` from the drop-down list. |
| 55 | + |
| 56 | +4. Click **clickhouse-cluster**, check and config RadonDB MySQL Operator. |
| 57 | + |
| 58 | + On the **Chart Files** tab, you can view the configuration and edit the `.yaml` files. |
| 59 | + On the **Version** list, you can view the app versions and select a version. |
| 60 | + |
| 61 | +  |
| 62 | + |
| 63 | +5. Click **Deploy**, go to the **Basic Information** page. |
| 64 | + |
| 65 | + Confirm the app name, app version, and deployment location. |
| 66 | + |
| 67 | +6. Click **Next** to continue, go to the **App Configuration** page. |
| 68 | + |
| 69 | + You can change the YAML file to customize settings. |
| 70 | + |
| 71 | +7. Click **Deploy** to use the default settings. |
| 72 | + |
| 73 | + After a while, you can see the app is in the **Running** status. |
| 74 | + |
| 75 | +### Step 3: Deploy a RadonDB MySQL cluster |
| 76 | + |
| 77 | +You can refer to [RadonDB MySQL template](/config/samples) to deploy a cluster, or you can customize the yaml file to deploy a cluster. |
| 78 | + |
| 79 | +Take `mysql_v1alpha1_mysqlcluster.yaml` template as an example to create a RadonDB MySQL cluster. |
| 80 | + |
| 81 | +1. Hover your cursor over the hammer icon in the lower-right corner, and then select **Kubectl**. |
| 82 | + |
| 83 | +2. Run the following command to install RadonDB MySQL cluster. |
| 84 | + |
| 85 | + ```kubectl |
| 86 | + kubectl apply -f https://github.com/radondb/radondb-mysql-kubernetes/releases/latest/download/mysql_v1alpha1_mysqlcluster.yaml --namespace=<project_name> |
| 87 | + ``` |
| 88 | + |
| 89 | + {{< notice note >}} |
| 90 | + |
| 91 | + When no project is specified, the cluster will be installed in the `kubesphere-controls-system` project by default. To specify a project, the install command needs to add the `--namespace=<project_name>` field. |
| 92 | + |
| 93 | + {{</ notice >}} |
| 94 | + |
| 95 | + You can see the expected output as below if the installation is successful. |
| 96 | + |
| 97 | + ```powershell |
| 98 | + $ kubectl apply -f https://github.com/radondb/radondb-mysql-kubernetes/releases/latest/download/mysql_v1alpha1_mysqlcluster.yaml --namespace=demo-project |
| 99 | + mysqlcluster.mysql.radondb.com/sample created |
| 100 | + ``` |
| 101 | + |
| 102 | +3. You can run the following command to view all services of RadonDB MySQL cluster. |
| 103 | + |
| 104 | + ```kubectl |
| 105 | + kubectl get statefulset,svc |
| 106 | + ``` |
| 107 | + |
| 108 | + **Expected output** |
| 109 | + |
| 110 | + ```powershell |
| 111 | + $ kubectl get statefulset,svc |
| 112 | + NAME READY AGE |
| 113 | + statefulset.apps/sample-mysql 3/3 10m |
| 114 | +
|
| 115 | + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 116 | + service/default-http-backend ClusterIP 10.96.69.202 <none> 80/TCP 3h2m |
| 117 | + service/sample-follower ClusterIP 10.96.9.162 <none> 3306/TCP 10m |
| 118 | + service/sample-leader ClusterIP 10.96.255.188 <none> 3306/TCP 10m |
| 119 | + service/sample-mysql ClusterIP None <none> 3306/TCP 10m |
| 120 | + ``` |
| 121 | + |
| 122 | +## Deployment Validation |
| 123 | + |
| 124 | +1. In `demo-project` project,go to **Services** under **Application Workloads**, you can see the information of services. |
| 125 | + |
| 126 | +2. In **Workloads** under **Application Workloads**, click the **StatefulSets** tab, and you can see the StatefulSets are up and running. |
| 127 | + |
| 128 | + Click a single StatefulSet to go to its detail page. You can see the metrics in line charts over a period of time under the **Monitoring** tab. |
| 129 | + |
| 130 | +3. In **Pods** under **Application Workloads**, you can see all the Pods are up and running. |
| 131 | + |
| 132 | +4. In **Volumes** under **Storage**, you can see the ClickHouse Cluster components are using persistent volumes. |
| 133 | + |
| 134 | + Volume usage is also monitored. Click a volume item to go to its detail page. |
| 135 | + |
| 136 | +## Access the RadonDB MySQL cluster |
| 137 | + |
| 138 | +The following demonstrates how to access RadonDB MySQL in KubeSphere Web console. |
| 139 | + |
| 140 | +### Method 1: Via pod terminal |
| 141 | + |
| 142 | +Go to the `demo-project` project management page, access RadonDB MySQL through the terminal. |
| 143 | + |
| 144 | +1. Go to **Pods** under **Application Workloads**. |
| 145 | + |
| 146 | +2. Click a pod name to go to the pod management page. |
| 147 | + |
| 148 | +3. Under the **Container** column box in **Resource Status**, click the terminal icon for the **mysql** container. |
| 149 | + |
| 150 | +4. In terminal window, run the following command to access the RadonDB MySQL cluster. |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | +### Method 2: Via Kubectl tool |
| 155 | + |
| 156 | +Hover your cursor over the hammer icon in the lower-right corner, and then select **Kubectl**. |
| 157 | + |
| 158 | +Run the following command to access the RadonDB MySQL cluster. |
| 159 | + |
| 160 | +```kubectl |
| 161 | +kubectl exec -it <pod_name> -c mysql -n <project_name> -- mysql --user=<user_name> --password=<user_password> |
| 162 | +``` |
| 163 | + |
| 164 | +{{< notice note >}} |
| 165 | + |
| 166 | +In the blow command, `sample-mysql-0` is the Pod name and `demo-project` is the Project name. Make sure you use your own Pod name, project name, username, and password. |
| 167 | + |
| 168 | +{{</ notice >}} |
| 169 | + |
| 170 | + |
0 commit comments