Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Discover kubernetes clusters and resources across cloud providers and/or on-prem

License

NotificationsYou must be signed in to change notification settings

app-net-interface/kubernetes-discovery

A library for discovering Kubernetes clusters from various Clouds and theservices inside them.

Quickstart

Retrieve clusters

Get a client:

First, import the library in your project, along with the libraries for yourchosen Kubernetes managed service -- for exampleEKS:

import (    cluster"github.com/app-net-interface/kubernetes-discovery/cluster"    eks"github.com/app-net-interface/kubernetes-discovery/cluster/eks""github.com/aws/aws-sdk-go-v2/config""github.com/aws/aws-sdk-go-v2/credentials")

Then create a configuration for your chose cluster retriever:

cfg,err:=config.LoadDefaultConfig(ctx,config.WithRegion("us-west-2"),config.WithDefaultRegion("us-west-2"),// Provide credentials here)iferr!=nil {returnnil,fmt.Errorf("cannot get AWS configuration: %w",err)}

Now get the clusters retriever:

retriever:=eks.NewClustersRetriever(cfg)clusters,err:=retriever.Retrieve(context.TODO(),cluster.WithRegions("us-west-2","us-west-1"))iferr!=nil {log.Err(err).Msg("cannot get clusters")return}for_,foundCluster:=rangeclusters.DiscoveredClusters {data,err:=foundCluster.GetData()// Check the error and use data}

Retrieve services

Get the Kubernetes clientset:

kclient,err:=cl.GetClientset(context.TODO())iferr!=nil {log.Err(err).Msg("cannot get Kubernetes clientset for cluster")return}

Now retrieve services:

servs,err:=service.GetServices(ctx,kclient,service.WithExternalNames(),service.WithNodePorts(),service.WithNamespaces(namespaces...))iferr!=nil {log.Err(err).Str("operation","get-services").Msg("cannot get services")return}for_,serv:=rangeservs.Services {// do something with the service}

Documentation

Read the full documentation about the usage, the supported clouds and functionsatpkg.go

Contributing

Thank you for interest in contributing! Please refer to ourcontributing guide.

License

kubernetes-discovery is released under the Apache 2.0 license. SeeLICENSE.

kubernetes-discovery is also made possible thanks tothird party open source projects.

About

Discover kubernetes clusters and resources across cloud providers and/or on-prem

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp