kubernetes

package
v0.119.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 31 Imported by: 7

Documentation

Index

Constants

View Source
const ErrImageNeverPull = "ErrImageNeverPull"

ErrImageNeverPull - Required Image is absent on host and PullPolicy is NeverPullImage

View Source
const ErrImagePull = "ErrImagePull"

ErrImagePull - General image pull error

View Source
const ErrImagePullBackOff = "ImagePullBackOff"

ErrImagePullBackOff - Container image pull failed, kubelet is backing off image pull

View Source
const ErrInvalidImageName = "ErrInvalidImageName"

ErrInvalidImageName - Unable to parse the image name.

View Source
const ErrRegistryUnavailable = "RegistryUnavailable"

ErrRegistryUnavailable - Get http error when pulling image from registry

Variables

This section is empty.

Functions

func AddServiceAccountAuth

func AddServiceAccountAuth(ctx context.Context, kubeClient client.Client, sa *corev1.ServiceAccount, config *rest.Config) error

AddServiceAccountAuth adds the authentication information of a service account to a rest config. It also waits for the secret with the token to be created.

func AddServiceAccountToken

func AddServiceAccountToken(ctx context.Context, kubeClient client.Client, sa *corev1.ServiceAccount, config *rest.Config) error

AddServiceAccountToken adds the authentication information of a service account to a rest config. It also waits until the token has been created.

func ConvertToRawExtension

func ConvertToRawExtension(from runtime.Object, scheme *runtime.Scheme) (*runtime.RawExtension, error)

ConvertToRawExtension converts a object to a raw extension. The type of the object is automatically set given the scheme.

func CoreObjectReferenceFromUnstructuredObject

func CoreObjectReferenceFromUnstructuredObject(obj *unstructured.Unstructured) *corev1.ObjectReference

CoreObjectReferenceFromUnstructuredObject creates a core object reference from an unstructured object.

func CreateOrUpdate

CreateOrUpdate creates or updates the given object in the Kubernetes cluster. The object's desired state must be reconciled with the existing state inside the passed in callback MutateFn. It also correctly handles objects that have the generateName attribute set.

The MutateFn is called regardless of creating or updating an object.

It returns the executed operation and an error.

func CreateSecretForServiceAccount

func CreateSecretForServiceAccount(ctx context.Context, kubeClient client.Client, serviceAccount *corev1.ServiceAccount) (*corev1.Secret, error)

func DecodeObjects

func DecodeObjects(log logging.Logger, name string, data []byte) ([]*unstructured.Unstructured, error)

DecodeObjects decodes raw data that can be a multiyaml file into unstructured kubernetes objects.

func DecodeObjectsToRawExtension

func DecodeObjectsToRawExtension(log logging.Logger, name string, data []byte) ([]*runtime.RawExtension, error)

DecodeObjectsToRawExtension decodes raw data that can be a multiyaml file into unstructured kubernetes objects.

func DeleteAndWaitForObjectDeleted

func DeleteAndWaitForObjectDeleted(ctx context.Context, kubeClient client.Client, timeout time.Duration, obj client.Object) error

DeleteAndWaitForObjectDeleted deletes an object and waits for the object to be deleted.

func GenerateDeleteObjectConditionFunc

func GenerateDeleteObjectConditionFunc(ctx context.Context, kubeClient client.Client, obj client.Object) wait.ConditionWithContextFunc

GenerateDeleteObjectConditionFunc creates a condition function to validate the deletion of objects.

func GenerateKubeconfig

func GenerateKubeconfig(restConfig *rest.Config) (clientcmdapi.Config, error)

GenerateKubeconfig generates a kubernetes kubeconfig config object from a rest config

func GenerateKubeconfigBytes

func GenerateKubeconfigBytes(restConfig *rest.Config) ([]byte, error)

GenerateKubeconfigBytes generates a kubernetes kubeconfig config object from a rest config and encodes it as yaml.

func GenerateKubeconfigJSONBytes

func GenerateKubeconfigJSONBytes(restConfig *rest.Config) ([]byte, error)

GenerateKubeconfigJSONBytes generates a kubernetes kubeconfig config object from a rest config and encodes it as json.

func GetMainOwnerFromOwnerReferences

func GetMainOwnerFromOwnerReferences(owners []metav1.OwnerReference) *metav1.OwnerReference

GetMainOwnerFromOwnerReferences returns the main owner from a list of owner references. If the list contains only a single reference, that one is returned. If multiple owners are defined, the controlling owner is returned. If there are multiple references and no controlling one, nil is returned.

func GetOwner

func GetOwner(objMeta metav1.ObjectMeta) *metav1.OwnerReference

GetOwner returns the owner reference of a object. If multiple owners are defined, the controlling owner is returned.

func GetSecretsForServiceAccount

func GetSecretsForServiceAccount(ctx context.Context, kubeClient client.Client, serviceAccountKey client.ObjectKey) ([]*corev1.Secret, error)

