k8s_utils

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 20 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOwnerReference

func AddOwnerReference(object, owner client.Object)

AddOwnerReference adds Sveltos resource owning a resource as an object's OwnerReference. OwnerReferences are used as ref count. Different Sveltos resources might match same cluster and reference same ConfigMap. This means a policy contained in a ConfigMap is deployed in a Cluster because of different Sveltos resources. When cleaning up, a policy can be removed only if no more Sveltos resources are listed as OwnerReferences.

func GetDynamicResourceInterface

func GetDynamicResourceInterface(config *rest.Config, gvk schema.GroupVersionKind,
	namespace string) (dynamic.ResourceInterface, error)

GetDynamicResourceInterface returns a dynamic ResourceInterface for the policy's GroupVersionKind

func GetKubeconfigWithUserToken

func GetKubeconfigWithUserToken(ctx context.Context, idToken, caData []byte,
	userID, server string) ([]byte, error)

GetKubeconfigWithUserToken() accepts a k8s client interface, OIDC IDToken, username (e.g. user@example.org) and server with scheme, host, and port (e.g. https://127.0.0.1:1234) to return a kube-config with credentials set for the user.

func GetKubernetesVersion

func GetKubernetesVersion(ctx context.Context, cfg *rest.Config, logger logr.Logger) (string, error)

func GetUnstructured

func GetUnstructured(object []byte) (*unstructured.Unstructured, error)

GetUnstructured returns an unstructured given a []bytes containing it

func HasSveltosResourcesAsOwnerReference

func HasSveltosResourcesAsOwnerReference(object client.Object) bool

HasSveltosResourcesAsOwnerReference returns true if at least one of current OwnerReferences is a Sveltos resource

func IsOnlyOwnerReference

func IsOnlyOwnerReference(object, owner client.Object) bool

IsOnlyOwnerReference returns true if clusterprofile is the only ownerreference for object

func IsOwnerReference

func IsOwnerReference(object, owner client.Object) bool

IsOwnerReference returns true is owner is one of the OwnerReferences for object

func RemoveOwnerReference

func RemoveOwnerReference(object, owner client.Object)

RemoveOwnerReference removes Sveltos resource as an OwnerReference from object. OwnerReferences are used as ref count. Different Sveltos resources might match same cluster and reference same ConfigMap. This means a policy contained in a ConfigMap is deployed in a Cluster because of different SveltosResources. When cleaning up, a policy can be removed only if no more SveltosResources are listed as OwnerReferences.

Types

This section is empty.

Jump to

Keyboard shortcuts

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