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

https://clusterpedia.io/blog/2022/02/15/upgrade-to-clusterpedia-0.1.0/

01

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   https://10.6.100.10:6443    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['test.io'] in (value1, value2)"

more details

https://clusterpedia.io/zh-cn/docs/usage/search/multi-cluster/#%E5%AD%97%E6%AE%B5%E8%BF%87%E6%BB%A4

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 \    "internalstorage.clusterpedia.io/owner-uid=$DEPLOY_UID,\     internalstorage.clusterpedia.io/owner-seniority=1"

more details

https://clusterpedia.io/zh-cn/docs/usage/search/multi-cluster/#%E6%A0%B9%E6%8D%AE%E7%88%B6%E8%BE%88%E4%BB%A5%E5%8F%8A%E7%A5%96%E8%BE%88-owner-%E6%9F%A5%E8%AF%A2

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/clusterpedia.io/v1beta1/resources/apis/apps/v1/deployments?withRemainingCount&limit=1" | jq{  "kind": "DeploymentList",  "apiVersion": "apps/v1",  "metadata": {    "remainingItemCount": 24  },  "items": [    ...  ]}

more details

https://clusterpedia.io/zh-cn/docs/usage/search/multi-cluster/#%E5%93%8D%E5%BA%94%E6%90%BA%E5%B8%A6%E5%89%A9%E4%BD%99%E8%B5%84%E6%BA%90%E6%95%B0%E9%87%8F%E4%BF%A1%E6%81%AF

02

Update overview

  • Pedia for resource retrieval clusterpedia. IO / v1alpha1 # changed to # clusterpedia io/v1beta1 ( https://github.com/clusterpedia-io/clusterpedia/pull/73)

  • The structure of PediaCluster is optimized, and "clusters" clusterpedia. Change IO / v1alpha1 # group to # cluster clusterpedia. io/v1alpha2 ( https://github.com/clusterpedia-io/clusterpedia/pull/27; https://github.com/clusterpedia-io/clusterpedia/pull/67; https://github.com/clusterpedia-io/clusterpedia/pull/76; https://github.com/clusterpedia-io/clusterpedia/pull/74; https://github.com/clusterpedia-io/clusterpedia/pull/78)

  • Support the collection and search of custom resources( https://github.com/clusterpedia-io/clusterpedia/pull/10)

  • Move the cluster information inserted into the resource from labels to annotations( https://github.com/clusterpedia-io/clusterpedia/pull/37)

  • Add deployment yaml of storage component postgres

APIServer

  • Support the response data to carry RemainingItemCount and Continue fields( https://github.com/clusterpedia-io/clusterpedia/pull/33)

  • Enhanced support for Field Selector. While compatible with the native Field Selector, it also supports the same complex operators as the Label Selector( https://github.com/clusterpedia-io/clusterpedia/pull/36)

  • A Warning reminder is added when querying resources in the cluster with unsynchronized exceptions( https://github.com/clusterpedia-io/clusterpedia/pull/35)

  • 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 ( https://github.com/clusterpedia-io/clusterpedia/pull/42)

Bug Fixes

  • Fix that requestInfo is still set when it resolves namespace resources Namespace field( https://github.com/clusterpedia-io/clusterpedia/pull/17)

  • Fixed the problem that the specified version caused the abnormal display of resource synchronization status during the synchronization of built-in resources( https://github.com/clusterpedia-io/clusterpedia/pull/58)

ClusterSynchro Manager

  • The clustersynchro manager can tailor the managed fields and last applied configuration fields through feature gates( https://github.com/clusterpedia-io/clusterpedia/pull/19)

Bug Fixes

  • Fixed issues related to PediaCluster Status update( https://github.com/clusterpedia-io/clusterpedia/pull/11 ;   https://github.com/clusterpedia-io/clusterpedia/pull/24 ;   https://github.com/clusterpedia-io/clusterpedia/pull/23;https://github.com/clusterpedia-io/clusterpedia/pull/22)

  • Fixed the leader selection of clustersynchro manager( https://github.com/clusterpedia-io/clusterpedia/pull/15)

Default Storage Layer

  • The default storage layer no longer provides users with the default sort order. Users can actively set the sort order( https://github.com/clusterpedia-io/clusterpedia/pull/44)

  • Added some indexes and fixed gorm ignoring empty fields( https://github.com/clusterpedia-io/clusterpedia/pull/41)

  • Query based on parent or grandparent owner is supported( https://github.com/clusterpedia-io/clusterpedia/pull/50)

Bug Fixes

  • Fixed generation of JSON SQL( https://github.com/clusterpedia-io/clusterpedia/pull/60; https://github.com/clusterpedia-io/clusterpedia/pull/62; https://github.com/clusterpedia-io/clusterpedia/pull/78)

  • Fixed the problem of inaccurate resources obtained when filtering collectionresources( https://github.com/clusterpedia-io/clusterpedia/pull/61 )

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