Skip to content

Commit

Permalink
refactor: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
zyy17 committed Nov 5, 2024
1 parent e4a9a5e commit 66b7e6f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
28 changes: 13 additions & 15 deletions docs/user-guide/deployments/deploy-on-kubernetes/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ The greptimedb-cluster is starting, use `kubectl get pods -n default` to check i
```
</details>
When the `monitoring` option is enabled, the Helm chart configuration will use `mycluster` and `default` as the default cluster name and namespace in grafana datasources configuration. If you want to monitor clusters with a different name or a different namespace, you can create a `values.yaml` file like this:
When the `monitoring` option is enabled, we will deploy a GreptimeDB Standalone instance to store monitoring data like metrics and logs from the cluster. Additionally, we will deploy a [Vector](https://github.com/vectordotdev/vector) sidecar for each pod in the cluster to collect metrics and logs and send them to the GreptimeDB Standalone instance.
When the `grafana` option is enabled, we will deploy a Grafana instance and configure it to use the GreptimeDB Standalone instance as a data source (using both Prometheus and MySQL protocols), allowing us to visualize the GreptimeDB cluster's monitoring data out of the box. By default, Grafana will use `mycluster` and `default` as the cluster name and namespace to create data sources. If you want to monitor clusters with different names or namespaces, you'll need to create different data source configurations based on the cluster names and namespaces. You can create a `values.yaml` file like this:
```yaml
grafana:
Expand All @@ -309,13 +311,13 @@ grafana:
datasources:
- name: greptimedb-metrics
type: prometheus
url: http://<cluster>-monitor-standalone.<namespace>.svc.cluster.local:4000/v1/prometheus
url: http://${cluster}-monitor-standalone.${namespace}.svc.cluster.local:4000/v1/prometheus
access: proxy
isDefault: true
- name: greptimedb-logs
type: mysql
url: <cluster>-monitor-standalone.<namespace>.svc.cluster.local:4002
url: ${cluster}-monitor-standalone.${namespace}.svc.cluster.local:4002
access: proxy
database: public
```
Expand All @@ -326,15 +328,15 @@ The above configuration will create the default datasources for the GreptimeDB c
- `greptimedb-logs`: The logs of the cluster are stored in the standalone monitoring database and exposed in MySQL protocol (`type: mysql`). It uses the `public` database by default;
Then replace `<cluster>` and `<namespace>` with your desired values and install the GreptimeDB cluster using the following command (please note that `<cluster>` and `<namespace>` in the command also need to be replaced):
Then replace `{cluster}` and `${namespace}` with your desired values and install the GreptimeDB cluster using the following command (please note that `{cluster}` and `${namespace}` in the command also need to be replaced):
```bash
helm install <cluster> \
helm install {cluster} \
--set monitoring.enabled=true \
--set grafana.enabled=true \
greptime/greptimedb-cluster \
-f values.yaml \
-n <namespace>
-n ${namespace}
```
When starting the cluster installation, we can check the status of the GreptimeDB cluster with the following command. If you use a different cluster name and namespace, you can replace `mycluster` and `default` with your configuration:
Expand Down Expand Up @@ -371,11 +373,7 @@ mycluster-monitor-standalone-0 1/1 Running 0 6m35s
```
</details>
As you can see, we create a minimum GreptimeDB cluster with 1 frontend, 1 datanode, and 1 metasrv. For more information about the components of a complete GreptimeDB cluster, you can refer to [architecture](/user-guide/concepts/architecture.md).
The cluster metrics and logs will be collected by the [Vector](https://github.com/vectordotdev/vector) sidecar and sent to the GreptimeDB standalone instance (`mycluster-monitor-standalone-0`) for monitoring.
The Grafana dashboard is also deployed to visualize the metrics from the standalone instance.
As you can see, we have created a minimal GreptimeDB cluster consisting of 1 frontend, 1 datanode, and 1 metasrv. For information about the components of a complete GreptimeDB cluster, you can refer to [architecture](/user-guide/concepts/architecture.md). Additionally, we have deployed a standalone GreptimeDB instance (`mycluster-monitor-standalone-0`) for storing monitoring data and a Grafana instance (`mycluster-grafana-675b64786-ktqps`) for visualizing the cluster's monitoring data.
## Explore the GreptimeDB cluster
Expand Down Expand Up @@ -405,10 +403,10 @@ Forwarding from [::1]:4003 -> 4003
```
</details>
Please note that when you use a different cluster name and namespace, you can use the following command (please replace `<cluster>` and `<namespace>` with your configuration):
Please note that when you use a different cluster name and namespace, you can use the following command, and replace `${cluster}` and `${namespace}` with your configuration:
```bash
kubectl -n <namespace> port-forward svc/<cluster>-frontend 4000:4000 4001:4001 4002:4002 4003:4003
kubectl -n ${namespace} port-forward svc/${cluster}-frontend 4000:4000 4001:4001 4002:4002 4003:4003
```
:::warning
Expand All @@ -433,10 +431,10 @@ You can access the Grafana dashboard by using `kubctl port-forward` the Grafana
kubectl -n default port-forward svc/mycluster-grafana 18080:80
```
Please note that when you use a different cluster name and namespace, you can use the following command (please replace `<cluster>` and `<namespace>` with your configuration):
Please note that when you use a different cluster name and namespace, you can use the following command, and replace `${cluster}` and `${namespace}` with your configuration:
```bash
kubectl -n <namespace> port-forward svc/<cluster>-grafana 18080:80
kubectl -n ${namespace} port-forward svc/${cluster}-grafana 18080:80
```
Then open your browser and navigate to `http://localhost:18080` to access the Grafana dashboard. The default username and password are `admin` and `gt-operator`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ helm install mycluster \
--set monitoring.vector.registry=greptime-registry.cn-hangzhou.cr.aliyuncs.com \
-n default
```
如果你使用了不同的集群名称和命名空间,请将 `mycluster``default` 替换为你的配置。
:::
<details>
Expand Down Expand Up @@ -357,7 +359,10 @@ The greptimedb-cluster is starting, use `kubectl get pods -n default` to check i
```
</details>
当启用 `monitoring` 选项时,Helm chart 配置将在 grafana 数据源配置中使用 `mycluster``default` 作为默认的集群名称和命名空间。如果你想要监控具有不同名称或不同命名空间的集群,可以创建一个如下所示的 `values.yaml` 文件:
当启用 `monitoring` 选项时,我们将会部署一个 GreptimeDB Standalone 实例来存储集群的 metrics 和 logs 这类监控数据。同时,我们也会为集群内的每一个 Pod 部署一个 [Vector](https://github.com/vectordotdev/vector) sidecar 来收集集群的 metrics 和 logs,并发送给 GreptimeDB Standalone 实例。
当启用 `grafana` 选项时,我们将会部署一个 Grafana 实例,并配置 Grafana 使用 GreptimeDB Standalone 实例作为数据源(分别使用 Prometheus 和 MySQL 协议),从而我们开箱即可使用 Grafana 来可视化 GreptimeDB 集群的监控数据。默认地,Grafana 将会使用 `mycluster``default` 作为集群名称和命名空间来创建数据源。如果你想要监控具有不同名称或不同命名空间的集群,那就需要基于不同的集群名称和命名空间来创建不同的数据源配置。你可以创建一个如下所示的 `values.yaml` 文件:
```yaml
grafana:
Expand All @@ -366,13 +371,13 @@ grafana:
datasources:
- name: greptimedb-metrics
type: prometheus
url: http://<cluster>-monitor-standalone.<namespace>.svc.cluster.local:4000/v1/prometheus
url: http://${cluster}-monitor-standalone.${namespace}.svc.cluster.local:4000/v1/prometheus
access: proxy
isDefault: true

- name: greptimedb-logs
type: mysql
url: <cluster>-monitor-standalone.<namespace>.svc.cluster.local:4002
url: ${cluster}-monitor-standalone.${namespace}.svc.cluster.local:4002
access: proxy
database: public
```
Expand All @@ -383,18 +388,18 @@ grafana:
- `greptimedb-logs`:集群的日志存储在独立的监控数据库中,并对外暴露为 MySQL 协议(`type: mysql`)。默认使用 `public` 数据库;
然后将上面的 `values.yaml` 中的 `<cluster>``<namespace>` 替换为你想要的值,并使用以下命令安装 GreptimeDB 集群(请注意命令中的 `<cluster>``<namespace>` 同样需要替换)
然后将上面的 `values.yaml` 中的 `${cluster}``${namespace}` 替换为你想要的值,并使用以下命令安装 GreptimeDB 集群:
```bash
helm install <cluster> \
helm install ${cluster} \
--set monitoring.enabled=true \
--set grafana.enabled=true \
greptime/greptimedb-cluster \
-f values.yaml \
-n <namespace>
-n ${namespace}
```
当启动集群安装之后,我们可以用如下命令检查 GreptimeDB 集群的状态。若你使用了不同的集群名和命名空间,可将 `mycluster``default` 替换为你的配置:
当启动集群安装之后,我们可以用如下命令检查 GreptimeDB 集群的状态。若你使用了不同的集群名和命名空间,可将 `default``mycluster` 替换为你的配置:
```bash
kubectl -n default get greptimedbclusters.greptime.io mycluster
Expand Down Expand Up @@ -428,11 +433,7 @@ mycluster-monitor-standalone-0 1/1 Running 0 6m35s
```
</details>
正如你所看到的,我们创建了一个最小的 GreptimeDB 集群,包括 1 个 frontend、1 个 datanode 和 1 个 metasrv。关于一个完整的 GreptimeDB 集群的组成,你可以参考 [architecture](/user-guide/concepts/architecture.md)。
集群的 metrics 和 logs 将会被 [Vector](https://github.com/vectordotdev/vector) sidecar 收集,并发送到一个 GreptimeDB Standalone 实例 (`mycluster-monitor-standalone-0`) 进行存储。
Grafana dashboard 也被部署用于可视化集群的监控。
正如你所看到的,我们创建了一个最小的 GreptimeDB 集群,包括 1 个 frontend、1 个 datanode 和 1 个 metasrv。关于一个完整的 GreptimeDB 集群的组成,你可以参考 [architecture](/user-guide/concepts/architecture.md)。除此之外,我们还部署了一个独立的 GreptimeDB Standalone 实例(`mycluster-monitor-standalone-0`)用以存储监控数据和一个 Grafana 实例(`mycluster-grafana-675b64786-ktqps`)用以可视化集群的监控数据。
## 探索 GreptimeDB 集群
Expand All @@ -458,10 +459,10 @@ Forwarding from [::1]:4003 -> 4003
```
</details>
请注意,当你使用了其他集群名和命名空间时,你可以使用如下命令(请将 `<cluster>``<namespace>` 替换为你的配置
请注意,当你使用了其他集群名和命名空间时,你可以使用如下命令,并将 `${cluster}``${namespace}` 替换为你的配置:
```bash
kubectl -n <namespace> port-forward svc/<cluster>-frontend 4000:4000 4001:4001 4002:4002 4003:4003
kubectl -n ${namespace} port-forward svc/${cluster}-frontend 4000:4000 4001:4001 4002:4002 4003:4003
```
:::warning
Expand All @@ -486,10 +487,10 @@ kubectl -n default port-forward --address 0.0.0.0 svc/mycluster-frontend 4000:40
kubectl -n default port-forward svc/mycluster-grafana 18080:80
```
请注意,当你使用了其他集群名和命名空间时,你可以使用如下命令(请将 `<cluster>``<namespace>` 替换为你的配置
请注意,当你使用了其他集群名和命名空间时,你可以使用如下命令,并将 `${cluster}``${namespace}` 替换为你的配置:
```bash
kubectl -n <namespace> port-forward svc/<cluster>-grafana 18080:80
kubectl -n ${namespace} port-forward svc/${cluster}-grafana 18080:80
```
接着打开浏览器并访问 `http://localhost:18080` 来访问 Grafana dashboard。默认的用户名和密码是 `admin``gt-operator`
Expand Down

0 comments on commit 66b7e6f

Please sign in to comment.