common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ControllerName = "kubecluster-controller"
)

Variables

This section is empty.

Functions

func ClearGeneratedFields

func ClearGeneratedFields(objmeta *metav1.ObjectMeta)

ClearGeneratedFields will clear the generated fields from the given object meta. It is used to avoid problems like "the object has been modified; please apply your changes to the latest version and try again".

func ConvertPodListWithFilter

func ConvertPodListWithFilter(list []corev1.Pod, pass ObjectFilterFunction) []*corev1.Pod

ConvertPodListWithFilter converts pod list to pod pointer list with ObjectFilterFunction

func ConvertServiceList

func ConvertServiceList(list []corev1.Service) []*corev1.Service

ConvertServiceList convert service list to service point list

func CreatedClustersCounterInc

func CreatedClustersCounterInc(clusterNamespace string, clusterType kubeclusterorgv1alpha1.ClusterType)

func DeletedClustersCounterInc

func DeletedClustersCounterInc(clusterNamespace string, clusterType kubeclusterorgv1alpha1.ClusterType)

func FailedClustersCounterInc

func FailedClustersCounterInc(clusterNamespace string, clusterType kubeclusterorgv1alpha1.ClusterType)

func GenGeneralName

func GenGeneralName(clusterName string, rtype kubeclusterorgv1alpha1.ReplicaType, index string) string

func KubeClusterControlledPodList

func KubeClusterControlledPodList(list []corev1.Pod, cluster metav1.Object) []*corev1.Pod

KubeClusterControlledPodList filter pod list owned by the cluster.

func RestartedClustersCounterInc

func RestartedClustersCounterInc(clusterNamespace string, clusterType kubeclusterorgv1alpha1.ClusterType)

Types

type ClusterSchemaReconciler

type ClusterSchemaReconciler interface {
	expectation.ControllerExpectationsInterface

	// GetDefaultContainerName Returns the default container name in pod
	GetDefaultContainerName() string

	ReconcileConfigMap(kcluster *kubeclusterorgv1alpha1.KubeCluster, configMap *v1.ConfigMap) error

	ValidateV1KubeCluster(kcluster *kubeclusterorgv1alpha1.KubeCluster) error

	UpdateConfigMap(kcluster *kubeclusterorgv1alpha1.KubeCluster, deepCopy *v1.ConfigMap) error

	Default(kcluster *kubeclusterorgv1alpha1.KubeCluster)

	// SetClusterSpec sets the cluster spec for the pod
	SetClusterSpec(
		kcluster *kubeclusterorgv1alpha1.KubeCluster,
		template *v1.PodTemplateSpec,
		rt kubeclusterorgv1alpha1.ReplicaType,
		indexStr string,
		configMap *v1.ConfigMap,
	) error

	IsController(
		spec map[kubeclusterorgv1alpha1.ReplicaType]*kubeclusterorgv1alpha1.ReplicaSpec,
		rType kubeclusterorgv1alpha1.ReplicaType,
		index int,
	) bool

	// UpdateClusterStatus updates the cluster status and cluster conditions
	UpdateClusterStatus(
		kcluster *kubeclusterorgv1alpha1.KubeCluster,
		clusterStatus *kubeclusterorgv1alpha1.ClusterStatus,
		rtype kubeclusterorgv1alpha1.ReplicaType,
		spec *kubeclusterorgv1alpha1.ReplicaSpec,
	)
}

type ControllerInterface

type ControllerInterface interface {
	// ControllerName Returns the Controller name
	ControllerName() string

	// GetAPIGroupVersionKind Returns the GroupVersionKind of the API
	GetAPIGroupVersionKind() schema.GroupVersionKind

	// GetAPIGroupVersion Returns the GroupVersion of the API
	GetAPIGroupVersion() schema.GroupVersion

	// GetClusterFromInformerCache Returns the Cluster from Informer Cache
	GetClusterFromInformerCache(namespace, name string) (metav1.Object, error)

	// GetPodsForCluster returns the pods managed by the cluster. This can be achieved by selecting pods using label key "kubecluster-name"
	// i.e. all pods created by the cluster will come with label "kubecluster-name" = <this_cluster_name>
	GetPodsForCluster(kcluster *kubeclusterorgv1alpha1.KubeCluster) ([]*v1.Pod, error)

	// GetConfigMapForCluster returns the pods managed by the cluster. This can be achieved by selecting pods using label key "kubecluster-name"
	// i.e. all pods created by the cluster will come with label "kubecluster-name" = <this_cluster_name>
	GetConfigMapForCluster(kcluster *kubeclusterorgv1alpha1.KubeCluster) (*v1.ConfigMap, error)

	// GetServicesForCluster returns the services managed by the cluster. This can be achieved by selecting services using label key "kubecluster-name"
	// i.e. all services created by the cluster will come with label "kubecluster-name" = <this_cluster_name>
	GetServicesForCluster(kcluster *kubeclusterorgv1alpha1.KubeCluster) ([]*v1.Service, error)

	// DeleteCluster deletes the cluster
	DeleteCluster(kcluster metav1.Object) error

	// UpdateClusterStatusInApiServer updates the cluster status in API server
	UpdateClusterStatusInApiServer(kcluster metav1.Object, clusterStatus *kubeclusterorgv1alpha1.ClusterStatus) error

	// UpdateClusterStatus updates the cluster status and cluster conditions
	UpdateClusterStatus(
		kcluster *kubeclusterorgv1alpha1.KubeCluster,
		replicas map[kubeclusterorgv1alpha1.ReplicaType]*kubeclusterorgv1alpha1.ReplicaSpec,
		clusterStatus *kubeclusterorgv1alpha1.ClusterStatus,
	) error

	GetServiceSlices(services []*v1.Service, replicas int, replica *log.Entry) [][]*v1.Service

	// GetGroupNameLabelValue Returns the Group Name(value) in the labels of the cluster
	GetGroupNameLabelValue() string

	UpdateConfigMapInApiServer(metav1.Object, *v1.ConfigMap) error
}

ControllerInterface defines the Interface to be implemented by custom operators. e.g. tf-operator needs to implement this interface

type ObjectFilterFunction

type ObjectFilterFunction func(obj metav1.Object) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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