0

Clusterpedia 0.2.0 发布

 2 years ago
source link: http://blog.daocloud.io/8062.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

f3db87f2f62748a5bd00e95f9621ecf0.jpg

Clusterpedia 0.2.0 发布,当前,用户可以使用 Helm 快速部署 Clusterpedia,直接使用 kube config 来接入集群,并新增三个检索功能,以及一些其他功能,为大家提供更优质的多集群资源复杂检索能力。

接下来详细介绍一下 Clusterpedia 0.2.0 的内容,欢迎大家使用和提出建议。

01

使用 Helm 来部署

用户已经可以使用 Helm 来部署 Clusterpedia,我们在上一篇已经为大家详细介绍过了,可以参考:使用 Helm 快速部署 Clusterpedia。

02

使用 Kube config
来接入集群

v0.1.0 时,用户需要分别填写被接入集群的 apiserver 地址,以及访问集群时的认证信息。

apiVersion: cluster.clusterpedia.io/v1alpha2
kind: PediaCluster
metadata:  
name: cluster-example
spec:  apiserver: "https://10.30.43.43:6443"  
caData:  
tokenData:  
certData:  
keyData:  
syncResources: []

图注,非必选。选本句、回车空行。

在 v0.2.0 中 PediaCluster 增加了 spec.kubeconfig 字段,用户可以直接使用 kube config 来接入集群。

首先 base64 集群的 kube config:

$ base64 ./kubeconfig.yaml

然后填充到 PediaCluster 的 spec.kubeconfig 字段中。

apiVersion: cluster.clusterpedia.io/v1alpha2
kind: PediaCluster
metadata: 
 name: cluster-example
spec:  kubeconfig: **base64 kubeconfig** 
 syncResources: []

在使用 kube config 时,不需要填写 spec.apiserver 以及其他认证字段。

需要注意,使用 kubectl get pediacluster 查看接入的集群列表时,APISERVER 不会显示集群地址。

$ kubectl get pediacluster
NAME              APISERVER   VERSION   STATUS
cluster-example               v1.22.2   Healthy

如果需要显示,那么需要额外手动设置 spec.kubeconfig,未来会添加 Mutating Admission Webhook 来解析 kubeconfig 并自动填充 spec.apiserver 字段。

03

新增的
检索功能

通过资源的创建时间来过滤资源

1d04af5c78eeb640dcbe5d7db42bd919.png

创建时间的区间采用左闭右开的规则,since <= creation time < before

时间格式支持 4 种:

  1. Unix 时间戳格式:为了方便使用会根据时间戳的长度来区分单位为 s 还是 ms。10 位时间戳单位为秒,13 位时间戳单位为毫秒。
  2. RFC3339:2006-01-02T15:04:05Z or 2006-01-02T15:04:05+08:00
  3. UTC Date:2006-01-02
  4. UTC Datetime: 2006-01-02 15:04:05
由于 Kube Label Selector 的限制,Search Label 只支持使用 Unix 时间戳和 UTC Data 的格式

URL Query 可以使用四种格式

首先查看一下当前都有哪些资源。

$ kubectl --cluster clusterpedia get pods
CLUSTER           NAME                                                 READY  
 STATUS      RESTARTS       AGE
cluster-example   quickstart-ingress-nginx-admission-create--1-kxlnn   0/1    
 Completed   0              171d
cluster-example   fake-pod-698dfbbd5b-wvtvw                            1/1   
  Running     0              8d
cluster-example   fake-pod-698dfbbd5b-74cjx                            1/1    
 Running     0              21d
cluster-example   fake-pod-698dfbbd5b-tmcw7                            1/1    
 Running     0              8d

我们使用创建时间来过滤资源。

$ kubectl --cluster clusterpedia get pods -l "search.
clusterpedia.io/since=2022-03-20"CLUSTER           NAME                        READY   STATUS    RESTARTS   AGEcluster-example   fake-pod-698dfbbd5b-wvtvw   1/1     Running   0          8dcluster-example   fake-pod-698dfbbd5b-tmcw7   1/1     Running   0          8d$ kubectl --
cluster clusterpedia get pods -l "search.
clusterpedia.io/before=2022-03-20"CLUSTER           NAME                                                 READY   STATUS      RESTARTS       AGEcluster-example   quickstart-ingress-nginx-admission-create--1-kxlnn   0/1     Completed   0              171dcluster-example   fake-pod-698dfbbd5b-74cjx                            1/1     Running     0              21d

使用 Owner Name 检索

在 v0.1.0 时,我们可以指定祖辈或者父辈 Owner UID 来查询资源,不过 Owner UID 使用起来并不方便,毕竟还需要提前得知 Owner 资源的 UID。

在 v0.2.0 版本中,支持直接使用 Owner Name 来查询,并且 Owner 查询由实验性功能进入到正式功能,Search Label 的前缀也由 internalstorage.clusterpedia.io 升级为 search.clusterpedia.io,并且提供了 URL Query。

597c1cc78d1e87a8bf93506b790e92ce.png

如果用户同时指定了 Owner UID 和 Owner Name,那么 Owner Name 会被忽略。

$ kubectl --cluster cluster-example get pods -l \   
 "search.clusterpedia.io/owner-name=fake-pod, \     
search.clusterpedia.io/owner-seniority=1"
CLUSTER           NAME                        READY   STATUS    RESTARTS   AGE
cluster-example   fake-pod-698dfbbd5b-wvtvw   1/1     Running   0          8d
cluster-example   fake-pod-698dfbbd5b-74cjx   1/1     Running   0          21d
cluster-example   fake-pod-698dfbbd5b-tmcw7   1/1     Running   0          8d

另外为了避免某些情况下,owner 资源存在多种类型,我们可以使用 Owner Group Resource 来限制 Owner 的类型。

$ kubectl --cluster cluster-example get pods -l \    
"search.clusterpedia.io/owner-name=fake-pod,\     
search.clusterpedia.io/owner-gr=deployments.apps,\     
search.clusterpedia.io/owner-seniority=1"... some output

根据资源名称的模糊搜索

模糊搜索是一个非常常用的功能,当前暂时只提供了资源名称上的模糊搜索,由于还需要更多功能上的讨论,暂时作为试验性功能。

$ kubectl --cluster clusterpedia get deployments -l "internalstorage.
clusterpedia.io/fuzzy-name=fake"
CLUSTER           NAME       READY   UP-TO-DATE   AVAILABLE   AGE
cluster-example   fake-pod   3/3     3            3           113d

可以使用 in 操作符来指定多个参数,这样可以过滤出名字包含所有模糊字符串的资源。

04

其他功能

在 v0.1.0 中,查询资源列表时,允许返回的剩余的资源数量,这样用户可以通过计算就能得知当前检索添加下的资源总量。

在 v0.2.0 中对该功能进行了强化, 当分页查询的 Offset 参数过大时,ReaminingItemCount 可以为负数,
这样可以保证通过 offset + len(list.items) + list.metadata.remainingItemCount 总是可以计算出正确的资源总量。

05

更新总览

  • 支持使用 Helm 部署 (#53, #125, @calvin0327, @wzshiming)
  • PediaCluster 支持使用 kube config 来接入集群 (#115, @wzshiming)

APIServer

  • 支持通过创建时间的区间来过滤资源 (#113, @cleverhu)
  • 支持根据 Owner 的名字来检索资源,并且 Owner 查询成为 clusterpedia 的正式功能,同时支持 Search Label 和 URL Query (#91, @Iceber)

Default Storage Layer

  • 支持根据资源名称的模糊搜索 (#117, @cleverhu)
  • RemainingItemCount 可以为负数,在 Offset 过大时依然可以使用 offset + len(items) + remainingItemCount 来计算资源总量。(#123, @cleverhu)

Bug Fixes

  • 修复由于不必要的反序列化导致的 cpu 损耗,提升了查询时的性能 (#89, #92, @Iceber)

Deprecation

  • Owner 查询已移动到正式功能,用于 Owner 查询的试验性 Search Label —— internalstorage.clusterpedia.io/owner-name 和 internalstorage.clusterpedia.io/owner-seniority 会在下一个版本被移除 (#91, @Iceber)

欢迎大家下载使用和参与讨论,并在 issue 提出自己的意见和想法。

DaoCloud 公司简介:「DaoCloud 道客」云原生领域的创新领导者,成立于 2014 年底,拥有自主知识产权的核心技术,致力于打造开放的云原生操作系统为企业数字化转型赋能。产品能力覆盖云原生应用的开发、交付、运维全生命周期,并提供公有云、私有云和混合云等多种交付方式。成立迄今,公司已在金融科技、先进制造、智能汽车、零售网点、城市大脑等多个领域深耕,标杆客户包括交通银行、浦发银行、上汽集团、东风汽车、海尔集团、屈臣氏、金拱门(麦当劳)等。目前,公司已完成了 D 轮超亿元融资,被誉为科技领域准独角兽企业。公司在北京、武汉、深圳、成都设立多家分公司及合资公司,总员工人数超过 400 人,是上海市高新技术企业、上海市“科技小巨人”企业和上海市“专精特新”企业,并入选了科创板培育企业名单。

未经允许不得转载:DaoCloud道客博客 » Clusterpedia 0.2.0 发布


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK