Git Product home page Git Product logo

clusterpedia's Introduction

The Encyclopedia of Kubernetes clusters

Clusterpedia

build License Go Report Card Release Artifact Hub CII Best Practices Join Slack channel

This name Clusterpedia is inspired by Wikipedia. It is an encyclopedia of multi-cluster to synchronize, search for, and simply control multi-cluster resources.

Clusterpedia can synchronize resources with multiple clusters and provide more powerful search features on the basis of compatibility with Kubernetes OpenAPI to help you effectively get any multi-cluster resource that you are looking for in a quick and easy way.

The capability of Clusterpedia is not only to search for and view but also simply control resources in the future, just like Wikipedia that supports for editing entries.

Clusterpedia is a Cloud Native Computing Foundation sandbox project.

If you want to join the clusterpedia channel on CNCF slack, please get invite to CNCF slack and then join the #clusterpedia channel.

Why Clusterpedia

Clusterpedia can be deployed as a standalone platform or integrated with Cluster API, Karmada, Clusternet and other multi-cloud platforms

Automatic synchronization of clusters managed by multi-cloud platforms

The clusterpedia can automatically synchronize the resources within the cluster managed by the multi-cloud platform.

Users do not need to maintain Clusterpedia manually, Clusterpedia can work as well as the internal components of the multi-cloud platforms.

Lean More About Interfacing to Multi-Cloud Platforms

More retrieval features and compatibility with Kubernetes OpenAPI

Support for importing Kubernetes 1.10+

Automic conversion of different versions of Kube resources and support for multiple version of resources

  • Even if you import different version of Kube, we can still use the same resource version to retrieve resources

For example, we can use v1, v1beta2, v1beta1 version to retrieve the Deployments resources in different clusters.

Notes: The version of deployments is v1beta1 in Kubernetes 1.10 and it is v1 in Kubernetes 1.24.

$ kubectl get --raw "/apis/clusterpedia.io/v1beta1/resources/apis/apps" | jq
{
  "kind": "APIGroup",
  "apiVersion": "v1",
  "name": "apps",
  "versions": [
    {
      "groupVersion": "apps/v1",
      "version": "v1"
    },
    {
      "groupVersion": "apps/v1beta2",
      "version": "v1beta2"
    },
    {
      "groupVersion": "apps/v1beta1",
      "version": "v1beta1"
    }
  ],
  "preferredVersion": {
    "groupVersion": "apps/v1",
    "version": "v1"
  }
}

A single API can be used to retrieve different types of resources

  • Use Collection Resource to retrieve different types of resources, such as Deployment, DaemonSet, StatefulSet.
$ 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

Diverse policies and intelligent synchronization

Unify the search entry for master clusters and multi-cluster resources

  • Based on Aggregated API, the entry portal for multi-cluster retrieval is the same as that of the master cluster(IP:PORT)

Very low memory usage and weak network optimization

  • Optimized caches used by informer, so the memory usage is very low for resource synchronization.
  • Automatic start/stop synchronization based on cluster health status

High availability

No dependency on specific storage components

Clusterpedia does not care about storage components and uses the storage layer to attach specific storage components, and will also add storage layers for graph databases and ES in the future

Architecture

The architecture consists of four parts:
  • Clusterpedia APIServer: Register to Kubernetes APIServer by the means of Aggregated API and provide services through a unified entrance
  • ClusterSynchro Manager: Manage the cluster synchro that is used to synchronize cluster resources
  • Storage Layer: Connect with a specific storage component and then register to Clusterpedia APIServer and ClusterSynchro Manager via a storage layer interface
  • Storage Component: A specific storage facility such as MySQL, PostgreSQL, Redis or other Graph Databases

In addition, Clusterpedia will use the Custom Resource - PediaCluster to implement cluster authentication and configure resources for synchronization.

Clusterpedia also provides a Default Storage Layer that can connect with MySQL and PostgreSQL.

Clusterpedia does not care about the specific storage components used by users, you can choose or implement the storage layer according to your own needs, and then register the storage layer in Clusterpedia as a plug-in


Search Label and URL Query

Role Search label key URL query
Filter cluster names search.clusterpedia.io/clusters clusters
Filter namespaces search.clusterpedia.io/namespaces namespaces
Filter resource names search.clusterpedia.io/names names
Fuzzy Search by resource name internalstorage.clusterpedia.io/fuzzy-name -
Since creation time search.clusterpedia.io/since since
Before creation time search.clusterpedia.io/before before
Specified Owner UID search.clusterpedia.io/owner-uid ownerUID
Specified Owner Seniority search.clusterpedia.io/owner-seniority ownerSeniority
Specified Owner Name search.clusterpedia.io/owner-name ownerName
Specified Owner Group Resource search.clusterpedia.io/owner-gr ownerGR
Order by fields search.clusterpedia.io/orderby orderby
Set page size search.clusterpedia.io/size limit
Set page offset search.clusterpedia.io/offset continue
Response include Continue search.clusterpedia.io/with-continue withContinue
Response include remaining count search.clusterpedia.io/with-remaining-count withRemainingCount
Custom Where SQL - whereSQL
Get only the metadata of the collection resource - onlyMetadata
Specify the groups of any collectionresource - groups
Specify the resources of any collectionresource - resources

Both Search Labels and URL Query support same operators as Label Selector:

  • exist, not exist
  • =, ==, !=
  • in, notin

More information about Search Conditions, Label Selector and Field Selector

