- Notifications
You must be signed in to change notification settings - Fork0
Discover kubernetes clusters and resources across cloud providers and/or on-prem
License
app-net-interface/kubernetes-discovery
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A library for discovering Kubernetes clusters from various Clouds and theservices inside them.
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}
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}
Read the full documentation about the usage, the supported clouds and functionsatpkg.go
Thank you for interest in contributing! Please refer to ourcontributing guide.
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.