Skip to content

Commit

Permalink
Merge pull request #75 from Iceber/kube-state-metrics
Browse files Browse the repository at this point in the history
add multi-cluster kube_state_metrics
  • Loading branch information
Iceber authored Jul 17, 2023
2 parents 8185527 + 65e95d8 commit 67d441f
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
69 changes: 69 additions & 0 deletions content/en/docs/advanced-features/kube_state_metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: Multi-Cluster kube-state-metrics
weight: 10
---

Clusterpedia provides kube-state-metrics features for multi-cluster resources at a fraction of the cost, providing the same metrics information as [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics), but with the addition of a cluster name label.
```text
kube_deployment_created{cluster="test-14",namespace="clusterpedia-system",deployment="clusterpedia-apiserver"} 1.676557618e+09
```

Since this feature is experimental, you will install Clusterpedia [the standard way first](https://github.com/clusterpedia-io/clusterpedia-helm/tree/main/charts/clusterpedia#clusterpedia).

Once Clusterpedia is installed, we need to update the helm to enable the `multi-cluster kube-state-metrics` feature.
> The kube-state-metrics feature has been merged into [the main branch](https://github.com/clusterpedia-io/clusterpedia) and will be included in `v0.8.0` in the future.
> The feature is included in the ghcr.io/iceber/clusterpedia/clustersynchro-manager:v0.8.0-ksm.0
## Enable Multi-Cluster kube-state-metrics
### Ensure Clusterpedia Chart Version >= v1.8.0
```bash
$ helm repo update clusterpedia
$ helm search clusterpedia
NAME CHART VERSION APP VERSION DESCRIPTION
clusterpedia/clusterpedia 1.8.0 v0.7.0 A Helm chart for Kubernetes
```

### Get the current chart values
```bash
$ helm -n clusterpedia-system get values clusterpedia > values.yaml
```

### Create patch values
```yaml
$ echo "clustersynchroManager:
image:
repository: iceber/clusterpedia/clustersynchro-manager
tag: v0.8.0-ksm.0
kubeStateMetrics:
enable: true
" > patch.yaml
```
### Update Clusterpedia to enable multi-cluster kube-state-metrics.
```bash
$ helm -n clusterpedia-system upgrade -f values.yaml -f patch.yaml clusterpedia clusterpedia/clusterpedia
```
Get clusterpedia kube-state-metrics services
```bash
$ kubectl -n clusterpedia-system get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
clusterpedia-apiserver ClusterIP 10.97.129.238 <none> 443/TCP 150d
clusterpedia-clustersynchro-manager-metrics ClusterIP 10.108.129.32 <none> 8081/TCP 51m
clusterpedia-kube-state-metrics ClusterIP 10.108.130.62 <none> 8080/TCP 43m
clusterpedia-mysql ClusterIP 10.102.38.225 <none> 3306/TCP 150d
clusterpedia-mysql-headless ClusterIP None <none> 3306/TCP 150d
```
For more information on importing clusters and using clusterpedia: [Import Clusters](../../usage/import-clusters)
## Future
Multi-cluster kube-state-metrics is a very interesting feature that removes the need to install a single-cluster version of kube-state-metrics in each cluster, and it handles **the issue of differing resource versions very well.**
There is a lot of discussion about this feature here, feel free to comment!
* [The resource state metrics provide different metrics paths depending on the cluster](https://github.com/clusterpedia-io/clusterpedia/issues/544)
* [Support remote write to send resource metrics data](https://github.com/clusterpedia-io/clusterpedia/issues/545)
* [Support for filtering exposed resource state metrics based on namespace](https://github.com/clusterpedia-io/clusterpedia/issues/546)
* [Support for filtering exposed resource state metrics by cluster labels/annotations](https://github.com/clusterpedia-io/clusterpedia/issues/547)
Also welcome to create [a new issue](https://github.com/clusterpedia-io/clusterpedia/issues/new/choose)
70 changes: 70 additions & 0 deletions content/zh/docs/advanced-features/kube_state_metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: 多集群 kube-state-metrics
weight: 10
---

Clusterpedia 以极小的代价提供了多集群资源的 kube-state-metrics 功能,它提供的指标信息与 [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics) 一致,当然会额外增加了一个集群名称的 label.
```text
kube_deployment_created{cluster="test-14",namespace="clusterpedia-system",deployment="clusterpedia-apiserver"} 1.676557618e+09
```

由于该功能处于试验阶段,所以使用该功能需要先额外通过[标准方式安装 Clusterpedia](https://github.com/clusterpedia-io/clusterpedia-helm/tree/main/charts/clusterpedia#clusterpedia).

Clusterpedia 安装完成后,我们需要更新 helm 来开启 `多集群 kube-state-metrics` 功能。
> 当前 main 分支中已经合并 kube-state-metrics 功能,未来会包含在 `v0.8.0` 中。
> ghcr.io/iceber/clusterpedia/clustersynchro-manager:v0.8.0-ksm.0 镜像中包含该功能呢
## 开启多集群 kube-state-metrics
### 确保 Clusterpedia Chart 版本 >= v1.8.0
```bash
$ helm repo update clusterpedia
$ helm search clusterpedia
NAME CHART VERSION APP VERSION DESCRIPTION
clusterpedia/clusterpedia 1.8.0 v0.7.0 A Helm chart for Kubernetes
```

### 获取当前 chart values
```bash
$ helm -n clusterpedia-system get values clusterpedia > values.yaml
```

### 创建 patch values
```yaml
echo "clustersynchroManager:
image:
repository: iceber/clusterpedia/clustersynchro-manager
tag: v0.8.0-ksm.0
kubeStateMetrics:
enable: true
" > patch.yaml
```
### 更新 Clusterpedia 开启多集群 kube-state-metrics
```bash
$ helm -n clusterpedia-system upgrade -f values.yaml -f patch.yaml clusterpedia clusterpedia/clusterpedia
```
查看 clusterpedia kube-state-metrics services
```bash
$ kubectl -n clusterpedia-system get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
clusterpedia-apiserver ClusterIP 10.97.129.238 <none> 443/TCP 150d
clusterpedia-clustersynchro-manager-metrics ClusterIP 10.108.129.32 <none> 8081/TCP 51m
clusterpedia-kube-state-metrics ClusterIP 10.108.130.62 <none> 8080/TCP 43m
clusterpedia-mysql ClusterIP 10.102.38.225 <none> 3306/TCP 150d
clusterpedia-mysql-headless ClusterIP None <none> 3306/TCP 150d
```
For more information on importing clusters and using clusterpedia: [Import Clusters](../../usage/import-clusters)
## 未来
`多集群 kube-state-metrics` 是一个非常有趣的功能,它可以让你不再需要在每一个集群中安装单集群版本的 kube-state-metrics,并且它可以很好的处理资源版本不同的问题。
这里有很多关于该功能的讨论,欢迎评论
* [The resource state metrics provide different metrics paths depending on the cluster](https://github.com/clusterpedia-io/clusterpedia/issues/544)
* [Support remote write to send resource metrics data](https://github.com/clusterpedia-io/clusterpedia/issues/545)
* [Support for filtering exposed resource state metrics based on namespace](https://github.com/clusterpedia-io/clusterpedia/issues/546)
* [Support for filtering exposed resource state metrics by cluster labels/annotations](https://github.com/clusterpedia-io/clusterpedia/issues/547)
也欢迎创建[新的 issue](https://github.com/clusterpedia-io/clusterpedia/issues/new/choose)

0 comments on commit 67d441f

Please sign in to comment.