Usage Samples

You can search for resources configured in PediaCluster, Clusterpedia supports two types of resource search:

$ kubectl api-resources | grep clusterpedia.io
collectionresources     clusterpedia.io/v1beta1  false   CollectionResource
resources               clusterpedia.io/v1beta1  false   Resources

Use a compatible way with Kubernetes OpenAPI

It is possible to search resources via URL, but using kubectl may be more convenient if you configured the cluster shortcuts for kubectl.

We can use kubectl --cluster <cluster name> to specify the cluster, if <cluster name> is clusterpedia, it meas it is a multi-cluster search operation.

First check which resources are synchronized. We cannot find a resource until it is properly synchronized:

$ kubectl --cluster clusterpedia api-resources
NAME                  SHORTNAMES   APIVERSION                     NAMESPACED   KIND
configmaps            cm           v1                             true         ConfigMap
events                ev           v1                             true         Event
namespaces            ns           v1                             false        Namespace
nodes                 no           v1                             false        Node
pods                  po           v1                             true         Pod
services              svc          v1                             true         Service
daemonsets            ds           apps/v1                        true         DaemonSet
deployments           deploy       apps/v1                        true         Deployment
replicasets           rs           apps/v1                        true         ReplicaSet
statefulsets          sts          apps/v1                        true         StatefulSet
cronjobs              cj           batch/v1                       true         CronJob
jobs                               batch/v1                       true         Job
clusters                           cluster.kpanda.io/v1alpha1     false        Cluster
ingressclasses                     networking.k8s.io/v1           false        IngressClass
ingresses             ing          networking.k8s.io/v1           true         Ingress
clusterrolebindings                rbac.authorization.k8s.io/v1   false        ClusterRoleBinding
clusterroles                       rbac.authorization.k8s.io/v1   false        ClusterRole
roles                              rbac.authorization.k8s.io/v1   true         Role

$ kubectl --cluster cluster-1 api-resources
...

Search in Multiple Clusters

Usage of multi-cluster search in documents

Get deployments in the kube-system namespace of all clusters:

$ kubectl --cluster clusterpedia get deployments -n kube-system
CLUSTER     NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
cluster-1   coredns                   2/2     2            2           68d
cluster-2   calico-kube-controllers   1/1     1            1           64d
cluster-2   coredns                   2/2     2            2           64d

Get deployments in the two namespaces kube-system and default of all clusters:

$ kubectl --cluster clusterpedia get deployments -A -l "search.clusterpedia.io/namespaces in (kube-system, default)"
NAMESPACE     CLUSTER     NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
kube-system   cluster-1   coredns                   2/2     2            2           68d
kube-system   cluster-2   calico-kube-controllers   1/1     1            1           64d
kube-system   cluster-2   coredns                   2/2     2            2           64d
default       cluster-2   dd-airflow-scheduler      0/1     1            0           54d
default       cluster-2   dd-airflow-web            0/1     1            0           54d
default       cluster-2   hello-world-server        1/1     1            1           27d
default       cluster-2   openldap                  1/1     1            1           41d
default       cluster-2   phpldapadmin              1/1     1            1           41d

Get deployments in the kube-system and default namespaces in cluster-1 and cluster-2:

$ kubectl --cluster clusterpedia get deployments -A -l "search.clusterpedia.io/clusters in (cluster-1, cluster-2),\
     search.clusterpedia.io/namespaces in (kube-system,default)"
NAMESPACE     CLUSTER     NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
kube-system   cluster-1   coredns                   2/2     2            2           68d
kube-system   cluster-2   calico-kube-controllers   1/1     1            1           64d
kube-system   cluster-2   coredns                   2/2     2            2           64d
default       cluster-2   dd-airflow-scheduler      0/1     1            0           54d
default       cluster-2   dd-airflow-web            0/1     1            0           54d
default       cluster-2   hello-world-server        1/1     1            1           27d
default       cluster-2   openldap                  1/1     1            1           41d
default       cluster-2   phpldapadmin              1/1     1            1           41d

Get deployments in the kube-system and default namespaces in cluster-1 and cluster-2:

$ kubectl --cluster clusterpedia get deployments -A -l "search.clusterpedia.io/clusters in (cluster-1, cluster-2),\
    search.clusterpedia.io/namespaces in (kube-system,default),\
    search.clusterpedia.io/orderby=name"
NAMESPACE     CLUSTER     NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
kube-system   cluster-2   calico-kube-controllers   1/1     1            1           64d
kube-system   cluster-1   coredns                   2/2     2            2           68d
kube-system   cluster-2   coredns                   2/2     2            2           64d
default       cluster-2   dd-airflow-scheduler      0/1     1            0           54d
default       cluster-2   dd-airflow-web            0/1     1            0           54d
default       cluster-2   hello-world-server        1/1     1            1           27d
default       cluster-2   openldap                  1/1     1            1           41d
default       cluster-2   phpldapadmin              1/1     1            1           41d

Search a specific cluster

Usage of specified cluster search in documents

If you want to search a specific cluster for any resource therein, you can add --cluster to specify the cluster name:

$ kubectl --cluster cluster-1 get deployments -A
NAMESPACE                           CLUSTER     NAME                                            READY   UP-TO-DATE   AVAILABLE   AGE
calico-apiserver                    cluster-1   calico-apiserver                                1/1     1            1           68d
calico-system                       cluster-1   calico-kube-controllers                         1/1     1            1           68d
calico-system                       cluster-1   calico-typha                                    1/1     1            1           68d
capi-system                         cluster-1   capi-controller-manager                         1/1     1            1           42d
capi-kubeadm-bootstrap-system       cluster-1   capi-kubeadm-bootstrap-controller-manager       1/1     1            1           42d
capi-kubeadm-control-plane-system   cluster-1   capi-kubeadm-control-plane-controller-manager   1/1     1            1           42d
capv-system                         cluster-1   capv-controller-manager                         1/1     1            1           42d
cert-manager                        cluster-1   cert-manager                                    1/1     1            1           42d
cert-manager                        cluster-1   cert-manager-cainjector                         1/1     1            1           42d
cert-manager                        cluster-1   cert-manager-webhook                            1/1     1            1           42d
clusterpedia-system                 cluster-1   clusterpedia-apiserver                          1/1     1            1           27m
clusterpedia-system                 cluster-1   clusterpedia-clustersynchro-manager             1/1     1            1           27m
clusterpedia-system                 cluster-1   clusterpedia-internalstorage-mysql              1/1     1            1           29m
kube-system                         cluster-1   coredns                                         2/2     2            2           68d
tigera-operator                     cluster-1   tigera-operator                                 1/1     1            1           68d

Except for search.clusterpedia.io/clusters, the support for other complex queries is same as that for multi-cluster search.

If you want to learn about the details of a resource, you need to specify which cluster it is:

$ kubectl --cluster cluster-1 -n kube-system get deployments coredns -o wide
CLUSTER     NAME      READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES                                                   SELECTOR
cluster-1   coredns   2/2     2            2           68d   coredns      registry.aliyuncs.com/google_containers/coredns:v1.8.4   k8s-app=kube-dns

Find the related pods by the name of the deployment

First view the deployments in default namespace

$ kubectl --cluster cluster-1 get deployments
NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
fake-pod                  3/3     3            3           104d
test-controller-manager   0/0     0            0           7d21h

Use owner-name to specify Owner Name and use owner-seniority to promote the Owner's seniority.

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

Lean More About Search by Parent or Ancestor Owner

Clusterpedia can also perform more advanced aggregation of resources. For example, you can use Collection Resource to get a set of different resources at once.

Let's first check which Collection Resource currently Clusterpedia supports:

$ 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

By getting workloads, you can get a set of resources aggregated by deployments, daemonsets, and statefulsets, and Collection Resource also supports for all complex queries.

kubectl get collectionresources workloads will get the corresponding resources of all namespaces in all clusters by default:

$ kubectl get collectionresources workloads
CLUSTER     GROUP   VERSION   KIND         NAMESPACE                     NAME                                          AGE
cluster-1   apps    v1        DaemonSet    kube-system                   vsphere-cloud-controller-manager              63d
cluster-2   apps    v1        Deployment   kube-system                   calico-kube-controllers                       109d
cluster-2   apps    v1        Deployment   kube-system                   coredns-coredns                               109d

Add the collection of Daemonset in cluster-1 and some of the above output is cut out

Due to the limitation of kubectl, you cannot use complex queries in kubectl and can only be queried by URL Query.

Lean More

Proposals

Perform more complex control over resources

In addition to resource search, similar to Wikipedia, Clusterpedia should also have simple capability of resource control, such as watch, create, delete, update, and more.

In fact, a write action is implemented by double write + warning response.

We will discuss this feature and decide whether we should implement it according to the community needs

Notes

Multi-cluster network connectivity

Clusterpedia does not actually solve the problem of network connectivity in a multi-cluster environment. You can use tools such as tower to connect and access sub-clusters, or use submariner or skupper to solve cross-cluster network problems.

Contact

If you have any question, feel free to reach out to us in the following ways:

If you want to join the clusterpedia channel on CNCF slack, please get invite to CNCF slack and then join the #clusterpedia channel.

Contributors

Made with contrib.rocks.

License

Copyright 2023 the Clusterpedia Authors. All rights reserved.

Licensed under the Apache License, Version 2.0.

clusterpedia's People

Contributors

27149chen avatar autsu avatar calvin0327 avatar carlory avatar dependabot[bot] avatar duanmengkk avatar hanweisen avatar huiwq1990 avatar iceber avatar kerthcet avatar khareyash05 avatar kuangcheng66 avatar kubekyrie avatar lengrongfu avatar nekomeowww avatar one7live avatar piotrlewandowski323 avatar qiuming520 avatar rokkiter avatar rulixu avatar scydas avatar tanryberdi avatar wawa0210 avatar windsonsea avatar wlp1153468871 avatar wuyingjun-lucky avatar wzshiming avatar xyz2277 avatar yankay avatar ycsk02 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clusterpedia's Issues

License copyright need to be updated

What would you like to be added?

I the License file, the copyright is:
Copyright [yyyy] [name of copyright owner]

suggest to change the license copyright to correct one.

Why is this needed?

perfesional

provide a clusterpedia client to make it easier to use

  1. Clusterpedia uses LabelSelector to filter data, but you need to manually build the Options object
  2. We need to use a more native way to call, like client-Go
  3. You only need to provide akubeconfig to get the clientset of client-go

Here's a project to solve the above problem.

Welcome to discuss it here👏

BUG:Couldn't parse request

When using fieldselector, the log will report an error: "Couldn't parse request" err="invalid selector: 'involvedObject.uid in xxx"
The detail is below:
image

Support for searching resources by owner

It is difficult to search for resources by their owner relationships in kubernetes.
clusterpedia will first introduce this experimental feature in internalstorage.

There are two types of owner functions.

  • Query based on the owner's UID
  • Query by owner's name, and support for setting the owner's GVR

In addition, owner filtering supports the ability to raise the seniority to meet the function of ancestor query.


Based on the above features, we plan to add four labels to the internalstorage first:

  • internalstorage.clusterpedia.io/owner-uid
  • internalstorage.clusterpedia.io/owner-name
  • internalstorage.clusterpedia.io/owner-gvr
  • internalstorage.clusterpedia.io/owner-seniority

Experimental function, the url query is not available for now

internalstorage search and sql examples

search pods base on the UID of the owner, label selector is
internalstorage.clusterpedia.io/owner-uid=018442f8-8e14-11eb-9f9e-0242ac130002

SELECT * FROM `resources` WHERE `group` = "" AND `version` = "v1" AND `resource` = "pods" AND `cluster` = "cluster-dce3" AND \
    owner_uid  = "018442f8-8e14-11eb-9f9e-0242ac130002"

search pods based on the UID of the grandfather owner, label selector is
internalstorage.clusterpedia.io/owner-uid=018442f8-8e14-11eb-9f9e-0242ac130002,internalstorage.clusterpedia.io/owner-seniority=1

SELECT * FROM `resources` WHERE `group` = "" AND `version` = "v1" AND `resource` = "pods" AND `cluster` = "cluster-dce3" AND \
        owner_uid IN (SELECT `uid` FROM `resources` WHERE `cluster` = "cluster-dce3" AND owner_uid = "018442f8-8e14-11eb-9f9e-0242ac130002")

An owning object must be in the same namespace as the dependent, or be cluster-scoped.
search pods based on the name of the grandfather owner, label selecttor is
internalstorage.clusterpedia.io/owner-name=dmp-eureka-enhance-1,internalstorage.clusterpedia.io/owner-seniority=1

SELECT * FROM `resources` WHERE `group` = "" AND `version` = "v1" AND `resource` = "pods" AND `cluster` = "cluster-dce3" AND \
    owner_uid IN (SELECT `uid` FROM `resources` WHERE `cluster` = "cluster-dce3" AND \
        owner_uid IN (SELECT `uid` FROM `resources` WHERE `cluster` = "cluster-dce3" AND `name` = "dmp-eureka-enhance-1" AND `namespace` = "dmp"))

update the status of the `pediacluster` if the creation of cluster synchro fails

The cluster synchro of pediacluster may fail to be. created due to many reasons, such as network problems, or authentication configuration....

Clusterpedia need to update the specific information to pediacluster's Conditions
eg.

status:
  conditions:
  - type: ClusterSynchro
     status: "False"
     reason: "InitialFailed"
     message: "some error message"
  - message: ""
    reason: Pending
    status: "False"
    type: Ready

Support filter by creation time

What would you like to be added?

Support fuzzy query through the name of the resource and the range of creation time.

Why is this needed?

This is commonly used in daily use. And it is convenient for our development and operation and maintenance personnel

Support for fetching cluster authentication information from other resources

What would you like to be added?

PdiaCluster can directly reference fields from existing resources for cluster validation.

eg.

spec:
  apiserver: https://10.6.100.100:6443
  caRef:
    apiVersion: v1
    kind: Configmap
    name: cluster-1
    fieldPath: ".data.ca"

Why is this needed?

Currently we need to fill caData, tokenData and other information in the PediaCluster,
but often these information may already exist in other resources,
it would be very convenient if we can get the authentication information by referring to the fields of these resources.

Support find Deployment/StatefulSet/DaemonSet related to pods

What would you like to be added?

Support find out which Deploy/StatefulSet/DaemonSet a pod belongs to.

Why is this needed?

We would like to have a pod list related to a specific service, and the workload(deploy/statefulset/daemonset) related to the pod. Of course we can get the related workloads with the service selector, but we can only get pods and workloads separately, we can't tell directly which workload one pod belongs to.

Support wildcard (like "*") for resources to sync

What would you like to be added?

Support wildcard (like "*") for resources to sync, in the following format:

# all resources in all groups
syncResources:
- group: "*"
  resources:
  - "*"
# all resources in group apps
syncResources:
- group: "apps"
  resources:
  - "*"

Why is this needed?

we need to list all resources in a cluster dynamically (the resource types might be changing)

support list field filtering

support list field filtering

kubectl get po --field-selector="spec.containers[].name!=container1"

kubectl get po --field-selector="spec.containers[].name == container1"

kubectl get po --field-selector="spec.containers[1].name in (container1,container2)"

PostgreSQL

SELECT *
FROM "resources",
     jsonb_array_elements(object -> 'status' -> 'conditions') as obj
WHERE "group" = 'apps'
  AND "resource" = 'deployments'
  AND "version" = 'v1'
  AND obj ->> 'status' = 'True'
ORDER BY namespace, name
LIMIT 10;

MySQL

SELECT *
FROM resources
WHERE `group` = 'apps'
  AND resource = 'deployments'
  AND version = 'v1'
  AND json_contains(object, '{"status": "True"}', '$.status.conditions')
ORDER BY namespace, name
LIMIT 10;

clusterpedia的文档中,关于指定集群的介绍中,后面多了个双引号"

What happened?

指定集群也可以使用 --cluster 来指定

文档最后面多了个"

kubectl --cluster cluster-1 get deployments"

What did you expect to happen?

修改文档,去掉"

How can we reproduce it (as minimally and precisely as possible)?

文档地址:https://clusterpedia.io/zh-cn/docs/usage/search/multi-cluster/

在指定集群的说明里面

指定集群也可以使用 --cluster 来指定
kubectl --cluster cluster-1 get deployments"

Anything else we need to know?

No response

Clusterpedia Version

# replace the pod name of clusterpedia apiserver
$ kubectl -n clusterpedia-system exec {clusterpedia-apiserver-pod-name} -- apiserver --version=raw
# paste output here

# replace the pod name of clusterpedia clustersynchro-manager
$ kubectl -n clusterpedia-system exec {clustersynchro-manager-pod-name} -- clustersynchro-manager --version=raw
# paste output here

Host Kubernetes version

$ kubectl version
# paste output here

Support for more complex field selector filtering

The current filter selector supports filtering on fields and values (eg. --filter-selector="spec.replicas=1"), but in some cases we need to compare two fields within a resource.
eg. --field-selector="spec.replicas == .status.readyReplicas"

Currently, when comparing between two fields, it looks like it needs to support only == and !=.
There is also the question of how to better distinguish between field comparisons and field-value comparisons.

The internalstorage allows passing a piece of SQL to support more flexible query requirements

What would you like to be added?

Many complex search queries are currently available, such as field selector and search by owner, but sometimes users have more customizable query needs .

To make the query more powerful, the plan wants to add an exclusive query feature to internalstorage that supports users passing a piece of SQL and then splicing the user's SQL after the WHERE.

Of course, in order to be compatible with the generic Search Label, which is still available, the SQL will be spliced after the sql according to the Search Label, but before the ORDER BY.

SELECT objects WHERE group='apps' AND version='v1' AND resource='deployments' AND <user sql> ORDER BY `id`

There are two current questions that need to be resolved

  • How to prevent the injection of the passed SQL string
  • How to be compatible with the Kubernetes API, after all, Label Selector's value checking is rather strict

Also the different syntax between postgres and mysql may need to be handled by the user depending on the storage component they choose .
The clusterpedia does not handle the compatibility of SQL pieces in different storage components.

However, the final generated SQL may be carried in the response header to allow the user to know the SQL statement

Field pruning is also supported in the `clusterpedia apiserver`

The clustersynchro prunes fields based on feature gate when storing resources.
issue: support for pruning manageFields and last-applied-configuration fields
pr: prune managedFields and last-applied-configuration

Since the managedFields field is typically used very infrequently in resource searches, pruning prior to storage can also reduce the strain on storage and data transfer.

However, this may result in inconsistencies between the stored resources and the resource data in the member clusters.

Considering whether the clusterpedia apiserver should also support pruning to ensure that the complete data is stored and then pruned when the data is returned

When searching by specifying a resource name through clusterpedia, the CLUSTER-IP of the svc searched out is None, and the fuzzy search is the same problem

What happened?

Search svc directly, service-nodeport has CLUSTER-IP

[root@dce-10-6-215-215 ~]# kubectl get svc -n zouzou
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service-clusterip ClusterIP 172.31.88.88 8080/TCP 4h44m
service-headliness ClusterIP None 9090/TCP 4h44m
service-nodeport NodePort 172.31.132.180 8888:30033/TCP 4h44m

By specifying a name search in clusterpedia, the cluster IP is not searched

[root@dce-10-6-215-215 ~]# kubectl --cluster clusterpedia get svc -n zouzou -l "search.clusterpedia.io/names=service-nodeport"
CLUSTER NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cluster-215-215 service-nodeport NodePort 8888:30033/TCP 4h44m

image

What did you expect to happen?

SVC searched through clusterpedia also shows CLUSTER-IP

How can we reproduce it (as minimally and precisely as possible)?

[root@dce-10-6-215-215 ~]# kubectl get svc -n zouzou
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service-clusterip ClusterIP 172.31.88.88 8080/TCP 4h44m
service-headliness ClusterIP None 9090/TCP 4h44m
service-nodeport NodePort 172.31.132.180 8888:30033/TCP 4h44m
[root@dce-10-6-215-215 ~]# kubectl --cluster clusterpedia get svc -n zouzou -l "search.clusterpedia.io/names=service-nodeport"
CLUSTER NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cluster-215-215 service-nodeport NodePort 8888:30033/TCP 4h44m

Anything else we need to know?

No response

Clusterpedia Version

# replace the pod name of clusterpedia apiserver
$ kubectl -n clusterpedia-system exec {clusterpedia-apiserver-pod-name} -- apiserver --version=raw
# paste output here

# replace the pod name of clusterpedia clustersynchro-manager
$ kubectl -n clusterpedia-system exec {clustersynchro-manager-pod-name} -- clustersynchro-manager --version=raw
# paste output here

Host Kubernetes version

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"1f3e19b7beb1cc0110255668c4238ed63dadb7ad", GitTreeState:"clean", BuildDate:"2021-06-16T12:58:51Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"7c28a83e67cb506f9df948d7b23698f8f9c279b8", GitTreeState:"clean", BuildDate:"2021-07-15T08:58:53Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

use the template to configure the pediaCluster resource

What would you like to be added?

In these cases, our experience is very unfriendly:

  • when we need to synchronize multiple clusters at once, we need to populate a large amount of resource information, including very basic resources. e.g: pod, node, deployment
  • if you want to add or delete multiple pediaCluster synchronization resources at the same time

