kubernetes

package
v3.0.0-...-d6c4d9c Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RevisionAnnotation is the revision annotation of a deployment's replica sets which records its rollout sequence.
	RevisionAnnotation = "deployment.kubernetes.io/revision"
	// NodeControlPlaneLabel is the label on kubernetes control plane nodes.
	NodeControlPlaneLabel = "node-role.kubernetes.io/control-plane"
)

Variables

This section is empty.

Functions

func AddFinalizer

func AddFinalizer(obj metav1.Object, finalizers ...string)

AddFinalizer will add the given finalizer to the object. It uses a StringSet to avoid duplicates.

func ContainerFromString

func ContainerFromString(containerSpec string) (*corev1.Container, error)

func EnsureLabels

func EnsureLabels(o metav1.Object, toEnsure map[string]string)

func EnsureOwnerReference

func EnsureOwnerReference(o metav1.Object, ref metav1.OwnerReference)

EnsureOwnerReference will add the given owner reference to the object if it doesn't exist yet. Other references with the same name can exist.

func EnsureUniqueOwnerReference

func EnsureUniqueOwnerReference(o metav1.Object, ref metav1.OwnerReference)

EnsureUniqueOwnerReference will remove any owner ref with the same APIVersion and Kind, and then add the given ref to the owner references. This ensures that only one ref with a given kind exists.

func GenerateToken

func GenerateToken() string

GenerateToken generates a new, random token that can be used as an admin and kubelet token.

func GetClusterClient

func GetClusterClient(ctx context.Context, cluster *kubermaticv1.ExternalCluster, masterClient ctrlruntimeclient.Client) (*kubernetes.Clientset, error)

func GetContainerRuntime

func GetContainerRuntime(ctx context.Context,
	clusterClient *kubernetes.Clientset,
) (string, error)

func GetDeploymentCondition

func GetDeploymentCondition(status appsv1.DeploymentStatus, condType appsv1.DeploymentConditionType) *appsv1.DeploymentCondition

GetDeploymentCondition returns the condition with the provided type.

func GetNodeGroupReadyCount

func GetNodeGroupReadyCount(nodes *corev1.NodeList, providerNodeLabel, providerNodePoolName string) int32

func GetVersion

func GetVersion(client *kubernetes.Clientset) (*ksemver.Semver, error)

func HasAnyFinalizer

func HasAnyFinalizer(o metav1.Object, names ...string) bool

func HasFinalizer

func HasFinalizer(o metav1.Object, names ...string) bool

HasFinalizer tells if a object has all the given finalizers.

func HasFinalizerSuperset

func HasFinalizerSuperset(o metav1.Object, names ...string) bool

HasFinalizerSuperset tells if the given finalizer(s) are a superset of the actual finalizers.

func HasOnlyFinalizer

func HasOnlyFinalizer(o metav1.Object, names ...string) bool

HasOnlyFinalizer tells if an object has only the given finalizer(s).

func HasOwnerReference

func HasOwnerReference(o metav1.Object, ref metav1.OwnerReference) bool

func IsDeploymentRolloutComplete

func IsDeploymentRolloutComplete(deployment *appsv1.Deployment, revision int64) (bool, error)

IsDeploymentRolloutComplete returns a bool saying whether the deployment completed and an error in case an unexpected condition arrives.

based on: https://github.com/kubernetes/kubernetes/blob/252887e39f905389156d2bc9c5932688857588e4/staging/src/k8s.io/kubectl/pkg/polymorphichelpers/rollout_status.go#L59

func IsNodeReady

func IsNodeReady(node *corev1.Node) bool

IsNodeReady returns true if a node is ready; false otherwise.

func RemoveFinalizer

func RemoveFinalizer(obj metav1.Object, toRemove ...string)

RemoveFinalizer removes the given finalizers from the object.

func RemoveOwnerReferenceKinds

func RemoveOwnerReferenceKinds(o metav1.Object, refKindsToRemove ...metav1.OwnerReference)

RemoveOwnerReferenceKinds removes any reference with the same APIVersion and Kind, notably ignoring the name.

func RemoveOwnerReferences

func RemoveOwnerReferences(o metav1.Object, refToRemoves ...metav1.OwnerReference)

RemoveOwnerReference removes any reference that has the same APIVersion, Kind and Name.

func Revision

func Revision(obj runtime.Object) (int64, error)

Revision returns the revision number of the input object.

func SortOwnerReferences

func SortOwnerReferences(refs []metav1.OwnerReference)

func TryAddFinalizer

func TryAddFinalizer(ctx context.Context, client ctrlruntimeclient.Client, obj ctrlruntimeclient.Object, finalizers ...string) error

func TryRemoveFinalizer

func TryRemoveFinalizer(ctx context.Context, client ctrlruntimeclient.Client, obj ctrlruntimeclient.Object, finalizers ...string) error

func UpdateClusterStatus

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 UpdateDatacenterStatus

func UpdateDatacenterStatus(ctx context.Context, client ctrlruntimeclient.Client, datacenter *kubermaticv1.Datacenter, patch DatacenterPatchFunc) error

func ValidateKubernetesToken

func ValidateKubernetesToken(token string) error

ValidateKubernetesToken checks if a given token is syntactically correct.

func ValidateSecretKeySelector

func ValidateSecretKeySelector(selector *kubermaticv1.GlobalSecretKeySelector, key string) error

Types

type ClusterPatchFunc

type ClusterPatchFunc func(cluster *kubermaticv1.Cluster)

type DatacenterPatchFunc

type DatacenterPatchFunc func(datacenter *kubermaticv1.Datacenter)

type KubermaticConfigurationPatchFunc

type KubermaticConfigurationPatchFunc func(kc *kubermaticv1.KubermaticConfiguration)

type SeedClientMap

type SeedClientMap map[string]ctrlruntimeclient.Client

func (SeedClientMap) Each

func (m SeedClientMap) Each(ctx context.Context, log *zap.SugaredLogger, visitor SeedVisitorFunc) error

type SeedVisitorFunc

type SeedVisitorFunc func(seedName string, seedClient ctrlruntimeclient.Client, log *zap.SugaredLogger) error

Jump to

Keyboard shortcuts

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