cluster

package
v0.0.0-...-e5246a7 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 16 Imported by: 20

Documentation

Index

Constants

View Source
const (
	LabelType = "type"
)

Variables

This section is empty.

Functions

func IsReady

func IsReady(clusterStatus *toolchainv1alpha1.ToolchainClusterStatus) bool

func RoleLabel

func RoleLabel(role Role) string

RoleLabel returns a label key that should be used to specific assign roles to clusters.

Types

type CachedToolchainCluster

type CachedToolchainCluster struct {
	*Config
	// Client is the kube client for the cluster.
	Client client.Client
	// ClusterStatus is the cluster result as of the last health check probe.
	ClusterStatus *toolchainv1alpha1.ToolchainClusterStatus
}

CachedToolchainCluster stores cluster client; cluster related info and previous health check probe results

func Filter

func Filter(clusters map[string]*CachedToolchainCluster, conditions ...Condition) []*CachedToolchainCluster

func GetCachedToolchainCluster

func GetCachedToolchainCluster(name string) (*CachedToolchainCluster, bool)

GetCachedToolchainCluster returns a kube client for the cluster (with the given name) and info if the client exists

func GetHostCluster

func GetHostCluster() (*CachedToolchainCluster, bool)

GetHostCluster returns the kube client for the host cluster from the cache of the clusters and info if such a client exists

func GetMemberClusters

func GetMemberClusters(conditions ...Condition) []*CachedToolchainCluster

GetMemberClusters returns the kube clients for the host clusters from the cache of the clusters

type Condition

type Condition func(cluster *CachedToolchainCluster) bool

Condition an expected cluster condition

var Ready Condition = func(cluster *CachedToolchainCluster) bool {
	return IsReady(cluster.ClusterStatus)
}

Ready checks that the cluster is in a 'Ready' status condition

type Config

type Config struct {
	// RestConfig contains rest config data
	RestConfig *rest.Config
	// Name is the name of the cluster. Has to be unique - is used as a key in a map.
	Name string
	// APIEndpoint is the API endpoint of the corresponding ToolchainCluster. This can be a hostname,
	// hostname:port, IP or IP:port.
	APIEndpoint string
	// OperatorNamespace is a name of a namespace (in the cluster) the operator is running in
	OperatorNamespace string
	// OwnerClusterName keeps the name of the cluster the ToolchainCluster resource is created in
	// eg. if this ToolchainCluster identifies a Host cluster (and thus is created in Member)
	// then the OwnerClusterName has a name of the member - it has to be same name as the name
	// that is used for identifying the member in a Host cluster
	OwnerClusterName string

	// Labels contains all the labels of the corresponding ToolchainCluster.
	// They will be used for filtering ToolchainCluster's based on a given list of cluster-role labels.
	Labels map[string]string `json:"labels,omitempty"`
}

func ListToolchainClusterConfigs

func ListToolchainClusterConfigs(cl client.Client, namespace string, timeout time.Duration) ([]*Config, error)

func NewClusterConfig

func NewClusterConfig(cl client.Client, toolchainCluster *toolchainv1alpha1.ToolchainCluster, timeout time.Duration) (*Config, error)

NewClusterConfig generate a new cluster config by fetching the necessary info the given ToolchainCluster's associated Secret and taking all data from ToolchainCluster CR

type GetHostClusterFunc

type GetHostClusterFunc func() (*CachedToolchainCluster, bool)

GetHostClusterFunc a func that returns the Host cluster from the cache, along with a bool to indicate if there was a match or not

HostCluster the func to retrieve the host cluster

type GetMemberClustersFunc

type GetMemberClustersFunc func(conditions ...Condition) []*CachedToolchainCluster

GetMemberClustersFunc a func that returns the member clusters from the cache

MemberClusters the func to retrieve the member clusters

type NewClient

type NewClient func(config *rest.Config, options client.Options) (client.Client, error)

type Role

type Role string

Role defines the role of the cluster. Each type of cluster can have multiple roles (tenant for specific APIs, user workloads, others ... )

const (
	Tenant Role = "tenant"
)

type ToolchainClusterService

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

ToolchainClusterService manages cached cluster kube clients and related ToolchainCluster CRDs it's used for adding/updating/deleting

func NewToolchainClusterService

func NewToolchainClusterService(client client.Client, log logr.Logger, namespace string, timeout time.Duration) ToolchainClusterService

NewToolchainClusterService creates a new instance of ToolchainClusterService object and assigns the refreshCache function to the cache instance

func NewToolchainClusterServiceWithClient

func NewToolchainClusterServiceWithClient(client client.Client, log logr.Logger, namespace string, timeout time.Duration, newClient NewClient) ToolchainClusterService

NewToolchainClusterServiceWithClient creates a new instance of ToolchainClusterService object and assigns the given newClient functione to be used for creating a client

func (*ToolchainClusterService) AddOrUpdateToolchainCluster

func (s *ToolchainClusterService) AddOrUpdateToolchainCluster(cluster *toolchainv1alpha1.ToolchainCluster) error

AddOrUpdateToolchainCluster takes the ToolchainCluster CR object, creates CachedToolchainCluster with a kube client and stores it in a cache

func (*ToolchainClusterService) DeleteToolchainCluster

func (s *ToolchainClusterService) DeleteToolchainCluster(name string)

DeleteToolchainCluster takes the ToolchainCluster CR object and deletes CachedToolchainCluster instance that has same name from a cache (if exists)

Jump to

Keyboard shortcuts

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