we can use a resource template, when we modify the template, all pediaCluster in the cluster will change dynamically. Exemptions can be used for pediaCluster that needs to be excluded.

Why is this needed?

We can more easily modify all pediaCluster resources in the cluster.

When we install clusterpedia, it restarts for more than 5 times

What happened?

企业微信截图_16454971838462

When we install clusterpedia, it restarts for more than 5 times

What did you expect to happen?

The Clusterpedia not restart, it wait for mysql ready.

How can we reproduce it (as minimally and precisely as possible)?

Install Clusterpeida using Kpanda

Anything else we need to know?

We can use initContainer to check mysql ready. Eg:

Clusterpedia Version

# replace the pod name of clusterpedia apiserver
$ kubectl -n clusterpedia-system exec {clusterpedia-apiserver-pod-name} -- apiserver --version=raw
# paste output here

# replace the pod name of clusterpedia clustersynchro-manager
$ kubectl -n clusterpedia-system exec {clustersynchro-manager-pod-name} -- clustersynchro-manager --version=raw
# paste output here

Host Kubernetes version

$ kubectl version
# paste output here

If the resource field value is a numeric value, then the FieldSelector does not work

Storage Component: mysql

kubectl --cluster clusterpedia get deploy --field-selector="status.availableReplicas==1" -A

The sql generated by the sql builder is

SELECT * FROM `resources` WHERE `group` = 'apps' AND `resource` = 'deployments' AND `version` = 'v1' AND cluster = 'test-cluster-2' AND namespace = 'default' AND \
     JSON_EXTRACT(`object`,'$."status"."availableReplicas"') == '1' LIMIT 500

In this case, only if the field value is the string '1'/"1" will be searched for.
For example, this will work:

kubectl --cluster pedia get deploy --field-selector="metadata.annotations['deployment.kubernetes.io/revision']=1" 

resources:

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"

the CRD file is missing from the deploy directory

What would you like to be added?

If we deploy Clusterpedia using kubectl apply instead of helm, having to find the CRD files from the /charts/_crd/ directory would be a hassle.

We can soft-link the files to the /deploy directory.

Why is this needed?

Be more friendly to deploy Clusterpedia.

Clusterpedia 分页的时候不能根据 namespace 进行分页

What happened?

查询 ns 的时候,限制了条数为 2,进行查询的时候,报错

[root@dce-10-6-215-215 pod-dir]# kubectl --cluster cluster-example get namespace --chunk-size 2
error: the server doesn't have a resource type "namespace"

What did you expect to happen?

可以查询出 ns,并且返回两条数据

How can we reproduce it (as minimally and precisely as possible)?

kubectl --cluster cluster-example get namespace --chunk-size 2

Anything else we need to know?

No response

Clusterpedia Version

# replace the pod name of clusterpedia apiserver
$ kubectl -n clusterpedia-system exec {clusterpedia-apiserver-pod-name} -- apiserver --version=raw
# paste output here

# replace the pod name of clusterpedia clustersynchro-manager
$ kubectl -n clusterpedia-system exec {clustersynchro-manager-pod-name} -- clustersynchro-manager --version=raw
# paste output here

Host Kubernetes version

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"1f3e19b7beb1cc0110255668c4238ed63dadb7ad", GitTreeState:"clean", BuildDate:"2021-06-16T12:58:51Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"7c28a83e67cb506f9df948d7b23698f8f9c279b8", GitTreeState:"clean", BuildDate:"2021-07-15T08:58:53Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

Support for cluster authentication via kubeconfig

What would you like to be added?

Use kubeconfig directly, instead of filling in ca, cert, key, etc. separately in PediaCluster

Why is this needed?

Using kubeconfig will make the creation of pediacluster much easier.

Add doc to explain scenario of how clusterpedia can help

What would you like to be added?

The Features List can not directly make people to adopt it.

To a man with a hammer, everything looks like a nail.

Now we have the hammer, but how to promote to the world more effectively , so those nails can find this hammer?

  1. SOE maybe one way. Maybe you can describe as many as possible scenario ,which this hammer can help .
  2. Treat the project as a product, do everything those product manager will do : analysis and advocation ..etc

Just my two cents.
The only "nail" I can figure out is the tools acting as cluster-gateway like PaaS. But I believe this hammer could fit more nail.

Why is this needed?

as above.

When sorting the resource_version field in the cluster, the result is wrong

What happened?

wecom-temp-6481f3f543fe2366435429f32712a5ba

wecom-temp-af951f2228022fa10d9553e247e0b89e

What did you expect to happen?

When sorting the resource_version field in the cluster, the query results are correct

How can we reproduce it (as minimally and precisely as possible)?

kubectl --cluster clusterpedia get pods -l "search.clusterpedia.io/orderby in (resource_version_desc)"
kubectl --cluster clusterpedia get pods -l "search.clusterpedia.io/orderby in (resource_version)"

Anything else we need to know?

No response

Clusterpedia Version

# replace the pod name of clusterpedia apiserver
$ kubectl -n clusterpedia-system exec {clusterpedia-apiserver-pod-name} -- apiserver --version=raw
# paste output here

# replace the pod name of clusterpedia clustersynchro-manager
$ kubectl -n clusterpedia-system exec {clustersynchro-manager-pod-name} -- clustersynchro-manager --version=raw
# paste output here

