iceber / clusterpedia Goto Github PK
View Code? Open in Web Editor NEWThis project forked from clusterpedia-io/clusterpedia
The Encyclopedia of Kubernetes clusters
License: Apache License 2.0
This project forked from clusterpedia-io/clusterpedia
The Encyclopedia of Kubernetes clusters
License: Apache License 2.0
已完成: clusterpedia-io#184
定义并创建 ClusterSyncResources
apiVersion: cluster.clusterpedia.io/v1alpha2
kind: ClusterSyncResources
metadata:
name: base
spec:
syncResources:
- group: ""
resources:
- pods
在 PediaCluster 的 .spec.syncResourcesRefName
字段设置 ClusterSyncResources 的名字
apiVersion: cluster.clusterpedia.io/v1alpha2
kind: PediaCluster
metadata:
name: cluster-example
spec:
apiserver: "https://10.30.43.43:6443"
caData:
tokenData:
certData:
keyData:
syncResourcesRefName: base
issue: clusterpedia-io#185
实现自动发现多云平台纳管的集群,核心就是将代表被纳管集群的 CR 转换为 PediaCluster
我们需要使用两个新的自定义资源:
ClusterImportPolicy 需要定义以下事情:
apiVersion: policy.clusterpedia.io/v1alpha1
kind: ClusterImportPolicy
metadata:
name: karmada
spec:
source:
group: "cluster.karmada.io"
versions: []
resource: clusters
references:
- group: ""
resource: secrets
namespaceTemplate: "{{ .source.spec.secretRef.namespace }}"
nameTemplate: "{{ .source.spec.secretRef.name }}"
key: secret
nameTemplate: 'karmada-{{ .source.metadata.name }}'
template: |
spec:
apiserver: "{{ .source.spec.apiEndpoint }}"
tokenData: "{{ .references.secret.data.token }}"
caData: "{{ .references.secret.data.caBundle }}"
syncResources:
- group: ""
resources:
- "pods"
creationCondition: |
{{ if ne .source.spec.apiEndpoint "" }}
{{ range .source.status.conditions }}
{{ if eq .type "Ready" }}
{{ if eq .status "True" }} true {{ end }}
{{ end }}
{{ end }}
{{ end }}
模版字段额外支持 70 多种模版函数(通过 https://github.com/Masterminds/sprig)
.spec.source
中,定义了需要自动发现的资源类型.spec.references
中,后面的项可以引用前面的项。.spec.nameTemplate
定义创建的 PediaCluster 的名称模版.spec.template
定义了 PediaCluster 创建和更新的资源模版,更新时只更新集群鉴权和认证相关的字段.spec.createCondition
定义了什么时候可以创建 PediaCluster[未实现]
.spec.deletedCondition
定义了什么时候删除 PediaCluster,默认为 source 被删除后同步删除 PediaCluster
后续优化
kubectl get pediaclusterlifecycle
and kubectl get clusterimportlifecycle
printing关于 Collection Resources 的自定义查询有两个方案
groups
和 resources
参数指定一组查询的资源类型kubectl edit collectionresources workloads
或者 kubectl create collectionresources
来修改或者新建 collectionresources$ kubectl get collectionresources
NAME RESOURCES
any *
workloads deployments.apps,daemonsets.apps,statefulsets.apps
kuberesources *,*.admission.k8s.io,*.admissionregistration.k8s.io,*.apiextensions.k8s.io,*.apps,*.authentication.k8s.io,*.authorization.k8s.io,*.autoscaling,*.batch,*.certificates.k8s.io,*.coordination.k8s.io,*.discovery.k8s.io,*.events.k8s.io,*.extensions,*.flowcontrol.apiserver.k8s.io,*.imagepolicy.k8s.io,*.internal.apiserver.k8s.io,*.networking.k8s.io,*.node.k8s.io,*.policy,*.rbac.authorization.k8s.io,*.scheduling.k8s.io,*.storage.k8s.io
$ kubectl get --raw="/apis/clusterpedia.io/v1beta1/collectionresources/workloads?groups=apps,cert-manager.io/v1" | jq
groups
指定一组资源组,以 ,
分隔,可以携带版本。 apps 或者 apps/v1 都可以,自定义资源建议携带组版本resources
指定一组资源,以 ,
分隔,可以携带版本,apps/v1/deployments 或者 apps/deployments 都可以,自定义资源建议携带版本以下版本发布中除了新功能外还包括对已有功能的优化
clusterpedia 控制面中增加新的组件 clusterpedia-collector 模块,并且 collector 接口兼容 Kubernetes OpenAPI, Agent 直接使用 client-go 将资源发送给 collector, 减少开发成本
clusterpedia-collector 支持横向扩容
Agent 模式下,clusterpedia apiserver 无法访问到指定集群,所以通过对接 OpenTelemery 来提供多集群 metrics server
资源 printer columns
,用户可以决定 kubectl get <resource type>
时显示那些字段,在 List 接口中同样可以通过 custom columns 来只获取想要的字段A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.