util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 25 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// PolicyClaimLabel will set in kubernetes resource, indicates that
	// the resource is occupied by propagationPolicy
	PolicyClaimLabel = "karmada.io/driven-by"
	// OwnerLabel will set in karmada CRDs, indicates that who created it.
	// We can use labelSelector to find who created it quickly.
	// example1: set it in propagationBinding, the label value is propagationPolicy.
	// example2: set it in propagationWork, the label value is propagationBinding.
	OwnerLabel = "karmada.io/created-by"
)
View Source
const (
	// MemberClusterControllerFinalizer is added to MemberCluster to ensure PropagationWork as well as the
	// execution space (namespace) is deleted before itself is deleted.
	MemberClusterControllerFinalizer = "karmada.io/membercluster-controller"

	// ExecutionControllerFinalizer is added to PropagationWork to ensure manifests propagated to member cluster
	// is deleted before PropagationWork itself is deleted.
	ExecutionControllerFinalizer = "karmada.io/execution-controller"
)

Define finalizers used by karmada system.

Variables

This section is empty.

Functions

func CreateClusterRole

func CreateClusterRole(client kubeclient.Interface, clusterRoleObj *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)

CreateClusterRole just try to create the ClusterRole.

func CreateClusterRoleBinding

func CreateClusterRoleBinding(client kubeclient.Interface, clusterRoleBindingObj *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)

CreateClusterRoleBinding just try to create the ClusterRoleBinding.

func CreateNamespace

func CreateNamespace(client kubeclient.Interface, namespaceObj *corev1.Namespace) (*corev1.Namespace, error)

CreateNamespace just try to create the namespace.

func CreateSecret

func CreateSecret(client kubeclient.Interface, secret *corev1.Secret) (*corev1.Secret, error)

CreateSecret just try to create the secret.

func CreateServiceAccount

func CreateServiceAccount(client kubeclient.Interface, saObj *corev1.ServiceAccount) (*corev1.ServiceAccount, error)

CreateServiceAccount just try to create the ServiceAccount.

func DeleteClusterRole

func DeleteClusterRole(client kubeclient.Interface, name string) error

DeleteClusterRole just try to delete the ClusterRole.

func DeleteClusterRoleBinding

func DeleteClusterRoleBinding(client kubeclient.Interface, name string) error

DeleteClusterRoleBinding just try to delete the ClusterRoleBinding.

func DeleteNamespace

func DeleteNamespace(client kubeclient.Interface, namespace string) error

DeleteNamespace just try to delete the namespace.

func DeleteSecret

func DeleteSecret(client kubeclient.Interface, namespace, name string) error

DeleteSecret just try to delete the secret.

func DeleteServiceAccount

func DeleteServiceAccount(client kubeclient.Interface, namespace, name string) error

DeleteServiceAccount just try to delete the ServiceAccount.

func GenerateKey

func GenerateKey(obj runtime.Object) (string, error)

GenerateKey generates a key from obj, the key contains cluster, GVK, namespace and name.

func GetDifferenceSet

func GetDifferenceSet(includeItems, excludeItems []string) []string

GetDifferenceSet will get difference set from includeItems and excludeItems.

func GetLabelValue

func GetLabelValue(labels map[string]string, labelKey string) string

GetLabelValue retrieves the value via 'labelKey' if exist, otherwise returns an empty string.

func GetMemberCluster

func GetMemberCluster(hostClient client.Client, clusterName string) (*v1alpha1.MemberCluster, error)

GetMemberCluster returns the given MemberCluster resource

func GetTargetSecret

func GetTargetSecret(client kubeclient.Interface, secretReferences []corev1.ObjectReference, targetType corev1.SecretType, targetNamespace string) (*corev1.Secret, error)

GetTargetSecret will get secrets(type=targetType, namespace=targetNamespace) from a list of secret references.

func GetUniqueElements

func GetUniqueElements(list []string) []string

GetUniqueElements will delete duplicate element in list.

func IsClusterRoleBindingExist

func IsClusterRoleBindingExist(client kubeclient.Interface, name string) (bool, error)

IsClusterRoleBindingExist tells if specific ClusterRole already exists.

func IsClusterRoleExist

func IsClusterRoleExist(client kubeclient.Interface, name string) (bool, error)

IsClusterRoleExist tells if specific ClusterRole already exists.

func IsMemberClusterReady

func IsMemberClusterReady(clusterStatus *v1alpha1.MemberClusterStatus) bool

IsMemberClusterReady tells whether the cluster status in 'Ready' condition.

func IsNamespaceExist

func IsNamespaceExist(client kubeclient.Interface, namespace string) (bool, error)

IsNamespaceExist tells if specific already exists.

func IsServiceAccountExist

func IsServiceAccountExist(client kubeclient.Interface, namespace string, name string) (bool, error)

IsServiceAccountExist tells if specific service account already exists.

func MergeLabel

func MergeLabel(obj *unstructured.Unstructured, labelKey string, labelValue string)

MergeLabel adds label for the given object.

func PatchSecret

func PatchSecret(client kubeclient.Interface, namespace, name string, pt types.PatchType, patchSecretBody *corev1.Secret) error

PatchSecret just try to patch the secret.

Types

type AsyncWorker

type AsyncWorker interface {
	EnqueueRateLimited(obj runtime.Object)
	Run(workerNumber int, stopChan <-chan struct{})
}

AsyncWorker is a worker to process resources periodic with a rateLimitingQueue.

func NewAsyncWorker

func NewAsyncWorker(reconcile ReconcileHandler, name string, interval time.Duration) AsyncWorker

NewAsyncWorker returns a asyncWorker which can process resource periodic.

type ClusterClient

type ClusterClient struct {
	KubeClient  *kubeclientset.Clientset
	ClusterName string
}

ClusterClient stands for a cluster Clientset for the given member cluster

func NewClusterClientSet

func NewClusterClientSet(c *v1alpha1.MemberCluster, client kubeclientset.Interface) (*ClusterClient, error)

NewClusterClientSet returns a ClusterClient for the given member cluster.

type ClusterWorkload

type ClusterWorkload struct {
	GVK       schema.GroupVersionKind
	Cluster   string
	Namespace string
	Name      string
}

ClusterWorkload is the thumbnail of cluster workload, it contains GVK, cluster, namespace and name.

func SplitMetaKey

func SplitMetaKey(key string) (ClusterWorkload, error)

SplitMetaKey transforms key to struct ClusterWorkload, struct ClusterWorkload contains cluster, GVK, namespace and name.

func (*ClusterWorkload) GetListerKey

func (w *ClusterWorkload) GetListerKey() string

GetListerKey returns the key that can be used to query full object information by GenericLister

type DynamicClusterClient

type DynamicClusterClient struct {
	DynamicClientSet dynamic.Interface
	ClusterName      string
}

DynamicClusterClient stands for a dynamic client for the given member cluster

func BuildDynamicClusterClient

func BuildDynamicClusterClient(hostClient client.Client, kubeClient kubeclientset.Interface, cluster string) (*DynamicClusterClient, error)

BuildDynamicClusterClient builds dynamic client for informerFactory by clusterName, it will build kubeconfig from memberCluster resource and construct dynamic client.

func NewClusterDynamicClientSet

func NewClusterDynamicClientSet(c *v1alpha1.MemberCluster, client kubeclientset.Interface) (*DynamicClusterClient, error)

NewClusterDynamicClientSet returns a dynamic client for the given member cluster.

type ReconcileHandler

type ReconcileHandler func(key string) error

ReconcileHandler is a callback function for process resources.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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