Documentation ¶
Overview ¶
TODO add unit test for the following functions, right now they are only covered in e2e
Index ¶
- Variables
- func AddManagedClusterFinalizer(modified *bool, managedCluster *clusterv1.ManagedCluster, finalizer string)
- func ApplyCustomResourceDefinitionV1Beta1(client apiextclientv1beta1.CustomResourceDefinitionsGetter, ...) (*crdv1beta1.CustomResourceDefinition, bool, error)
- func ApplyResources(clientHolder *ClientHolder, recorder events.Recorder, scheme *runtime.Scheme, ...) (bool, error)
- func AssertManifestWorkFinalizer(ctx context.Context, runtimeClient client.Client, recorder events.Recorder, ...) error
- func ContainAuthError(err error) bool
- func ContainInternalServerError(err error) bool
- func DeleteAutoImportSecret(ctx context.Context, kubeClient kubernetes.Interface, secret *corev1.Secret, ...) error
- func DeleteManagedClusterAddons(ctx context.Context, runtimeClient client.Client, ...) error
- func DeleteManifestWork(ctx context.Context, workClient workclient.Interface, recorder events.Recorder, ...) error
- func DeleteManifestWorkWithSelector(ctx context.Context, workClient workclient.Interface, recorder events.Recorder, ...) error
- func DetermineKlusterletMode(cluster *clusterv1.ManagedCluster) operatorv1.InstallMode
- func ForceDeleteAllManagedClusterAddons(ctx context.Context, runtimeClient client.Client, ...) error
- func ForceDeleteAllManifestWorks(ctx context.Context, workClient workclient.Interface, recorder events.Recorder, ...) error
- func ForceDeleteManagedClusterAddon(ctx context.Context, runtimeClient client.Client, recorder events.Recorder, ...) error
- func ForceDeleteManifestWork(ctx context.Context, workClient workclient.Interface, recorder events.Recorder, ...) error
- func GetComponentNamespace() (string, error)
- func GetHostingCluster(cluster *clusterv1.ManagedCluster) (string, error)
- func GetMaxConcurrentReconciles() int
- func GetMergedKlusterletConfigWithGlobal(klusterletconfigName string, ...) (*klusterletconfigv1alpha1.KlusterletConfig, error)
- func GetNodeSelectorFromManagedClusterAnnotations(clusterAnnotations map[string]string) (map[string]string, error)
- func GetTolerationsFromManagedClusterAnnotations(clusterAnnotations map[string]string) ([]corev1.Toleration, error)
- func HasCertificates(supersetCertData, subsetCertData []byte) (bool, error)
- func ImportManagedClusterFromSecret(client *ClientHolder, restMapper meta.RESTMapper, recorder events.Recorder, ...) (bool, error)
- func ImportingResourcesApplied(condition *metav1.Condition) bool
- func IsAPIExtensionV1Supported(kubeVersion string) bool
- func IsClusterUnavailable(cluster *clusterv1.ManagedCluster) bool
- func IsKubeVersionChanged(objectOld, objectNew runtime.Object) bool
- func IsManifestWorksAvailable(ctx context.Context, client workclient.Interface, namespace string, ...) (bool, error)
- func ListManagedClusterAddons(ctx context.Context, runtimeClient client.Client, clusterName string) (*addonv1alpha1.ManagedClusterAddOnList, error)
- func ManifestsEqual(newManifests, oldManifests []workv1.Manifest) bool
- func MustCreateAssetFromTemplate(name string, tb []byte, config interface{}) []byte
- func MustCreateObject(raw []byte) runtime.Object
- func MustCreateObjectFromTemplate(file string, template []byte, config interface{}) runtime.Object
- func NewEventRecorder(kubeClient kubernetes.Interface, controllerName string) events.Recorder
- func NewManagedClusterEventRecorder(ctx context.Context, kubeClient kubernetes.Interface) kevents.EventRecorder
- func NewManagedClusterImportSucceededCondition(s metav1.ConditionStatus, reason, message string) metav1.Condition
- func NoManagedClusterAddons(ctx context.Context, runtimeClient client.Client, clusterName string) (bool, error)
- func NoPendingManifestWorks(ctx context.Context, log logr.Logger, clusterName string, ...) (bool, error)
- func RemoveManagedClusterFinalizer(ctx context.Context, runtimeClient client.Client, recorder events.Recorder, ...) error
- func ResourceIsNotFound(err error) bool
- func SplitYamls(yamls []byte) [][]byte
- func SupportPriorityClass(cluster *clusterv1.ManagedCluster) (bool, error)
- func UpdateManagedClusterBootstrapSecret(client *ClientHolder, importSecret *corev1.Secret, recorder events.Recorder) (bool, error)
- func UpdateManagedClusterImportCondition(client client.Client, managedCluster *clusterv1.ManagedCluster, ...) error
- func ValidateImportSecret(importSecret *corev1.Secret) error
- func ValidateKlusterletMode(mode operatorv1.InstallMode) error
- func ValidateNodeSelector(nodeSelector map[string]string) error
- func ValidateTolerations(tolerations []corev1.Toleration) error
- type ApplyResourcesFunc
- type ClientHolder
- func GenerateImportClientFromKubeConfigSecret(secret *corev1.Secret) (reconcile.Result, *ClientHolder, meta.RESTMapper, error)
- func GenerateImportClientFromKubeTokenSecret(secret *corev1.Secret) (reconcile.Result, *ClientHolder, meta.RESTMapper, error)
- func GenerateImportClientFromRosaCluster(getter *RosaKubeConfigGetter, secret *corev1.Secret) (reconcile.Result, *ClientHolder, meta.RESTMapper, error)
- type GenerateClientHolderFunc
- type ImportHelper
- func (i *ImportHelper) Import(backupRestore bool, cluster *clusterv1.ManagedCluster, ...) (reconcile.Result, metav1.Condition, bool, int, error)
- func (i *ImportHelper) WithApplyResourcesFunc(f ApplyResourcesFunc) *ImportHelper
- func (i *ImportHelper) WithGenerateClientHolderFunc(f GenerateClientHolderFunc) *ImportHelper
- type RosaKubeConfigGetter
- func (g *RosaKubeConfigGetter) Cleanup() error
- func (g *RosaKubeConfigGetter) KubeConfig() (bool, *clientcmdapi.Config, error)
- func (g *RosaKubeConfigGetter) SetAPIServerURL(apiServer string)
- func (g *RosaKubeConfigGetter) SetAuthMethod(authMethod string)
- func (g *RosaKubeConfigGetter) SetClientID(clientID string)
- func (g *RosaKubeConfigGetter) SetClientSecret(clientSecret string)
- func (g *RosaKubeConfigGetter) SetClusterID(clusterID string)
- func (g *RosaKubeConfigGetter) SetRetryTimes(retryTimes string)
- func (g *RosaKubeConfigGetter) SetToken(token string)
- func (g *RosaKubeConfigGetter) SetTokenURL(tokenURL string)
- type WorkSelector
Constants ¶
This section is empty.
Variables ¶
var DeployOnOCP bool = true
DeployOnOCP is set once at the beginning
Functions ¶
func AddManagedClusterFinalizer ¶
func AddManagedClusterFinalizer(modified *bool, managedCluster *clusterv1.ManagedCluster, finalizer string)
AddManagedClusterFinalizer add a finalizer to a managed cluster
func ApplyCustomResourceDefinitionV1Beta1 ¶
func ApplyCustomResourceDefinitionV1Beta1(client apiextclientv1beta1.CustomResourceDefinitionsGetter, recorder events.Recorder, required *crdv1beta1.CustomResourceDefinition) (*crdv1beta1.CustomResourceDefinition, bool, error)
In order to support ocp 311, copy this func from old library-go
func ApplyResources ¶
func ApplyResources(clientHolder *ClientHolder, recorder events.Recorder, scheme *runtime.Scheme, owner metav1.Object, objs ...runtime.Object) (bool, error)
ApplyResources apply resources, includes: serviceaccount, secret, deployment, clusterrole, clusterrolebinding, crdv1beta1, crdv1, manifestwork and klusterlet
func AssertManifestWorkFinalizer ¶
func AssertManifestWorkFinalizer(ctx context.Context, runtimeClient client.Client, recorder events.Recorder, cluster *clusterv1.ManagedCluster, works int) error
AssertManifestWorkFinalizer add/remove manifest finalizer for a managed cluster, this func will send request to api server to update managed cluster.
func ContainAuthError ¶
func DeleteAutoImportSecret ¶
func DeleteAutoImportSecret(ctx context.Context, kubeClient kubernetes.Interface, secret *corev1.Secret, recorder events.Recorder) error
DeleteAutoImportSecret delete the auto-import-secret if the secret does not have the keeping annotation
func DeleteManagedClusterAddons ¶
func DeleteManagedClusterAddons( ctx context.Context, runtimeClient client.Client, cluster *clusterv1.ManagedCluster, recorder events.Recorder, mcRecorder kevents.EventRecorder) error
DeleteManagedClusterAddons deletes all managedclusteraddons for the managed cluster
func DeleteManifestWork ¶
func DeleteManifestWork(ctx context.Context, workClient workclient.Interface, recorder events.Recorder, namespace, name string) error
DeleteManifestWork triggers the deletion action of the manifestwork
func DeleteManifestWorkWithSelector ¶
func DeleteManifestWorkWithSelector(ctx context.Context, workClient workclient.Interface, recorder events.Recorder, cluster *clusterv1.ManagedCluster, works []workv1.ManifestWork, ignoredSelector func(clusterName string, manifestWork workv1.ManifestWork) bool) error
DeleteManifestWorkWithSelector deletes manifestworks but ignores the ignoredSelector selected manifestworks
func DetermineKlusterletMode ¶
func DetermineKlusterletMode(cluster *clusterv1.ManagedCluster) operatorv1.InstallMode
DetermineKlusterletMode gets the klusterlet deploy mode for the managed cluster.
func ForceDeleteAllManagedClusterAddons ¶
func ForceDeleteAllManagedClusterAddons( ctx context.Context, runtimeClient client.Client, cluster *clusterv1.ManagedCluster, recorder events.Recorder, mcRecorder kevents.EventRecorder) error
ForceDeleteAllManagedClusterAddons delete all managed cluster addons forcefully
func ForceDeleteAllManifestWorks ¶
func ForceDeleteAllManifestWorks(ctx context.Context, workClient workclient.Interface, recorder events.Recorder, manifestWorks []workv1.ManifestWork) error
ForceDeleteAllManifestWorks delete all manifestworks forcefully
func ForceDeleteManagedClusterAddon ¶
func ForceDeleteManagedClusterAddon( ctx context.Context, runtimeClient client.Client, recorder events.Recorder, addonNamespace, addonName string) error
ForceDeleteManagedClusterAddon will delete the managedClusterAddon regardless of finalizers.
func ForceDeleteManifestWork ¶
func ForceDeleteManifestWork(ctx context.Context, workClient workclient.Interface, recorder events.Recorder, namespace, name string) error
ForceDeleteManifestWork will delete the manifestwork regardless of finalizers.
func GetComponentNamespace ¶
func GetHostingCluster ¶
func GetHostingCluster(cluster *clusterv1.ManagedCluster) (string, error)
GetHostingCluster gets the hosting cluster name from the managed cluster annotation
func GetMaxConcurrentReconciles ¶
func GetMaxConcurrentReconciles() int
GetMaxConcurrentReconciles get the max concurrent reconciles from MAX_CONCURRENT_RECONCILES env, if the reconciles cannot be found, return 1
func GetMergedKlusterletConfigWithGlobal ¶
func GetMergedKlusterletConfigWithGlobal( klusterletconfigName string, kcLister listerklusterletconfigv1alpha1.KlusterletConfigLister, ) (*klusterletconfigv1alpha1.KlusterletConfig, error)
func GetTolerationsFromManagedClusterAnnotations ¶
func GetTolerationsFromManagedClusterAnnotations(clusterAnnotations map[string]string) ([]corev1.Toleration, error)
func HasCertificates ¶
HasCertificates returns true if the supersetCertData contains all the certs in subsetCertData
func ImportManagedClusterFromSecret ¶
func ImportManagedClusterFromSecret(client *ClientHolder, restMapper meta.RESTMapper, recorder events.Recorder, importSecret *corev1.Secret) (bool, error)
ImportManagedClusterFromSecret use managed cluster client to import managed cluster from import-secret
func IsAPIExtensionV1Supported ¶
IsAPIExtensionV1Supported if the cluster can support the crdv1, return true
func IsClusterUnavailable ¶
func IsClusterUnavailable(cluster *clusterv1.ManagedCluster) bool
IsClusterUnavailable checks whether the cluster is unavilable
func IsKubeVersionChanged ¶
func ListManagedClusterAddons ¶
func ListManagedClusterAddons(ctx context.Context, runtimeClient client.Client, clusterName string) ( *addonv1alpha1.ManagedClusterAddOnList, error)
ListManagedClusterAddons lists all managedclusteraddons for the managed cluster
func ManifestsEqual ¶
ManifestsEqual if two manifests are equal, return true
func MustCreateAssetFromTemplate ¶
MustCreateAssetFromTemplate render a template with its configuration If it's failed, this function will panic
func MustCreateObject ¶
MustCreateObject translate object from raw bytes to runtime object
func MustCreateObjectFromTemplate ¶
MustCreateObjectFromTemplate render a template to a runtime object with its configuration If it's failed, this function will panic
func NewEventRecorder ¶
func NewEventRecorder(kubeClient kubernetes.Interface, controllerName string) events.Recorder
func NewManagedClusterEventRecorder ¶
func NewManagedClusterEventRecorder(ctx context.Context, kubeClient kubernetes.Interface) kevents.EventRecorder
func NewManagedClusterImportSucceededCondition ¶
func NewManagedClusterImportSucceededCondition(s metav1.ConditionStatus, reason, message string) metav1.Condition
func NoManagedClusterAddons ¶
func NoManagedClusterAddons(ctx context.Context, runtimeClient client.Client, clusterName string) (bool, error)
NoManagedClusterAddons checks whether there are managedclusteraddons for the managed cluster
func NoPendingManifestWorks ¶
func NoPendingManifestWorks(ctx context.Context, log logr.Logger, clusterName string, manifestWorks []workv1.ManifestWork, ignoredSelector WorkSelector) (bool, error)
NoPendingManifestWorks checks whether there are pending manifestworks for the managed cluster
func RemoveManagedClusterFinalizer ¶
func RemoveManagedClusterFinalizer(ctx context.Context, runtimeClient client.Client, recorder events.Recorder, managedCluster *clusterv1.ManagedCluster, finalizer string) error
RemoveManagedClusterFinalizer remove a finalizer from a managed cluster
func ResourceIsNotFound ¶
func SupportPriorityClass ¶
func SupportPriorityClass(cluster *clusterv1.ManagedCluster) (bool, error)
func UpdateManagedClusterBootstrapSecret ¶
func UpdateManagedClusterBootstrapSecret(client *ClientHolder, importSecret *corev1.Secret, recorder events.Recorder) (bool, error)
UpdateManagedClusterBootstrapSecret update the bootstrap secret on the managed cluster
func UpdateManagedClusterImportCondition ¶
func UpdateManagedClusterImportCondition(client client.Client, managedCluster *clusterv1.ManagedCluster, cond metav1.Condition, recorder kevents.EventRecorder) error
UpdateManagedClusterImportCondition update managed cluster status and record the event
func ValidateImportSecret ¶
ValidateImportSecret validate managed cluster import secret
func ValidateKlusterletMode ¶
func ValidateKlusterletMode(mode operatorv1.InstallMode) error
func ValidateNodeSelector ¶
refer to https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/validation/validation.go#L3498
func ValidateTolerations ¶
func ValidateTolerations(tolerations []corev1.Toleration) error
refer to https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/validation/validation.go#L3330
Types ¶
type ApplyResourcesFunc ¶
type ApplyResourcesFunc func(backupRestore bool, client *ClientHolder, restMapper meta.RESTMapper, recorder events.Recorder, importSecret *corev1.Secret) (bool, error)
ApplyResourcesFunc is a function to apply resources to the manged cluster to import it to the hub
type ClientHolder ¶
type ClientHolder struct { KubeClient kubernetes.Interface APIExtensionsClient apiextensionsclient.Interface OperatorClient operatorclient.Interface RuntimeClient client.Client RuntimeAPIReader client.Reader ImageRegistryClient imageregistry.Interface WorkClient workclient.Interface }
func GenerateImportClientFromKubeConfigSecret ¶
func GenerateImportClientFromKubeConfigSecret(secret *corev1.Secret) (reconcile.Result, *ClientHolder, meta.RESTMapper, error)
GenerateImportClientFromKubeConfigSecret generate a client from a given secret that contains a kubeconfig
func GenerateImportClientFromKubeTokenSecret ¶
func GenerateImportClientFromKubeTokenSecret(secret *corev1.Secret) (reconcile.Result, *ClientHolder, meta.RESTMapper, error)
GenerateImportClientFromKubeTokenSecret generate a client from a given secret that contains kube apiserver and token
func GenerateImportClientFromRosaCluster ¶
func GenerateImportClientFromRosaCluster(getter *RosaKubeConfigGetter, secret *corev1.Secret) (reconcile.Result, *ClientHolder, meta.RESTMapper, error)
GenerateImportClientFromRosaCluster generate a client from a given secret that contains rosa cluster info
type GenerateClientHolderFunc ¶
type GenerateClientHolderFunc func(secret *corev1.Secret) (reconcile.Result, *ClientHolder, meta.RESTMapper, error)
GenerateClientHolderFunc is a function to generate the managed cluster client holder which is used to import cluster(apply resources to the managed cluster)
type ImportHelper ¶
type ImportHelper struct {
// contains filtered or unexported fields
}
ImportHelper is used to helper controller to import managed cluster
func NewImportHelper ¶
func NewImportHelper(informerHolder *source.InformerHolder, recorder events.Recorder, log logr.Logger) *ImportHelper
func (*ImportHelper) Import ¶
func (i *ImportHelper) Import(backupRestore bool, cluster *clusterv1.ManagedCluster, managedClusterKubeClientSecret *corev1.Secret, lastRetry, totalRetry int) ( reconcile.Result, metav1.Condition, bool, int, error)
Import uses the managedClusterKubeClientSecret to generate a managed cluster client, then use this client to import the managed cluster, return managed cluster import condition when finished apply
func (*ImportHelper) WithApplyResourcesFunc ¶
func (i *ImportHelper) WithApplyResourcesFunc(f ApplyResourcesFunc) *ImportHelper
func (*ImportHelper) WithGenerateClientHolderFunc ¶
func (i *ImportHelper) WithGenerateClientHolderFunc(f GenerateClientHolderFunc) *ImportHelper
type RosaKubeConfigGetter ¶
type RosaKubeConfigGetter struct {
// contains filtered or unexported fields
}
func NewRosaKubeConfigGetter ¶
func NewRosaKubeConfigGetter() *RosaKubeConfigGetter
func (*RosaKubeConfigGetter) Cleanup ¶
func (g *RosaKubeConfigGetter) Cleanup() error
func (*RosaKubeConfigGetter) KubeConfig ¶
func (g *RosaKubeConfigGetter) KubeConfig() (bool, *clientcmdapi.Config, error)
func (*RosaKubeConfigGetter) SetAPIServerURL ¶
func (g *RosaKubeConfigGetter) SetAPIServerURL(apiServer string)
func (*RosaKubeConfigGetter) SetAuthMethod ¶
func (g *RosaKubeConfigGetter) SetAuthMethod(authMethod string)
func (*RosaKubeConfigGetter) SetClientID ¶
func (g *RosaKubeConfigGetter) SetClientID(clientID string)
func (*RosaKubeConfigGetter) SetClientSecret ¶
func (g *RosaKubeConfigGetter) SetClientSecret(clientSecret string)
func (*RosaKubeConfigGetter) SetClusterID ¶
func (g *RosaKubeConfigGetter) SetClusterID(clusterID string)
func (*RosaKubeConfigGetter) SetRetryTimes ¶
func (g *RosaKubeConfigGetter) SetRetryTimes(retryTimes string)
func (*RosaKubeConfigGetter) SetToken ¶
func (g *RosaKubeConfigGetter) SetToken(token string)
func (*RosaKubeConfigGetter) SetTokenURL ¶
func (g *RosaKubeConfigGetter) SetTokenURL(tokenURL string)
type WorkSelector ¶
type WorkSelector func(string, workv1.ManifestWork) bool