Host Kubernetes version

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"1f3e19b7beb1cc0110255668c4238ed63dadb7ad", GitTreeState:"clean", BuildDate:"2021-06-16T12:58:51Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"7c28a83e67cb506f9df948d7b23698f8f9c279b8", GitTreeState:"clean", BuildDate:"2021-07-15T08:58:53Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

support for pruning `manageFields` and `last-applied-configuration` fields

Server-Side Apply stores field management in the manageFields, which may not be useful during resource search.
This field needs to be pruned according to the user's needs.

The kubectl.kubernetes.io/last-applied-configuration annotation also requires a feature gate to be provide to prune.

kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "5"
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"cluster-autoscaler"},"name":"poc-autoscaler","namespace":"default"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"cluster-autoscaler"}},"template":{"metadata":{"labels":{"app":"cluster-autoscaler"}},"spec":{"containers":[{"args":["--cloud-provider=clusterapi","--kubeconfig=/etc/kubeconfig/value","--clusterapi-cloud-config-authoritative","--node-group-auto-discovery=clusterapi:clusterName=poc"],"command":["/cluster-autoscaler"],"image":"daocloud.io/daocloud/cluster-autoscaler:v1.20.1","name":"cluster-autoscaler","volumeMounts":[{"mountPath":"/etc/kubeconfig","name":"kubeconfig"}]}],"serviceAccountName":"cluster-autoscaler-management","terminationGracePeriodSeconds":10,"tolerations":[{"effect":"NoSchedule","key":"node-role.kubernetes.io/master"}],"volumes":[{"name":"kubeconfig","secret":{"secretName":"poc-kubeconfig"}}]}}}}

Frequent cluster status updates

When updating the cluster status, DeepEqual will be called first to compare the cluster status to see if it is the same, and if it is, the update will be skipped.

