Client-go - Clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

Overview

clusterpedia-client supports the use of native client-go mode to call the clusterpedia API. clisterpedia uses labelSelector to query data. clusterpedia- client provides a more convenient way to build options for various complex conditions, which is more suitable for users.

usage

In multiple clusters, build options in a chained stype.

options := clusterpedia.ListOptionsBuild().Clusters("cluster-01").Namespaces("kube-system").Offset(10).Size(5).OrderBy(Order{"dsad", false}).Options()

You can get the clientset of client-go connect to clusterpedia.

example

Here are some examples where clusterpedia-client can be used more easily.

Comments
  • remove fake-apiserver to repo `clusterpedia-io/fake-apiserver`

    remove fake-apiserver to repo `clusterpedia-io/fake-apiserver`

    fake-apiserver references kubernetes. io pkg cause users need to replace all of kubenetes's pkgs if they want to use client-go. this was very unfriendly and after discussion, we are now going to separate the fake-apiserver to repo clusterpedia-io/fake-apiserver to keep client-go lightweight.

    • [x] pull fake-apiserver to clusterpedia-io/fake-apiserver
    • [x] init clusterpedia-io/fake-apiserver
    • [x] remove client-go/fake-apiserver and update go.mod
    enhancement 
    opened by calvin0327 6
  • feat/support_labelselect_not_exist

    feat/support_labelselect_not_exist

    Feature: make clusterpedia client support select by notExistLabel Example:

    企业微信截图_a997e0d2-88c9-4095-a28b-bb53809ef47c

      select node role by notExistLabel:node-role.kubernetes.io/master:""
    

    企业微信截图_13e5289d-cdde-4c24-a3a7-f2268d8d96f8

    opened by feeltimeQ 5
  • Support controller-runtime style Client

    Support controller-runtime style Client

    The controller-runtime style Client is more convenient than client-go, and it is widely used in many kubebuilder/operator-sdk based products.

    Here is a code snippet to show how to use it:

    package main
    
    import (
    	"context"
    	"fmt"
    	"time"
    
    	pedia "github.com/clusterpedia-io/client-go/client"
    	"github.com/clusterpedia-io/client-go/tools/builder"
    	"github.com/pkg/errors"
    	corev1 "k8s.io/api/core/v1"
    	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    	"k8s.io/apimachinery/pkg/runtime"
    	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
    	clientgoscheme "k8s.io/client-go/kubernetes/scheme"
    	ctrl "sigs.k8s.io/controller-runtime"
    	"sigs.k8s.io/controller-runtime/pkg/client"
    )
    
    func main() {
    	// build listOptions
    	options := builder.ListOptionsBuilder().
    		Clusters("lou1").
    		Namespaces("kube-system").
    		Offset(10).
    		Limit(5).
    		OrderBy("dsad", false).
    		Options()
    
    	cl, err := GetClient()
    	if err != nil {
    		panic(err)
    	}
    
    	pods := &corev1.PodList{}
    	err = ListResources(pods, &options, cl)
    	if err != nil {
    		panic(err)
    	}
    
    	for _, pod := range pods.Items {
    		fmt.Printf("Name: %v\n", pod.Name)
    	}
    }
    
    func GetClient() (client.Client, error) {
    	restConfig := ctrl.GetConfigOrDie()
    	restConfig.Timeout = 10 * time.Second
    	restConfig, _ = pedia.ConfigFor(restConfig)
    
    	scheme := runtime.NewScheme()
    	utilruntime.Must(clientgoscheme.AddToScheme(scheme))
    
    	c, err := client.New(restConfig, client.Options{
    		Scheme: scheme,
    	})
    	if err != nil {
    		return nil, errors.Wrap(err, "unable to init client")
    	}
    
    	return c, nil
    }
    
    func ListResources(obj client.ObjectList, opts *metav1.ListOptions, cl client.Reader) error {
    	o := &client.ListOptions{Raw: opts, Limit: opts.Limit, Continue: opts.Continue}
    
    	return cl.List(context.TODO(), obj, o)
    }
    
    opened by 27149chen 5
  • add collection resource client

    add collection resource client

    Signed-off-by: calvin [email protected]

    fixed: https://github.com/clusterpedia-io/client-go/issues/37

    /kind feature

    add client to satisfy clusterpedia collectionresource feature.

    opened by calvin0327 3
  • merge custom client to collectionresouce client

    merge custom client to collectionresouce client

    ref: https://github.com/clusterpedia-io/client-go/pull/43

    As the two types of clients are used in a very similar way, we should merge the two clients.

    opened by calvin0327 0
