helpers

package
v0.0.0-...-b86b35d Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Overview

Copyright Contributors to the Open Cluster Management project

Copyright Contributors to the Open Cluster Management project

Index

Constants

View Source
const (
	FeatureGatesTypeValid             = "ValidFeatureGates"
	FeatureGatesReasonAllValid        = "FeatureGatesAllValid"
	FeatureGatesReasonInvalidExisting = "InvalidFeatureGatesExisting"
)
View Source
const (
	// KlusterletDefaultNamespace is the default namespace of klusterlet
	KlusterletDefaultNamespace = "open-cluster-management-agent"

	// BootstrapHubKubeConfig is the secret name of bootstrap kubeconfig secret to connect to hub
	BootstrapHubKubeConfig             = "bootstrap-hub-kubeconfig"
	ControlplaneBootstrapHubKubeConfig = "multicluster-controlplane-svc-kubeconfig"

	// HubKubeConfig is the secret name of kubeconfig secret to connect to hub with mtls
	HubKubeConfig = "hub-kubeconfig-secret"

	// ManagedClusterKubeConfig is the secret name of kubeconfig secret, it is provied by user in the managed cluster
	// namespace on the controlplane, it only applicable to Hosted mode, klusterlet uses it to install resources
	// on the managed cluster.
	ManagedClusterKubeConfig = "managedcluster-kubeconfig"
	// ExternalManagedClusterKubeConfig is the secret name of kubeconfig secret, it is created by klusterlet with
	// ManagedClusterKubeConfig, it is in the controlplane namespace on the management cluster, it only applicable to
	// Hosted mode, controlplane agent uses it connecting to the managed cluster.
	ExternalManagedClusterKubeConfig = "external-managedcluster-kubeconfig"
)
View Source
const KlusterletOwnerAnnotation = "operator.open-cluster-management.io/klusterlet-owner"

Variables

This section is empty.

Functions

func AgentNamespace

func AgentNamespace(klusterlet *operatorapiv1.Klusterlet) string

AgentNamespace returns the namespace to deploy the agents. It is on the managed cluster in the Default mode, and on the management cluster in the Hosted mode.

func ApplyDirectly

func ApplyDirectly(
	ctx context.Context,
	client kubernetes.Interface,
	apiExtensionClient apiextensionsclient.Interface,
	recorder events.Recorder,
	cache resourceapply.ResourceCache,
	manifests resourceapply.AssetFunc,
	files ...string) []resourceapply.ApplyResult

func ApplyEndpoints

func ApplyEndpoints(ctx context.Context, client coreclientv1.EndpointsGetter, required *corev1.Endpoints) (*corev1.Endpoints, bool, error)

func BootstrapHubKubeConfigSecret

func BootstrapHubKubeConfigSecret(klusterlet *operatorapiv1.Klusterlet) string

func BuildFeatureCondition

func BuildFeatureCondition(invalidMsgs ...string) metav1.Condition

func CleanUpStaticObject

func CleanUpStaticObject(
	ctx context.Context,
	client kubernetes.Interface,
	apiExtensionClient apiextensionsclient.Interface,
	apiRegistrationClient apiregistrationclient.APIServicesGetter,
	manifests resourceapply.AssetFunc,
	file string) error

func ClusterName

func ClusterName(klusterlet *operatorapiv1.Klusterlet) string

func ConvertToFeatureGateFlags

func ConvertToFeatureGateFlags(component string, features []operatorapiv1.FeatureGate, defaultFeatureGates map[featuregate.Feature]featuregate.FeatureSpec) ([]string, string)

func DeleteAllManifestWorks

func DeleteAllManifestWorks(
	ctx context.Context, workClient workclient.Interface, manifestWorks []workv1.ManifestWork, force bool) error

func DeleteManagedCluster

func DeleteManagedCluster(ctx context.Context, clusterClient clusterclient.Interface, clusterName string) error

func DeletePolicies

func DeletePolicies(ctx context.Context, dynamicClient dynamic.Interface, clusterName string) error

func ExternalManagedClusterKubeConfigSecret

func ExternalManagedClusterKubeConfigSecret(klusterlet *operatorapiv1.Klusterlet) string

func FeatureGateEnabled

func FeatureGateEnabled(features []operatorapiv1.FeatureGate, defaultFeatures map[featuregate.Feature]featuregate.FeatureSpec, featureName featuregate.Feature) bool

FeatureGateEnabled checks if a feature is enabled or disabled in operator API, or fallback to use the the default setting

func FindGenerationStatus

func FindGenerationStatus(generationStatuses []operatorapiv1.GenerationStatus, generation operatorapiv1.GenerationStatus) *operatorapiv1.GenerationStatus

func FindKlusterletByNamespace

func FindKlusterletByNamespace(klusterlets []*operatorapiv1.Klusterlet, namespace string) *operatorapiv1.Klusterlet

func FindRelatedResourcesStatus

func FindRelatedResourcesStatus(
	relatedResourcesStatuses []operatorapiv1.RelatedResourceMeta,
	relatedResource operatorapiv1.RelatedResourceMeta) *operatorapiv1.RelatedResourceMeta

func GenerateRelatedResource

func GenerateRelatedResource(objBytes []byte) (operatorapiv1.RelatedResourceMeta, error)

func GetComponentNamespace

func GetComponentNamespace() string

func HubKubeConfigSecret

func HubKubeConfigSecret(klusterlet *operatorapiv1.Klusterlet) string

func IsClusterUnavailable

func IsClusterUnavailable(ctx context.Context, clusterClient clusterclient.Interface, name string) (bool, error)

func KlusterletDeploymentQueueKeyFunc

func KlusterletDeploymentQueueKeyFunc(klusterletLister operatorlister.KlusterletLister) factory.ObjectQueueKeyFunc

func KlusterletNamespace

func KlusterletNamespace(klusterlet *operatorapiv1.Klusterlet) string

KlusterletNamespace returns the klusterlet namespace on the managed cluster.

func KlusterletSecretQueueKeyFunc

func KlusterletSecretQueueKeyFunc(klusterletLister operatorlister.KlusterletLister) factory.ObjectQueueKeyFunc

func LoadClientConfigFromSecret

func LoadClientConfigFromSecret(secret *corev1.Secret) (*rest.Config, error)

LoadClientConfigFromSecret returns a client config loaded from the given secret

func NumOfUnavailablePod

func NumOfUnavailablePod(deployment *appsv1.Deployment) int32

NumOfUnavailablePod is to check if a deployment is in degraded state.

func RemoveRelatedResourcesStatus

func RemoveRelatedResourcesStatus(
	relatedResourcesStatuses *[]operatorapiv1.RelatedResourceMeta,
	relatedResource operatorapiv1.RelatedResourceMeta)

func RemoveRelatedResourcesStatuses

func RemoveRelatedResourcesStatuses(
	relatedResourcesStatuses *[]operatorapiv1.RelatedResourceMeta,
	rmRelatedResourcesStatus operatorapiv1.RelatedResourceMeta)

func RemoveRelatedResourcesStatusesWithObj

func RemoveRelatedResourcesStatusesWithObj(
	relatedResourcesStatuses *[]operatorapiv1.RelatedResourceMeta, objData []byte)

func SetGenerationStatuses

func SetGenerationStatuses(generationStatuses *[]operatorapiv1.GenerationStatus, newGenerationStatus operatorapiv1.GenerationStatus)

func SetRelatedResourcesStatuses

func SetRelatedResourcesStatuses(
	relatedResourcesStatuses *[]operatorapiv1.RelatedResourceMeta,
	newRelatedResourcesStatus operatorapiv1.RelatedResourceMeta)

func SetRelatedResourcesStatusesWithObj

func SetRelatedResourcesStatusesWithObj(
	relatedResourcesStatuses *[]operatorapiv1.RelatedResourceMeta, objData []byte)

func SyncKubeConfigSecret

func SyncKubeConfigSecret(ctx context.Context, secretName, secretNamespace, kubeconfigPath string, templateKubeconfig *rest.Config, secretClient coreclientv1.SecretsGetter, tokenGetter TokenGetterFunc, recorder events.Recorder) error

func SyncSecret

func SyncSecret(ctx context.Context, client, targetClient coreclientv1.SecretsGetter, recorder events.Recorder,
	sourceNamespace, sourceName, targetNamespace, targetName string, ownerRefs []metav1.OwnerReference) (*corev1.Secret, bool, error)

SyncSecret forked from https://github.com/openshift/library-go/blob/d9cdfbd844ea08465b938c46a16bed2ea23207e4/pkg/operator/resource/resourceapply/core.go#L357, add an addition targetClient parameter to support sync secret to another cluster.

func UpdateKlusterletStatus

func UpdateKlusterletStatus(
	ctx context.Context,
	client operatorv1client.KlusterletInterface,
	klusterletName string,
	updateFuncs ...UpdateKlusterletStatusFunc) (*operatorapiv1.KlusterletStatus, bool, error)

Types

type TokenGetterFunc

type TokenGetterFunc func() ([]byte, []byte, error)

func SATokenGetter

func SATokenGetter(ctx context.Context, saName, saNamespace string, saClient kubernetes.Interface) TokenGetterFunc

SATokenGetter get the saToken of target sa. If there is not secrets in the sa, use the tokenrequest to get a token.

type UpdateKlusterletStatusFunc

type UpdateKlusterletStatusFunc func(status *operatorapiv1.KlusterletStatus) error

func UpdateKlusterletConditionFn

func UpdateKlusterletConditionFn(conds ...metav1.Condition) UpdateKlusterletStatusFunc

func UpdateKlusterletGenerationsFn

func UpdateKlusterletGenerationsFn(generations ...operatorapiv1.GenerationStatus) UpdateKlusterletStatusFunc

func UpdateKlusterletRelatedResourcesFn

func UpdateKlusterletRelatedResourcesFn(relatedResources ...operatorapiv1.RelatedResourceMeta) UpdateKlusterletStatusFunc

Jump to

Keyboard shortcuts

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