kubernetes

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DynamicClient *dynamic.DynamicClient
View Source
var KubernetesClient *clientkube.Clientset
View Source
var NumaplaneClient *versioned.Clientset

Functions

func ApplyOwnerReference added in v0.22.0

func ApplyOwnerReference(child *unstructured.Unstructured, owner *unstructured.Unstructured) error

func CalculateHash added in v0.22.0

func CalculateHash(ctx context.Context, resource unstructured.Unstructured) (string, error)

Calculate the sha256 hash of a Resource's definition

func CreateResource added in v0.8.0

func CreateResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error

CreateResource creates the resource in the kubernetes cluster

func DeleteResource added in v0.8.0

func DeleteResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error

DeleteResource deletes the resource from the kubernetes cluster

func ExtractResourceNames added in v0.10.0

func ExtractResourceNames(unstrucList *unstructured.UnstructuredList) []string

ExtractResourceNames extracts the names of the resources from an UnstructuredList

func GetLabel added in v0.2.0

func GetLabel(un *unstructured.Unstructured, key string) (string, error)

GetLabel returns the label identified by "key"

func GetLiveResource added in v0.8.0

func GetLiveResource(
	ctx context.Context,
	object *unstructured.Unstructured,
	pluralName string,
) (*unstructured.Unstructured, error)

GetLiveResource converts the generic object to unstructured object and fetches the resource from the API server

func GetResource

GetResource retrieves the resource from the informer cache, if it's not found then it fetches from the API server.

func GetSecret

func GetSecret(ctx context.Context, client k8sClient.Client, namespace, secretName string) (*corev1.Secret, error)

GetSecret gets secret using the kubernetes client

func IsValidKubernetesManifestFile

func IsValidKubernetesManifestFile(fileName string) bool

func IsValidKubernetesNamespace

func IsValidKubernetesNamespace(name string) bool

func ListLiveResource added in v0.8.0

func ListLiveResource(
	ctx context.Context,
	apiGroup string,
	version string,
	pluralName string,
	namespace string,
	labelSelector string,
	fieldSelector string,
) (unstructured.UnstructuredList, error)

func ListPodsMetadataOnly added in v0.14.0

func ListPodsMetadataOnly(ctx context.Context, c k8sClient.Client, namespace, labels string) (*metav1.PartialObjectMetadataList, error)

func ListResources added in v0.8.0

ListResources retrieves the list of resources from the informer cache, if it's not found then it fetches from the API server.

func MetaGVKToSchemaGVK added in v0.22.0

func MetaGVKToSchemaGVK(metaGVK metav1.GroupVersionKind) schema.GroupVersionKind

func NewKubectl

func NewKubectl() kube.Kubectl

func NewPodDisruptionBudget added in v0.2.0

func NewPodDisruptionBudget(name, namespace string, maxUnavailable int32, ownerReference []metav1.OwnerReference) *policyv1.PodDisruptionBudget

func PatchResource added in v0.8.0

func PatchResource(
	ctx context.Context,
	c client.Client,
	obj *unstructured.Unstructured,
	patch string,
	patchType k8stypes.PatchType,
) error

func RawExtensionToUnstructured added in v0.26.1

func RawExtensionToUnstructured(rawExtension runtime.RawExtension) (*unstructured.Unstructured, error)

func SchemaGVKToMetaGVK added in v0.22.0

func SchemaGVKToMetaGVK(schemaGVK schema.GroupVersionKind) metav1.GroupVersionKind

func SetClientSets added in v0.10.0

func SetClientSets(restConfig *rest.Config) error

func SetLabel added in v0.2.0

func SetLabel(target *unstructured.Unstructured, key, val string) error

SetLabel sets the label identified by "key" on an unstructured object

func StartConfigMapWatcher

func StartConfigMapWatcher(ctx context.Context, config *rest.Config) error

StartConfigMapWatcher will start a watcher for ConfigMaps with the given label key and value

func UpdateResource added in v0.8.0

func UpdateResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error

UpdateResource updates the resource in the kubernetes cluster

Types

type GenericStatus

type GenericStatus struct {
	Phase              string             `json:"phase,omitempty"`
	Conditions         []metav1.Condition `json:"conditions,omitempty"`
	ObservedGeneration int64              `json:"observedGeneration,omitempty"`
}

func ParseStatus

func ParseStatus(obj *unstructured.Unstructured) (GenericStatus, error)

type ResourceFilter added in v0.22.0

type ResourceFilter struct {
	IncludedResources []ResourceType
}

ResourceFilter filter resources based on allowed Resource Types

func (*ResourceFilter) IsExcludedResource added in v0.22.0

func (n *ResourceFilter) IsExcludedResource(group, kind, _ string) bool

type ResourceType added in v0.22.0

type ResourceType struct {
	Group string
	Kind  string
}

func ParseResourceFilter added in v0.22.0

func ParseResourceFilter(rules string) ([]ResourceType, error)

ParseResourceFilter parse the given rules to generate the list of resources we allow or watch. The rules are delimited by ';', and each rule is composed by both 'group' and 'kind' which can be empty. For example, 'group=apps,kind=Deployment;group=,kind=ConfigMap'. Note that empty rule is valid.

Jump to

Keyboard shortcuts

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