Launch | four important functions of Clusterpedia 0.1.0

The first version of Clusterpedia , Clusterpedia , 0.1.0 , was officially released and will enter the version iteration stage from now on. Compared with the initial 0.0.8 and 0.0.9-alpha, 0.1.0 added many functions and made some incompatible updates.

If you upgrade from 0.0.9-alpha, you can refer to 0.1.0 upgrade to clusterpedia


Important functions

Let's first introduce the four important functions added in 0.1.0:

  • When retrieving resources for Not Ready clusters, a Warning reminder is added

  • Enhanced native Field Selector capabilities

  • Query according to the Owner of the parent or grandparent

  • The response data carries the remaining item count

Warning reminder during resource retrieval

When the cluster is in a non Ready state for some reasons, the resources usually cannot be synchronized normally. When the resources in the cluster are obtained, the user will be informed of the cluster exception through the warning reminder, and the obtained resources may not be real-time and accurate.

$ kubectl get pediaclusterNAME        APISERVER                   VERSION   STATUScluster-1    v1.22.2   ClusterSynchroStop
$ kubectl --cluster cluster-1 get podsWarning: cluster-1 is not ready and the resources obtained may be inaccurate, reason: ClusterSynchroStopCLUSTER     NAME                                                 READY   STATUS      RESTARTS   AGEcluster-1   fake-pod-698dfbbd5b-64fsx                            1/1     Running     0          68dcluster-1   fake-pod-698dfbbd5b-9ftzh                            1/1     Running     0          39dcluster-1   fake-pod-698dfbbd5b-rk74p                            1/1     Running     0          39dcluster-1   quickstart-ingress-nginx-admission-create--1-kxlnn   0/1     Completed   0          126d

Strengthen Field Selector

Native kubernetes support for Field Selector is very limited, and only metadata is supported by default Namespace and metadata Name field filtering. Although some specific resources support some special fields, it is still limited to use. The operator can only support =, = =,! =.

# kubernetes/pkg$ grep AddFieldLabelConversionFunc . -r./apis/core/v1/conversion.go:   err := scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Pod"),./apis/core/v1/conversion.go:   err = scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Node"),./apis/core/v1/conversion.go:   err = scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("ReplicationController"),./apis/core/v1/conversion.go:   return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Event"),./apis/core/v1/conversion.go:   return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Namespace"),./apis/core/v1/conversion.go:   return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Secret"),./apis/certificates/v1/conversion.go:   return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("CertificateSigningRequest"),./apis/certificates/v1beta1/conversion.go:      return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("CertificateSigningRequest"),./apis/batch/v1/conversion.go:  return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Job"),./apis/batch/v1beta1/conversion.go:             err = scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind(kind),./apis/events/v1/conversion.go: return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Event"),./apis/events/v1beta1/conversion.go:    return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Event"),./apis/apps/v1beta2/conversion.go:      if err := scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("StatefulSet"),./apis/apps/v1beta1/conversion.go:      if err := scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("StatefulSet"),

On the basis of compatibility with the native Field Selector, Clusterpedia not only supports more flexible field filtering, but also supports the same operators as the Label Selector:!, =,! =, =, = =, in, notin.

For example, we can filter resources through annotations like label selector.

kubectl get deploy --field-selector="metadata.annotations[''] in (value1, value2)"

more details

Query by parent or grandparent Owner

There is usually an Owner relationship between Kubernetes resources, such as

apiVersion: v1kind: Podmetadata:  ownerReferences:  - apiVersion: apps/v1    blockOwnerDeletion: true    controller: true    kind: ReplicaSet    name: fake-pod-698dfbbd5b    uid: d5bf2bdd-47d2-4932-84fb-98bde486d244

Clusterpedia supports not only the query based on the Owner, but also the promotion of the Owner's generation to retrieve resources based on the Owner of the ancestor or higher generation.

For example, you can obtain all the corresponding pods through Deployment.

You can only use the function of uid: owner by owner to query the current resource. You can only use the function of uid: owner for discussion.

$ DEPLOY_UID=$(kubectl --cluster cluster-1 get deploy fake-deploy -o jsonpath="{.metadata.uid}")$ kubectl --cluster cluster-1 get pods -l \    "$DEPLOY_UID,\"

more details

Number of remaining resources carried in response data

In some UI scenarios, it is often necessary to obtain the total amount of resources under the current retrieval conditions.

The RemainingItemCount field in the ListMeta of Kubernetes response indicates the number of resources remaining.

type ListMeta struct {    ...
        // remainingItemCount is the number of subsequent items in the list which are not included in this        // list response. If the list request contained label or field selectors, then the number of        // remaining items is unknown and the field will be left unset and omitted during serialization.        // If the list is complete (either because it is not chunking or because this is the last chunk),        // then there are no more remaining items and this field will be left unset and omitted during        // serialization.        // Servers older than v1.15 do not set this field.        // The intended use of the remainingItemCount is *estimating* the size of a collection. Clients        // should not rely on the remainingItemCount to be set or to be exact.        // +optional    RemainingItemCount *int64 `json:"remainingItemCount,omitempty" protobuf:"bytes,4,opt,name=remainingItemCount"`}

Reuse listmeta Remainingitemcount: the total amount of resources under the current retrieval condition can be obtained through simple calculation: total = offset + len (list. Items) + list metadata. remainingItemCount

This function needs to be used together with paging function

$ kubectl get --raw="/apis/" | jq{  "kind": "DeploymentList",  "apiVersion": "apps/v1",  "metadata": {    "remainingItemCount": 24  },  "items": [    ...  ]}

more details


Update overview

  • Pedia for resource retrieval clusterpedia. IO / v1alpha1 # changed to # clusterpedia io/v1beta1 (

  • The structure of PediaCluster is optimized, and "clusters" clusterpedia. Change IO / v1alpha1 # group to # cluster clusterpedia. io/v1alpha2 (;;;;

  • Support the collection and search of custom resources(

  • Move the cluster information inserted into the resource from labels to annotations(

  • Add deployment yaml of storage component postgres


  • Support the response data to carry RemainingItemCount and Continue fields(

  • Enhanced support for Field Selector. While compatible with the native Field Selector, it also supports the same complex operators as the Label Selector(

  • A Warning reminder is added when querying resources in the cluster with unsynchronized exceptions(

  • In order to keep the Limit query used for paging consistent, search label is replaced by search clusterpedia. Modify IO / size to search clusterpedia. io/limit (

Bug Fixes

  • Fix that requestInfo is still set when it resolves namespace resources Namespace field(

  • Fixed the problem that the specified version caused the abnormal display of resource synchronization status during the synchronization of built-in resources(

ClusterSynchro Manager

  • The clustersynchro manager can tailor the managed fields and last applied configuration fields through feature gates(

Bug Fixes

  • Fixed issues related to PediaCluster Status update( ; ;;

  • Fixed the leader selection of clustersynchro manager(

Default Storage Layer

  • The default storage layer no longer provides users with the default sort order. Users can actively set the sort order(

  • Added some indexes and fixed gorm ignoring empty fields(

  • Query based on parent or grandparent owner is supported(

Bug Fixes

  • Fixed generation of JSON SQL(;;

  • Fixed the problem of inaccurate resources obtained when filtering collectionresources( )

The above is the content introduction of Clusterpedia 0.1.0. You are very welcome to use and participate in the discussion.

Keywords: Linux Kubernetes Nginx

Added by soadlink on Tue, 01 Mar 2022 08:08:34 +0200