Owner
clusterpedia.io
The Encyclopedia of Kubernetes clusters
clusterpedia.io
InkCaller is an API to call Ink. Each new call is independent and can be executing concurrently

inkcaller This library InkCaller is an API to call Ink. Each new call is independent and can be executing concurrently. A call will force the ink stat

Vincent KERDRAON 0 Feb 8, 2022
API call that accepts a list of sold Items and creates Payouts for the sellers.

Introduction As a marketplace, we need to pay our sellers for every item that has been sold on our platform. In this task, you’ll be working with 2 ma

Shubham Saxena 0 Dec 15, 2021
A cloud native Identity & Access Proxy / API (IAP) and Access Control Decision API

Heimdall Heimdall is inspired by Ory's OAthkeeper, tries however to resolve the functional limitations of that product by also building on a more mode

Dimitrij Drus 19 Jan 6, 2023
null 2 Feb 7, 2022
go-whatsapp-rest-API is a Go library for the WhatsApp web which use Swagger as api interface

go-whatsapp-rest-API go-whatsapp-rest-API is a Go library for the WhatsApp web which use Swagger as api interface Multi-devices (MD) Support. This ver

null 18 Dec 15, 2022
Elastos.ELA.Rosetta.API - How to write a Rosetta server and use either the Client package or Fetcher package to communicate

Examples This folder demonstrates how to write a Rosetta server and how to use e

Elastos Foundation 3 Jan 17, 2022
Cloud governance reports from native services in a clear and readable digest

cloudig, or Cloudigest, is a simple CLI tool for creating reports from various cloud sources with user-provided comments. It is written in Go and curr

Optum 22 Nov 10, 2022
A simple Kubernetes-native CI system for the Bhojpur.NET Platform.

Bhojpur Piro - Kubernetes-native CI A simple Kubernetes-native CI system applied by the Bhojpur.NET Platform. It knows no pipelines, just the jobs and

Bhojpur Consulting 2 Apr 28, 2022
Breaking Cloud Native Web APIs in their natural habitat.

cnfuzz - Cloud Native Web API Fuzzer "Breaking Cloud Native Web APIs in their natural habitat." Fuzzing web APIs in their fully converged Cloud Native

Sue B.V. - Cloud Native 35 Nov 28, 2022
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple Weather API Simple weather api app created using golang and Open Weather

Siva Prakash 3 Feb 6, 2022
Go library to use the imgur.com API

go-imgur Go library to use the imgur.com API. At the moment only the anonymous part of the API is supported, but that is used in a production environm

null 24 Sep 27, 2022
Use Google REST api to extract your personal Photo Library

Photo Go A better approach to extracting your photos from Google to your personal cloud. I'm moving my photos out of Google to a Synology NAS. create

James 2 Dec 7, 2021
Rewritten glusterfs csi driver to use with heketi API

Glusterfs-Heketi CSI driver The CSI (Container Storage Interface) is a universal way to provide storage for the applications. This version of the plug

NativeCI 9 Dec 8, 2022
Our library to use the sendcloud API endpoints in golang.

gosendcloud With this library it should be possible to interact with the endpoints of the sendcloud API via golang functions. Since we can not impleme

J&J Ideenschmiede GmbH 0 Dec 3, 2021
Easy to use API for Twitch emotes including 7TV, BetterTTV and FFZ

tEmotes API Easy to use API for Twitch emotes We support: Twitch 7TV BetterTTV F

Adrian Zmenda 14 Dec 23, 2022
Easy-to-use api for uploadgram written in Go

uploadgramApiGo Easy to use uploadgram.me api Already done: Upload Files Download Files + Files info Delete files Rename files How install it? $ go ge

null 4 Jul 31, 2022
Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Bruno Souza 55 Oct 6, 2022
An API client for the Notion API implemented in Golang

An API client for the Notion API implemented in Golang

Anatoly Nosov 354 Dec 30, 2022
A Wrapper Client for Google Spreadsheet API (Sheets API)

Senmai A Wrapper Client for Google Spreadsheet API (Sheets API) PREPARATION Service Account and Key File Create a service account on Google Cloud Plat

ytnobody / satoshi azuma 0 Nov 5, 2021