Skip to content

Commit

Permalink
docs: update kbcli cluster create, yaml, and monitoring docs in relea…
Browse files Browse the repository at this point in the history
…se-1.0 (#8729)

(cherry picked from commit 0c9a974)
  • Loading branch information
michelle-0808 committed Jan 8, 2025
1 parent ac8db9b commit 34962e1
Show file tree
Hide file tree
Showing 53 changed files with 2,288 additions and 2,227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,71 +105,59 @@ KubeBlocks supports creating two types of ApeCloud MySQL clusters: Standalone an

KubeBlocks implements a `Cluster` CRD to define a cluster. Here is an example of creating a RaftGroup Cluster.

If you only have one node for deploying a RaftGroup Cluster, set `spec.affinity.topologyKeys` as `null`. But for a production environment, it is not recommended to deploy all replicas on one node, which may decrease the cluster availability.
If you only have one node for deploying a RaftGroup Cluster, configure the cluster affinity by setting `spec.schedulingPolicy` or `spec.componentSpecs.schedulingPolicy`. For details, you can refer to the [API docs](https://kubeblocks.io/docs/preview/developer_docs/api-reference/cluster#apps.kubeblocks.io/v1.SchedulingPolicy). But for a production environment, it is not recommended to deploy all replicas on one node, which may decrease the cluster availability.

```yaml
cat <<EOF | kubectl apply -f -
apiVersion: apps.kubeblocks.io/v1alpha1
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
name: mycluster
namespace: demo
spec:
clusterDefinitionRef: apecloud-mysql
clusterVersionRef: ac-mysql-8.0.30
terminationPolicy: Delete
affinity:
podAntiAffinity: Preferred
topologyKeys:
- kubernetes.io/hostname
tolerations:
- key: kb-data
operator: Equal
value: 'true'
effect: NoSchedule
clusterDef: apecloud-mysql
topology: apecloud-mysql
componentSpecs:
- name: mysql
componentDefRef: mysql
enabledLogs:
- error
- general
- slow
disableExporter: true
replicas: 3
serviceAccountName: kb-acmysql-cluster
resources:
limits:
cpu: '0.5'
memory: 0.5Gi
requests:
cpu: '0.5'
memory: 0.5Gi
volumeClaimTemplates:
- name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
- name: mysql
serviceVersion: "8.0.30"
disableExporter: false
replicas: 3
resources:
limits:
cpu: '0.5'
memory: 0.5Gi
requests:
cpu: '0.5'
memory: 0.5Gi
volumeClaimTemplates:
- name: data
spec:
storageClassName: ""
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
EOF
```

| Field | Definition |
|---------------------------------------|--------------------------------------|
| `spec.clusterDefinitionRef` | It specifies the name of the ClusterDefinition for creating a specific type of cluster. |
| `spec.clusterVersionRef` | It is the name of the cluster version CRD that defines the cluster version. |
| `spec.terminationPolicy` | It is the policy of cluster termination. The default value is `Delete`. Valid values are `DoNotTerminate`, `Delete`, `WipeOut`. For the detailed definition, you can refer to [Termination Policy](./delete-mysql-cluster.md#termination-policy). |
| `spec.affinity` | It defines a set of node affinity scheduling rules for the cluster's Pods. This field helps control the placement of Pods on nodes within the cluster. |
| `spec.affinity.podAntiAffinity` | It specifies the anti-affinity level of Pods within a component. It determines how pods should spread across nodes to improve availability and performance. |
| `spec.affinity.topologyKeys` | It represents the key of node labels used to define the topology domain for Pod anti-affinity and Pod spread constraints. |
| `spec.tolerations` | It is an array that specifies tolerations attached to the cluster's Pods, allowing them to be scheduled onto nodes with matching taints. |
| `spec.componentSpecs` | It is the list of components that define the cluster components. This field allows customized configuration of each component within a cluster. |
| `spec.componentSpecs.componentDefRef` | It is the name of the component definition that is defined in the cluster definition and you can get the component definition names with `kubectl get clusterdefinition apecloud-mysql -o json \| jq '.spec.componentDefs[].name'`. |
| `spec.componentSpecs.name` | It specifies the name of the component. |
| `spec.componentSpecs.disableExporter` | It defines whether the monitoring function is enabled. |
| `spec.componentSpecs.replicas` | It specifies the number of replicas of the component. |
| `spec.componentSpecs.resources` | It specifies the resource requirements of the component. |
| `spec.terminationPolicy` | It is the policy of cluster termination. Valid values are `DoNotTerminate`, `Delete`, `WipeOut`. For the detailed definition, you can refer to [Termination Policy](./delete-mysql-cluster.md#termination-policy). |
| `spec.clusterDef` | It specifies the name of the ClusterDefinition to use when creating a Cluster. Note: DO NOT UPDATE THIS FIELD. The value must be `apecloud-mysql` to create a ApeCloud-MySQL Cluster. |
| `spec.topology` | It specifies the name of the ClusterTopology to be used when creating the Cluster. |
| `spec.componentSpecs` | It is the list of ClusterComponentSpec objects that define the individual Components that make up a Cluster. This field allows customized configuration of each component within a cluster. |
| `spec.componentSpecs.serviceVersion` | It specifies the version of the Service expected to be provisioned by this Component. The valid option for ApeCloud MySQL is 8.0.30. |
| `spec.componentSpecs.disableExporter` | It determines whether metrics exporter information is annotated on the Component's headless Service. Valid options are [true, false]. |
| `spec.componentSpecs.replicas` | It specifies the number of replicas of the component. ApeCloud-MySQL prefers ODD numbers like [1, 3, 5, 7]. |
| `spec.componentSpecs.resources` | It specifies the resources required by the Component. |
| `spec.componentSpecs.volumeClaimTemplates` | It specifies a list of PersistentVolumeClaim templates that define the storage requirements for the Component. |
| `spec.componentSpecs.volumeClaimTemplates.name` | It refers to the name of a volumeMount defined in `componentDefinition.spec.runtime.containers[*].volumeMounts`. |
| `spec.componentSpecs.volumeClaimTemplates.spec.storageClassName` | It is the name of the StorageClass required by the claim. If not specified, the StorageClass annotated with `storageclass.kubernetes.io/is-default-class=true` will be used by default. |
| `spec.componentSpecs.volumeClaimTemplates.spec.resources.storage` | You can set the storage size as needed. |

For more API fields and descriptions, refer to the [API Reference](https://kubeblocks.io/docs/preview/developer_docs/api-reference/cluster).

KubeBlocks operator watches for the `Cluster` CRD and creates the cluster and all dependent resources. You can get all the resources created by the cluster by running the command below.

Expand Down Expand Up @@ -209,19 +197,24 @@ KubeBlocks supports creating two types of ApeCloud MySQL clusters: Standalone an
Create a Standalone.

```bash
kbcli cluster create mycluster --cluster-definition apecloud-mysql --namespace demo
kbcli cluster create apecloud-mysql mycluster --mode='standalone' --namespace demo
```

Create a RaftGroup Cluster.

```bash
kbcli cluster create mycluster --cluster-definition apecloud-mysql --set replicas=3 --namespace demo
kbcli cluster create apecloud-mysql mycluster --mode='raftGroup' --namespace demo
```

If you only have one node for deploying a RaftGroup Cluster, set the `topology-keys` as `null` when creating a RaftGroup Cluster. But you should note that for a production environment, it is not recommended to deploy all replicas on one node, which may decrease the cluster availability.
If you only have one node for deploying a RaftGroup Cluster, you can configure the cluster affinity by setting `--pod-anti-affinity`, `--tolerations`, and `--topology-keys` when creating a RaftGroup Cluster. But you should note that for a production environment, it is not recommended to deploy all replicas on one node, which may decrease the cluster availability. For example,

```bash
kbcli cluster create mycluster --cluster-definition apecloud-mysql --set replicas=3 --topology-keys null --namespace demo
kbcli cluster create apecloud-mysql mycluster \
--mode='raftGroup' \
--pod-anti-affinity='Preferred' \
--tolerations='node-role.kubeblocks.io/data-plane:NoSchedule' \
--topology-keys='null' \
--namespace demo
```

2. Verify whether this cluster is created successfully.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ The termination policy determines how a cluster is deleted.

| **terminationPolicy** | **Deleting Operation** |
|:----------------------|:-------------------------------------------------|
| `DoNotTerminate` | `DoNotTerminate` blocks delete operation. |
| `Halt` | `Halt` deletes Cluster resources like Pods and Services but retains Persistent Volume Claims (PVCs), allowing for data preservation while stopping other operations. Halt policy is deprecated in v0.9.1 and will have same meaning as DoNotTerminate. |
| `Delete` | `Delete` extends the Halt policy by also removing PVCs, leading to a thorough cleanup while removing all persistent data. |
| `WipeOut` | `WipeOut` deletes all Cluster resources, including volume snapshots and backups in external storage. This results in complete data removal and should be used cautiously, especially in non-production environments, to avoid irreversible data loss. |
| `DoNotTerminate` | `DoNotTerminate` prevents deletion of the Cluster. This policy ensures that all resources remain intact. |
| `Delete` | `Delete` deletes Cluster resources like Pods, Services, and Persistent Volume Claims (PVCs), leading to a thorough cleanup while removing all persistent data. |
| `WipeOut` | `WipeOut` is an aggressive policy that deletes all Cluster resources, including volume snapshots and backups in external storage. This results in complete data removal and should be used cautiously, primarily in non-production environments to avoid irreversible data loss. |

To check the termination policy, execute the following command.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_position: 1

# KubeBlocks for ApeCloud MySQL

This tutorial illustrates how to create and manage an ApeCloud MySQL cluster by `kbcli`, `kubectl` or a YAML file. You can find the YAML examples in [the GitHub repository](https://github.com/apecloud/kubeblocks-addons/tree/release-0.9/examples/apecloud-mysql).
This tutorial illustrates how to create and manage an ApeCloud MySQL cluster by `kbcli`, `kubectl` or a YAML file. You can find the YAML examples in [the GitHub repository](https://github.com/apecloud/kubeblocks-addons/tree/main/examples/apecloud-mysql).

* [Introduction](./apecloud-mysql-intro/apecloud-mysql-intro.md)
* [Cluster Management](./cluster-management/create-and-connect-an-apecloud-mysql-cluster.md)
Expand Down
Loading

0 comments on commit 34962e1

Please sign in to comment.