k8sclient

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRunningInCluster

func IsRunningInCluster() bool

IsRunningInCluster returns true if the application is running inside a Kubernetes cluster.

Types

type Client

type Client interface {
	// GetClientset returns the underlying kubernetes.Interface.
	GetClientset() kubernetes.Interface

	// GetDynamicClient returns the dynamic client for unstructured resources.
	GetDynamicClient() dynamic.Interface

	// GetDiscoveryClient returns the discovery client for API discovery.
	GetDiscoveryClient() discovery.DiscoveryInterface

	// GetSecret retrieves a secret by name from the specified namespace.
	GetSecret(ctx context.Context, namespace, name string) (*corev1.Secret, error)

	// CreateSecret creates a new secret in the specified namespace.
	CreateSecret(ctx context.Context, namespace string, secret *corev1.Secret) (*corev1.Secret, error)

	// UpdateSecret updates an existing secret.
	UpdateSecret(ctx context.Context, namespace string, secret *corev1.Secret) (*corev1.Secret, error)

	// ListResources lists resources of a given type.
	ListResources(ctx context.Context, gvr schema.GroupVersionResource, namespace string) (*unstructured.UnstructuredList, error)

	// WatchResources watches for changes to resources of a given type.
	WatchResources(ctx context.Context, gvr schema.GroupVersionResource, namespace string, resourceVersion string) (watch.Interface, error)
}

Client abstracts Kubernetes API operations.

func NewClient

func NewClient() (Client, error)

NewClient creates a new Client that uses real K8s APIs. It supports both in-cluster and out-of-cluster (kubeconfig) execution.

func NewClientFromClients

func NewClientFromClients(clientset kubernetes.Interface, dynamicClient dynamic.Interface) Client

NewClientFromClients creates a Client from existing clients.

func NewClientFromConfig

func NewClientFromConfig(config *rest.Config) (Client, error)

NewClientFromConfig creates a Client from an existing config.

Jump to

Keyboard shortcuts

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