k8sutils

package
v0.0.0-...-c7431a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceImportFullIndexer    = "clusterNameNamespaceIndex"
	ServiceImportClusterIndexer = "clusterIndex"
)
View Source
const (
	// SDKubePath is to be used for initializing member cluster clients, this constant
	// must not be used directly, IsKubePathSet() must be checked before using the below
	// constant
	SDKubePath = "/tmp/sd-kubeconfig"
)

Variables

This section is empty.

Functions

func AddEventHandlersToClusterInformers

func AddEventHandlersToClusterInformers(numWorkers uint32)

func BuildContextConfig

func BuildContextConfig(kubeconfigPath, context string) (*restclient.Config, error)

BuildContextConfig builds the kubernetes/openshift context config

func GenerateKubeConfig

func GenerateKubeConfig(kubeConfigData string) error

func GetClusterListFromSharedClusters

func GetClusterListFromSharedClusters() []string

func GetClusterListStr

func GetClusterListStr(clist []*K8sClusterConfig) []string

func GetClustersetKubeConfig

func GetClustersetKubeConfig(kubeClient *kubernetes.Clientset, secretName string) (string, error)

GetClustersetKubeConfig fetches the clusterset's secret, validates the secret and returns the kubeconfig for the clusters in the clusterset

func GetNodeIP

func GetNodeIP(nodeStatus corev1.NodeStatus) (string, error)

func GetNodeInfoFromSharedClusters

func GetNodeInfoFromSharedClusters(cname, nodeName string) (string, error)

func GetSvcInfoFromSharedClusters

func GetSvcInfoFromSharedClusters(cname, ns, svc string) (*corev1.Service, error)

func GetWorkqueueForCluster

func GetWorkqueueForCluster(cname string) []workqueue.RateLimitingInterface

func InformersToRegister

func InformersToRegister(kclient *kubernetes.Clientset, cname string) ([]string, error)

func InitSharedClusterList

func InitSharedClusterList(clusterConfigs []*K8sClusterConfig)

func IsErrorTypeNotFound

func IsErrorTypeNotFound(err error) bool

func IsKubePathSet

func IsKubePathSet() bool

IsKubePathSet returns true if the kubeconfig exists in the SDKubePath

func NodeEventHandlers

func NodeEventHandlers(numWorkers uint32, c *K8sClusterConfig) cache.ResourceEventHandler

func RunSharedClusterInformers

func RunSharedClusterInformers(stopCh <-chan struct{})

func SvcEventHandlers

func SvcEventHandlers(numWorkers uint32, c *K8sClusterConfig) cache.ResourceEventHandler

Types

type ClusterNodeCache

type ClusterNodeCache struct {
	// contains filtered or unexported fields
}

func GetClusterNodeCache

func GetClusterNodeCache() *ClusterNodeCache

func (*ClusterNodeCache) AddCluster

func (cnc *ClusterNodeCache) AddCluster(cname string)

func (*ClusterNodeCache) AddNode

func (cnc *ClusterNodeCache) AddNode(cname, node, nodeIP string)

func (*ClusterNodeCache) DeleteNode

func (cnc *ClusterNodeCache) DeleteNode(cname, node string)

func (*ClusterNodeCache) GetNodeCache

func (cnc *ClusterNodeCache) GetNodeCache(cname string) *NodeCache

func (*ClusterNodeCache) GetNodeInfo

func (cnc *ClusterNodeCache) GetNodeInfo(cname, node string) (string, error)

func (*ClusterNodeCache) GetNodeList

func (cnc *ClusterNodeCache) GetNodeList(cname string) ([]string, error)

type K8sClusterConfig

type K8sClusterConfig struct {
	// contains filtered or unexported fields
}

func InitK8sClusterConfig

func InitK8sClusterConfig(cname string) (*K8sClusterConfig, error)

InitK8sClusterConfig initializes a kubernetes cluster client and informers. "name" must have the cluster context name.

func (*K8sClusterConfig) ClientSet

func (k8sCluster *K8sClusterConfig) ClientSet() kubernetes.Interface

func (*K8sClusterConfig) GetNodeFromInformer

func (k8sCluster *K8sClusterConfig) GetNodeFromInformer(nodeName string) (string, error)

GetNodeFromInformer returns the IP of the node and the error (if any)

func (*K8sClusterConfig) GetNodes

func (k8sCluster *K8sClusterConfig) GetNodes() (*corev1.NodeList, error)

func (*K8sClusterConfig) GetSvcFromInformer

func (k8sCluster *K8sClusterConfig) GetSvcFromInformer(ns, svcName string) (*corev1.Service, error)

func (*K8sClusterConfig) GetWorkqueue

func (k8sCluster *K8sClusterConfig) GetWorkqueue() []workqueue.RateLimitingInterface

func (*K8sClusterConfig) Name

func (k8sCluster *K8sClusterConfig) Name() string

func (*K8sClusterConfig) ServiceInformer

func (k8sCluster *K8sClusterConfig) ServiceInformer() coreinformers.ServiceInformer

type K8sServiceDiscoveryConfig

type K8sServiceDiscoveryConfig struct {
	// contains filtered or unexported fields
}

func InitK8sServiceDiscoveryConfig

func InitK8sServiceDiscoveryConfig(cfg *rest.Config) (*K8sServiceDiscoveryConfig, error)

func (*K8sServiceDiscoveryConfig) GetAmkoV1Clientset

func (sdc *K8sServiceDiscoveryConfig) GetAmkoV1Clientset() *akov1.Clientset

func (*K8sServiceDiscoveryConfig) GetClientset

func (sdc *K8sServiceDiscoveryConfig) GetClientset() *kubernetes.Clientset

func (*K8sServiceDiscoveryConfig) SetClusterConfigs

func (sdc *K8sServiceDiscoveryConfig) SetClusterConfigs(cc []*K8sClusterConfig)

type NodeCache

type NodeCache struct {
	// contains filtered or unexported fields
}

func GetNodeCache

func GetNodeCache() *NodeCache

func (*NodeCache) Add

func (nc *NodeCache) Add(node string, nodeIP string)

func (*NodeCache) Delete

func (nc *NodeCache) Delete(node string)

func (*NodeCache) Get

func (nc *NodeCache) Get(node string) (string, error)

func (*NodeCache) GetAllNodeIPs

func (nc *NodeCache) GetAllNodeIPs() []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL