helper

package
v2.21.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	UserServiceAccountPrefix = "serviceaccount-"
)

Variables

This section is empty.

Functions

func CCMMigrationCompleted

func CCMMigrationCompleted(cluster *kubermaticv1.Cluster) bool

func ClusterReconcileWrapper

func ClusterReconcileWrapper(
	ctx context.Context,
	client ctrlruntimeclient.Client,
	workerName string,
	cluster *kubermaticv1.Cluster,
	versions kubermatic.Versions,
	conditionType kubermaticv1.ClusterConditionType,
	reconcile func() (*reconcile.Result, error),
) (*reconcile.Result, error)

ClusterReconcileWrapper is a wrapper that should be used around any cluster reconciliaton. It:

  • Checks if the cluster is paused
  • Checks if the worker-name matches
  • Sets the ReconcileSuccess condition for the controller by fetching the current Cluster object and patching its status.

func ClusterReconciliationSuccessful

func ClusterReconciliationSuccessful(cluster *kubermaticv1.Cluster, versions kubermatic.Versions, ignoreKubermaticVersion bool) (missingConditions []kubermaticv1.ClusterConditionType, success bool)

ClusterReconciliationSuccessful checks if cluster has all conditions that are required for it to be healthy. ignoreKubermaticVersion should only be set in tests.

func EnsureProjectServiceAccountPrefix added in v2.21.0

func EnsureProjectServiceAccountPrefix(str string) string

EnsureProjectServiceAccountPrefix adds "serviceaccount-" prefix to a SA's ID, for example given "7d4b5695vb" it returns "serviceaccount-7d4b5695vb".

func GetHealthStatus

func GetHealthStatus(status kubermaticv1.HealthStatus, cluster *kubermaticv1.Cluster, versions kubermatic.Versions) kubermaticv1.HealthStatus

We assume that the cluster is still provisioning if it was not initialized fully at least once.

func HasProvider

func HasProvider(p *kubermaticv1.Preset, providerType kubermaticv1.ProviderType) (bool, reflect.Value)

func IsClusterInitialized

func IsClusterInitialized(cluster *kubermaticv1.Cluster, versions kubermatic.Versions) bool

func IsProjectServiceAccount added in v2.21.0

func IsProjectServiceAccount(nameOrEmail string) bool

IsProjectServiceAccount determines whether the given email address or user object name belongs to a project service account. For a service account, they must have the UserServiceAccountPrefix.

func IsProviderEnabled

func IsProviderEnabled(p *kubermaticv1.Preset, provider kubermaticv1.ProviderType) bool

func NeedCCMMigration

func NeedCCMMigration(cluster *kubermaticv1.Cluster) bool

func OverrideProvider

func OverrideProvider(p *kubermaticv1.Preset, providerType kubermaticv1.ProviderType, newPreset *kubermaticv1.Preset) *kubermaticv1.Preset

func RemoveProjectServiceAccountPrefix added in v2.21.0

func RemoveProjectServiceAccountPrefix(str string) string

RemoveProjectServiceAccountPrefix removes "serviceaccount-" from a SA's ID, for example given "serviceaccount-7d4b5695vb" it returns "7d4b5695vb".

func RemoveProvider

func RemoveProvider(p *kubermaticv1.Preset, providerType kubermaticv1.ProviderType) *kubermaticv1.Preset

func SetClusterCondition

func SetClusterCondition(
	c *kubermaticv1.Cluster,
	v kubermatic.Versions,
	conditionType kubermaticv1.ClusterConditionType,
	status corev1.ConditionStatus,
	reason string,
	message string,
)

SetClusterCondition sets a condition on the given cluster using the provided type, status, reason and message. It also adds the Kubermatic version and timestamps.

func SetProviderEnabled

func SetProviderEnabled(p *kubermaticv1.Preset, providerType kubermaticv1.ProviderType, enabled bool)

func SetSeedCondition added in v2.21.0

func SetSeedCondition(seed *kubermaticv1.Seed, conditionType kubermaticv1.SeedConditionType, status corev1.ConditionStatus, reason string, message string)

SetSeedCondition sets a condition on the given seed using the provided type, status, reason and message.

func UpdateClusterStatus added in v2.20.0

func UpdateClusterStatus(ctx context.Context, client ctrlruntimeclient.Client, cluster *kubermaticv1.Cluster, patch ClusterPatchFunc) error

UpdateClusterStatus will attempt to patch the cluster status of the given cluster.

func UpdateKubermaticConfigurationStatus added in v2.21.0

func UpdateKubermaticConfigurationStatus(ctx context.Context,
	client ctrlruntimeclient.Client,
	kc *kubermaticv1.KubermaticConfiguration,
	patch KubermaticConfigurationPatchFunc,
) error

func UpdateResourceQuotaStatus added in v2.21.0

func UpdateResourceQuotaStatus(ctx context.Context, client ctrlruntimeclient.Client, resourceQuota *kubermaticv1.ResourceQuota, patch ResourceQuotaPatchFunc) error

UpdateResourceQuotaStatus will attempt to patch the resource quota status of the given resource quota.

func UpdateSeedStatus added in v2.21.0

func UpdateSeedStatus(ctx context.Context, client ctrlruntimeclient.Client, seed *kubermaticv1.Seed, patch SeedPatchFunc) error

func Validate

func Validate(p *kubermaticv1.Preset, providerType kubermaticv1.ProviderType) error

Types

type ClusterPatchFunc added in v2.20.0

type ClusterPatchFunc func(cluster *kubermaticv1.Cluster)

type KubermaticConfigurationPatchFunc added in v2.21.0

type KubermaticConfigurationPatchFunc func(kc *kubermaticv1.KubermaticConfiguration)

type ResourceQuotaPatchFunc added in v2.21.0

type ResourceQuotaPatchFunc func(resourceQuota *kubermaticv1.ResourceQuota)

type SeedPatchFunc added in v2.21.0

type SeedPatchFunc func(seed *kubermaticv1.Seed)

Jump to

Keyboard shortcuts

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