GetSecretsForServiceAccount returns the list of secrets of type "kubernetes.io/service-account-token" which belong to the given service account. The result list is sorted decreasingly by creation timestamp, so that it starts with the newest secret.

func GetStatusForContainer

func GetStatusForContainer(containerStatus []corev1.ContainerStatus, name string) (corev1.ContainerStatus, error)

GetStatusForContainer returns the container status for a specific container

func HasAnnotation

func HasAnnotation(obj metav1.Object, ann string) bool

HasAnnotation checks if the objects has a annotation

func HasAnnotationWithValue

func HasAnnotationWithValue(obj metav1.Object, ann string, value string) bool

HasAnnotationWithValue checks if the objects has a annotation with a value

func HasFinalizer

func HasFinalizer(obj metav1.Object, finalizer string) bool

HasFinalizer checks if the object constains a finalizer with the given name.

func HasLabel

func HasLabel(obj metav1.Object, lab string) bool

HasLabel checks if the objects has a label

func HasLabelWithValue

func HasLabelWithValue(obj metav1.Object, lab string, value string) bool

HasLabelWithValue checks if the objects has a label with a value

func HasOwnerReference

func HasOwnerReference(owned, owner client.Object, scheme *runtime.Scheme) (int, error)

HasOwnerReference returns the index of the owner reference if the 'owned' object has a owner reference pointing to the 'owner' object. If not, -1 is returned. Note that name and uid are only compared if set in the owner object. This means that the function will return a positive index for an owner object with empty name and uid if the owned object contains a owner reference which fits just apiversion and kind. The scheme argument may be nil if the owners GVK is populated.

func InjectTypeInformation

func InjectTypeInformation(obj runtime.Object, scheme *runtime.Scheme) error

InjectTypeInformation injects the group version kind into a runtime object. This is needed as this information gets lost when a struct is decoded.

func Mutate

Mutate wraps a MutateFn and applies validation to its result

func ObjectFromCoreObjectReference

func ObjectFromCoreObjectReference(ref *corev1.ObjectReference) *unstructured.Unstructured

ObjectFromCoreObjectReference creates an unstructured object from a core object reference.

func ObjectFromTypedObjectReference

func ObjectFromTypedObjectReference(ref *v1alpha1.TypedObjectReference) *unstructured.Unstructured

ObjectFromTypedObjectReference creates an unstructured object from a typed object reference.

func ObjectKey

func ObjectKey(name, namespace string) types.NamespacedName

ObjectKey creates a namespaced name (client.ObjectKey) for a given name and namespace.

func ObjectKeyFromObject

func ObjectKeyFromObject(obj metav1.Object) types.NamespacedName

ObjectKeyFromObject creates a namespaced name for a given object.

func OwnerOfGVK

func OwnerOfGVK(ownerRefs []metav1.OwnerReference, gvk schema.GroupVersionKind) (string, bool)

OwnerOfGVK validates whether a instance of the given gvk is referenced

func ParseFiles

func ParseFiles(log logging.Logger, files map[string]string) ([]*unstructured.Unstructured, error)

ParseFiles parses a map of filename->data into unstructured yaml objects.

func ParseFilesToRawExtension

func ParseFilesToRawExtension(log logging.Logger, files map[string]string) ([]*runtime.RawExtension, error)

ParseFilesToRawExtension parseslogging.Loggerilename->data into unstructured yaml objects.

func ReconcileRequestFromObject

func ReconcileRequestFromObject(obj client.Object) reconcile.Request

ReconcileRequestFromObject creates a namespaced name for a given object.

func ResolveSecrets

func ResolveSecrets(ctx context.Context, client client.Client, secretRefs []v1alpha1.ObjectReference) ([]corev1.Secret, error)

ResolveSecrets finds and returns the secrets referenced by secretRefs

func SetMetaDataLabel

func SetMetaDataLabel(obj metav1.Object, lab string, value string)

SetMetaDataLabel sets the label and value

func SetRequiredNestedFieldsFromObj

func SetRequiredNestedFieldsFromObj(currObj, obj *unstructured.Unstructured) error

SetRequiredNestedFieldsFromObj sets the immutable or the fields that are required when updating un object. e.g: the ClusterIP of a service.

func TypedObjectReferenceFromObject

func TypedObjectReferenceFromObject(obj runtime.Object, scheme *runtime.Scheme) (*v1alpha1.TypedObjectReference, error)

TypedObjectReferenceFromObject creates a typed object reference from a object.

func TypedObjectReferenceFromUnstructuredObject

func TypedObjectReferenceFromUnstructuredObject(obj *unstructured.Unstructured) *v1alpha1.TypedObjectReference

TypedObjectReferenceFromUnstructuredObject creates a typed object reference from an unstructured object.

func WaitForServiceAccountToken

func WaitForServiceAccountToken(ctx context.Context, kubeClient client.Client, secretKey client.ObjectKey) error

Types

This section is empty.

Directories

Path Synopsis
Package mock_client is a generated GoMock package.
Package mock_client is a generated GoMock package.

Jump to

Keyboard shortcuts

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