Skip to content

Commit

Permalink
refactor: add some notes and configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
zyy17 committed Nov 5, 2024
1 parent d5f738c commit 00a20e6
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following output may have minor differences depending on the versions of the
## Create a test Kubernetes cluster

:::warning
Don't use the `kind` for production use. It's recommended to use a managed Kubernetes service like [Amazon EKS](https://aws.amazon.com/eks/), [Google GKE](https://cloud.google.com/kubernetes-engine/), or [Azure AKS](https://azure.microsoft.com/en-us/services/kubernetes-service/).
Using `kind` is not recommended for production environments or performance testing. For such use cases, we recommend using cloud-managed Kubernetes services such as [Amazon EKS](https://aws.amazon.com/eks/), [Google GKE](https://cloud.google.com/kubernetes-engine/), or [Azure AKS](https://azure.microsoft.com/en-us/services/kubernetes-service/), or deploying your own production-grade Kubernetes cluster.
:::

There are many ways to create a Kubernetes cluster for testing purposes. In this guide, we will use [kind](https://kind.sigs.k8s.io/docs/user/quick-start/) to create a local Kubernetes cluster. You can skip this step if you want to use the existing Kubernetes cluster.
Expand Down Expand Up @@ -173,8 +173,8 @@ The GreptimeDB Operator will use `greptimedbclusters.greptime.io` and `greptimed
The GreptimeDB cluster requires an etcd cluster for metadata storage. Let's install an etcd cluster using Bitnami's etcd Helm [chart](https://hub.docker.com/r/bitnami/etcd).

```bash
helm install \
etcd oci://registry-1.docker.io/bitnamicharts/etcd \
helm install etcd \
oci://registry-1.docker.io/bitnamicharts/etcd \
--version 10.2.12 \
--set replicaCount=3 \
--set auth.rbac.create=false \
Expand Down Expand Up @@ -300,7 +300,40 @@ The greptimedb-cluster is starting, use `kubectl get pods -n default` to check i
```
</details>
You can check the status of the GreptimeDB cluster:
When the `monitoring` option is enabled, the Helm chart configuration will use `mycluster` and `default` as the default cluster name and namespace.
If you want to modify the default cluster name and namespace, you can create a `values.yaml` file like this:
```yaml
grafana:
datasources:
datasources.yaml:
datasources:
- name: greptimedb-metrics
type: 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
access: proxy
database: public
```
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> \
--set monitoring.enabled=true \
--set grafana.enabled=true \
greptime/greptimedb-cluster \
-f values.yaml \
-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:
```bash
kubectl -n default get greptimedbclusters.greptime.io mycluster
Expand All @@ -314,7 +347,9 @@ mycluster 1 1 1 0 Running v0.9.5 5m12s
```
</details>
You can check the Pods status of the GreptimeDB cluster:
The above command will show the status of the GreptimeDB cluster. When the `PHASE` is `Running`, it means the GreptimeDB cluster has been successfully started.
You also can check the Pods status of the GreptimeDB cluster:
```bash
kubectl -n default get pods
Expand Down Expand Up @@ -366,6 +401,12 @@ 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):
```bash
kubectl -n <namespace> port-forward svc/<cluster>-frontend 4000:4000 4001:4001 4002:4002 4003:4003
```
:::warning
If you want to expose the service to the public, you can use the `kubectl port-forward` command with the `--address` option:
Expand All @@ -388,7 +429,13 @@ You can access the Grafana dashboard by using `kubctl port-forward` the Grafana
kubectl -n default port-forward svc/mycluster-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`:
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):
```bash
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`:
![Grafana Dashboard](/kubernetes-cluster-grafana-dashboard.jpg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ greptimedbstandalones.greptime.io 2024-10-28T08:46:27Z
```
</details>
By default, the GreptimeDB Operator chart will manage the installation and upgrade of the CRDs and the users don't need to manage them manually.
By default, the GreptimeDB Operator chart will manage the installation and upgrade of the CRDs and the users don't need to manage them manually. If you want to know the specific definitions of these two types of CRD, you can refer to the GreptimeDB Operator [API documentation](https://github.com/GreptimeTeam/greptimedb-operator/blob/main/docs/api-references/docs.md).
### Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
## 创建一个测试 Kubernetes 集群

:::warning
不要在生产环境中使用 `kind`建议使用托管的 Kubernetes 服务,如 [Amazon EKS](https://aws.amazon.com/eks/)[Google GKE](https://cloud.google.com/kubernetes-engine/)[Azure AKS](https://azure.microsoft.com/en-us/services/kubernetes-service/)
不建议在生产环境或性能测试中使用 `kind`如有这类需求建议使用公有云托管的 Kubernetes 服务,如 [Amazon EKS](https://aws.amazon.com/eks/)[Google GKE](https://cloud.google.com/kubernetes-engine/)[Azure AKS](https://azure.microsoft.com/en-us/services/kubernetes-service/),或者自行搭建生产级 Kubernetes 集群
:::

目前有很多方法可以创建一个用于测试的 Kubernetes 集群。在本指南中,我们将使用 [kind](https://kind.sigs.k8s.io/docs/user/quick-start/) 来创建一个本地 Kubernetes 集群。如果你想使用已有的 Kubernetes 集群,可以跳过这一步。
Expand Down Expand Up @@ -62,12 +62,22 @@ To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
```
</details>

:::note
中国大陆用户如有网络访问问题,可使用 Greptime 提供的 `kindest/node:v1.27.3` 镜像:

```bash
kind create cluster --image greptime-registry.cn-hangzhou.cr.aliyuncs.com/kindest/node:v1.27.3
```
:::

## 添加 Greptime Helm 仓库

:::note
中国大陆用户如有网络访问问题,可跳过这一步骤并直接参考下一步中使用阿里云 OCI 镜像仓库的方式。采用这一方式将无需手动添加 Helm 仓库。
:::

我们提供了 GreptimeDB Operator 和 GreptimeDB 集群的[官方 Helm 仓库](https://github.com/GreptimeTeam/helm-charts)。你可以通过运行以下命令来添加仓库:

```bash
helm repo add greptime https://greptimeteam.github.io/helm-charts/
helm repo update
Expand Down Expand Up @@ -131,8 +141,8 @@ The greptimedb-operator is starting, use `kubectl get deployments greptimedb-ope

```bash
helm install greptimedb-operator \
--set image.registry=greptime-registry.cn-hangzhou.cr.aliyuncs.com \
oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/greptimedb-operator \
--set image.registry=greptime-registry.cn-hangzhou.cr.aliyuncs.com \
-n greptimedb-admin \
--create-namespace
```
Expand All @@ -157,7 +167,7 @@ kubectl apply -f \
检查 GreptimeDB Operator 的状态:

```bash
kubectl get pods --namespace greptimedb-admin -l app.kubernetes.io/instance=greptimedb-operator
kubectl get pods -n greptimedb-admin -l app.kubernetes.io/instance=greptimedb-operator
```

<details>
Expand Down Expand Up @@ -189,8 +199,8 @@ GreptimeDB Operator 将会使用 `greptimedbclusters.greptime.io` and `greptimed
GreptimeDB 集群需要一个 etcd 集群来存储元数据。让我们使用 Bitnami 的 etcd Helm [chart](https://hub.docker.com/r/bitnami/etcd) 来安装一个 etcd 集群。

```bash
helm install \
etcd oci://registry-1.docker.io/bitnamicharts/etcd \
helm install etcd \
oci://registry-1.docker.io/bitnamicharts/etcd \
--version 10.2.12 \
--set replicaCount=3 \
--set auth.rbac.create=false \
Expand Down Expand Up @@ -261,8 +271,8 @@ etcd-2 1/1 Running 0 2m8s
中国大陆用户如有网络访问问题,可直接使用阿里云 OCI 镜像仓库的方式安装 etcd 集群:
```bash
helm install \
etcd oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/etcd \
helm install etcd \
oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/etcd \
--set image.registry=greptime-registry.cn-hangzhou.cr.aliyuncs.com \
--set image.tag=3.5.12 \
--set replicaCount=3 \
Expand All @@ -276,7 +286,7 @@ helm install \
你可以通过运行以下命令来测试 etcd 集群:
```bash
kubectl --namespace etcd-cluster \
kubectl -n etcd-cluster \
exec etcd-0 -- etcdctl endpoint health \
--endpoints=http://etcd-0.etcd-headless.etcd-cluster.svc.cluster.local:2379,http://etcd-1.etcd-headless.etcd-cluster.svc.cluster.local:2379,http://etcd-2.etcd-headless.etcd-cluster.svc.cluster.local:2379
```
Expand All @@ -294,6 +304,10 @@ http://etcd-2.etcd-headless.etcd-cluster.svc.cluster.local:2379 is healthy: succ
目前我们已经准备好了 GreptimeDB Operator 和 etcd 集群,现在我们可以部署一个带监控集成的最小 GreptimeDB 集群:
:::warning
本文档中的默认配置不适用于生产环境,你应该根据自己的需求调整配置。
:::
```bash
helm install mycluster \
--set monitoring.enabled=true \
Expand All @@ -306,8 +320,8 @@ helm install mycluster \
中国大陆用户如有网络访问问题,可直接使用阿里云 OCI 镜像仓库的方式来安装 GreptimeDB 集群:
```bash
helm install \
mycluster oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/greptimedb-cluster \
helm install mycluster \
oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/greptimedb-cluster \
--set image.registry=greptime-registry.cn-hangzhou.cr.aliyuncs.com \
--set initializer.registry=greptime-registry.cn-hangzhou.cr.aliyuncs.com \
--set grafana.enabled=true \
Expand Down Expand Up @@ -343,7 +357,40 @@ The greptimedb-cluster is starting, use `kubectl get pods -n default` to check i
```
</details>
检查 GreptimeDB 集群的状态:
在启用 `monitoring` 选项时,Helm chart 的配置会默认分别使用 `mycluster``default` 作为集群名和命名空间。
如果你想修改默认的集群名和命名空间,可以创建如下的 `values.yaml` 文件:
```yaml
grafana:
datasources:
datasources.yaml:
datasources:
- name: greptimedb-metrics
type: 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
access: proxy
database: public
```
然后将上面的 `values.yaml` 中的 `<cluster>``<namespace>` 替换为你想要的值,并使用以下命令安装 GreptimeDB 集群(请注意命令中的 `<cluster>``<namespace>` 同样需要替换):
```bash
helm install <cluster> \
--set monitoring.enabled=true \
--set grafana.enabled=true \
greptime/greptimedb-cluster \
-f values.yaml \
-n <namespace>
```
当启动集群安装之后,我们可以用如下命令检查 GreptimeDB 集群的状态。若你使用了不同的集群名和命名空间,可将 `mycluster``default` 替换为你的配置:
```bash
kubectl -n default get greptimedbclusters.greptime.io mycluster
Expand All @@ -357,7 +404,9 @@ mycluster 1 1 1 0 Running v0.9.5 5m12s
```
</details>
你可以检查 GreptimeDB 集群的 Pod 状态:
上面的命令将会显示 GreptimeDB 集群的状态。当 `PHASE``Running` 时,表示 GreptimeDB 集群已经成功启动。
你还可以检查 GreptimeDB 集群的 Pod 状态:
```bash
kubectl -n default get pods
Expand Down Expand Up @@ -405,6 +454,12 @@ Forwarding from [::1]:4003 -> 4003
```
</details>
请注意,当你使用了其他集群名和命名空间时,你可以使用如下命令(请将 `<cluster>``<namespace>` 替换为你的配置):
```bash
kubectl -n <namespace> port-forward svc/<cluster>-frontend 4000:4000 4001:4001 4002:4002 4003:4003
```
:::warning
如果你想将服务暴露给公网访问,可以使用带有 `--address` 选项的 `kubectl port-forward` 命令:
Expand All @@ -427,7 +482,13 @@ 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
```
然后,打开浏览器并访问 `http://localhost:18080` 来访问 Grafana dashboard。默认的用户名和密码是 `admin``gt-operator`
请注意,当你使用了其他集群名和命名空间时,你可以使用如下命令(请将 `<cluster>``<namespace>` 替换为你的配置):
```bash
kubectl -n <namespace> port-forward svc/<cluster>-grafana 18080:80
```
接着打开浏览器并访问 `http://localhost:18080` 来访问 Grafana dashboard。默认的用户名和密码是 `admin``gt-operator`
![Grafana Dashboard](/kubernetes-cluster-grafana-dashboard.jpg)
Expand All @@ -439,6 +500,10 @@ kubectl -n default port-forward svc/mycluster-grafana 18080:80
## 清理
:::danger
清理操作将会删除 GreptimeDB 集群的元数据和数据。请确保在继续操作之前已经备份了数据。
:::
### 停止端口转发
可以使用以下命令停止 GreptimeDB 集群的端口转发:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ greptimedbstandalones.greptime.io 2024-10-28T08:46:27Z
```
</details>
默认情况下,GreptimeDB Operator chart 将管理 CRDs 的安装和升级,用户不需要手动管理它们。
默认情况下,GreptimeDB Operator chart 将管理 CRDs 的安装和升级,用户不需要手动管理它们。如果你想了解这两类 CRD 的具体定义,可参考 GreptimeDB Operator 的 [API 文档](https://github.com/GreptimeTeam/greptimedb-operator/blob/main/docs/api-references/docs.md)。
### 配置
Expand Down

0 comments on commit 00a20e6

Please sign in to comment.