func (manager *Manager) UpdateClusterStatus(ctx context.Context, name string, status *clustersv1alpha1.ClusterStatus) error {
cluster, err := manager.clusterlister.Get(name)
if err != nil {
return err
}
if equality.Semantic.DeepEqual(cluster.Status, status) {
return nil
}

However, there are now three places where the cluster status will always be unequal:

  1. cluster.Status is not ptr, but status is ptr
  2. ClusterGroupStatus.Resources is not sorted.
    groupStatus.Resources = append(groupStatus.Resources, *resourceStatus)
  3. metav1.Now() is too precise, and should use the metav1.Now().Rfc3339Copy()

helm: If the release name contains `mysql` or `postgresql` , the clusterpedia will not start successfully

What happened?

If the release name contains the name of a storage component, then clusterpedia will not start successfully.

realease name: clusterpedia-with-postgresql

$ helm install clusterpedia-with-postgresql  -n clusterpedia-system --create-namespace  --set persistenceMatchNode=caiwei-master --set installCRDs=true .
╭─icebergu@IceberGudeMBP ~/clusterpedia/charts  ‹add-helm*›
╰─➤  kubectl -n clusterpedia-system get pods
NAME                                                              READY   STATUS             RESTARTS      AGE
clusterpedia-with-postgresql-0                                    1/1     Running            0             13s
clusterpedia-with-postgresql-apiserver-b96d4c599-4tlcs            0/1     CrashLoopBackOff   1 (11s ago)   13s
clusterpedia-with-postgresql-clustersynchro-manager-7f76cd2sgch   0/1     CrashLoopBackOff   1 (11s ago)   13s

╭─icebergu@IceberGudeMBP ~/clusterpedia/charts  ‹add-helm*›
╰─➤  kubectl -n clusterpedia-system logs clusterpedia-with-postgresql-apiserver-b96d4c599-4tlcs  
Failed to init storage: failed to connect to `host=clusterpedia-with-postgresql-postgresql user=postgres database=clusterpedia`: hostname resolving error (lookup clusterpedia-with-postgresql-postgresql on 10.96.0.10:53: no such host)

Found that the svc name provided by postgres does not match the host in internalstorage config:

╭─icebergu@IceberGudeMBP ~/clusterpedia/charts  ‹add-helm*›
╰─➤  kubectl -n clusterpedia-system get svc
NAME                                     TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
clusterpedia-with-postgresql             ClusterIP   10.108.157.173   <none>        5432/TCP   4m29s
clusterpedia-with-postgresql-apiserver   ClusterIP   10.99.111.2      <none>        443/TCP    4m29s
clusterpedia-with-postgresql-hl          ClusterIP   None             <none>        5432/TCP   4m29s

╭─icebergu@IceberGudeMBP ~/clusterpedia/charts  ‹add-helm*›
╰─➤  kubectl -n clusterpedia-system get cm clusterpedia-with-postgresql-internalstorage -o yaml
apiVersion: v1
data:
  internalstorage-config.yaml: |-
    type: "postgres"
    host: "clusterpedia-with-postgresql-postgresql"
    port: 5432
    user: postgres
    database: clusterpedia
kind: ConfigMap

The host of the internstorage configmap has an additional postgres suffix.
The problem should be that the host of the internalstorage configmap generated in charts is not the same as the svc name of postgresql.

What did you expect to happen?

The host of internalstorage is the same as the svc name of postgresql, and the clusterpedia will start successfully.

How can we reproduce it (as minimally and precisely as possible)?

output template:

$ helm template clusterpedia-with-postgresql --set persistenceMatchNode=None  .
# Source: clusterpedia/charts/postgresql/templates/primary/svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: clusterpedia-with-postgresql
  namespace: default
spec:
  type: ClusterIP
  ports:
    - name: tcp-postgresql
      port: 5432
      targetPort: tcp-postgresql
      nodePort: null
  selector:
    app.kubernetes.io/name: postgresql
    app.kubernetes.io/instance: clusterpedia-with-postgresql
    app.kubernetes.io/component: primary
# Source: clusterpedia/templates/internalstorage-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: clusterpedia-with-postgresql-internalstorage
  namespace: default
data:
  internalstorage-config.yaml: |-
    type: "postgres"
    host: "clusterpedia-with-postgresql-postgresql"
    port: 5432
    user: postgres
    database: clusterpedia

Anything else we need to know?

No response

Clusterpedia Version

# replace the pod name of clusterpedia apiserver
$ kubectl -n clusterpedia-system exec {clusterpedia-apiserver-pod-name} -- apiserver --version=raw
# paste output here

# replace the pod name of clusterpedia clustersynchro-manager
$ kubectl -n clusterpedia-system exec {clustersynchro-manager-pod-name} -- clustersynchro-manager --version=raw
# paste output here

Host Kubernetes version

$ kubectl version
# paste output here

Support synchronization of all CRD resources

What would you like to be added?

Support synchronization of all CRD resources by a field designed in pediacluster.

Why is this needed?

It is useful for front-end display and viewing of all CRD resources.

support custom resource

For the synchronization of custom resources is developed in two stages:

  • The default collection policy, where the user specifies the version to be synchronized,If no version is specified, then the top three versions of the priority order in the member cluster will be synchronized by default. #10
  • When crds change, the resources that need to be synchronized are renegotiated. #136
  • The clustersynchro manager reconciles the sync version and storage version that should be synchronized by the member cluster

未对接入集群信息做判断,一个集群可以重复接入

What would you like to be added?

1.使用A.yaml文件接入集群A
2.复制A.yaml文件,修改文件名和集群名为B
3.使用B.yaml文件接入集群
预期结果:提示集群已存在
实际结果:接入集群B
image

Why is this needed?

对接入的yaml文件进行判断,若存在相同的集群接入,则接入失败,提示该集群已接入到clusterpedia

指定集群名称查询报错

What happened?

[root@dce-10-6-215-215 ~]# kubectl --cluster clusterpedia get pod
CLUSTER NAME READY STATUS RESTARTS AGE
cluster-178-220 hello-79dbf8f975-fhkcl 1/1 Running 0 128m
cluster-example cm-env-test-pod 0/1 Completed 0 5d1h
cluster-example ng1-849588dbb9-dqc7r 1/1 Running 3 (19h ago) 2d16h
cluster-178-220 nginx-f89759699-rkgkg 1/1 Running 0 130m
cluster-128-168 dao-2048-4-9cdc87d65-7hbdb 1/1 Running 7 (36d ago) 210d
cluster-128-168 dao-2048-6d6dfbb6ff-cjmps 1/1 Running 6 (36d ago) 210d
cluster-128-168 my222-dao-2048-d96b45f57-hpcgn 1/1 Running 8 (36d ago) 210d

指定了某个具体的集群名称提示找不到

[root@dce-10-6-215-215 ~]# kubectl --cluster cluster-128-168 get pod
error: no server found for cluster "cluster-128-168"
[root@dce-10-6-215-215 ~]#

What did you expect to happen?

可以根据某个集群名称找到对应的 pod

How can we reproduce it (as minimally and precisely as possible)?

指定了某个具体的集群名称提示找不到

[root@dce-10-6-215-215 ~]# kubectl --cluster cluster-128-168 get pod
error: no server found for cluster "cluster-128-168"

Anything else we need to know?

No response

Clusterpedia Version

# replace the pod name of clusterpedia apiserver
$ kubectl -n clusterpedia-system exec {clusterpedia-apiserver-pod-name} -- apiserver --version=raw
# paste output here

# replace the pod name of clusterpedia clustersynchro-manager
$ kubectl -n clusterpedia-system exec {clustersynchro-manager-pod-name} -- clustersynchro-manager --version=raw
# paste output here

Host Kubernetes version

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"1f3e19b7beb1cc0110255668c4238ed63dadb7ad", GitTreeState:"clean", BuildDate:"2021-06-16T12:58:51Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"7c28a83e67cb506f9df948d7b23698f8f9c279b8", GitTreeState:"clean", BuildDate:"2021-07-15T08:58:53Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

Move group "pedia.clusterpedia.io" to "clusterpedia.io"

Currently, then resources(resources,collectionresources) under pedia.clusterpedia.io are used for searching multi-cluster resources,
but the prefix pedia does not make any sense and pedia.clusterpedia.io provides the main functionality of clusterpedia,
so it is commended to change pedia.clusterpedia.io to clusterpedia.io.

In this case, the search url will be modified:

kubectl get --raw="/apis/pedia.clusterpedia.io/v1alpha1/resources/apis/apps/v1/deployments"

to

kubectl get --raw="/apis/clusterpedia.io/v1alpha1/resources/apis/apps/v1/deployments"

After the modification, the current clusterpedia-provided groups include:

  • clusterpedia.io
  • clusters.clusterpedia.io

support setting the last `resource version` in the reflector

Support setting the resource version in the reflector before resource synchronizatiion.

In the weak network environment, the start and stop of resource synchronization may be more frequent,
so setting the last resource version can avoid the full list

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.