kubernetes

package
v0.0.0-...-9c03649 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultOverrideType = OverrideTypeMerge

Variables

This section is empty.

Functions

func GetRESTConfig

func GetRESTConfig(
	apiServer string,
	kubeconfig string,
	kubeconfigContext string,
) (*rest.Config, string, error)

func JSONPatch

func JSONPatch[D any](dest D, fragment string) (o D, err error)

func MergePatch

func MergePatch[D any](dest D, fragment string) (o D, err error)

func Override

func Override[D any](dest D, fragment string, overrideType OverrideType) (o D, err error)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a minimal Kubernetes REST client

func NewClient

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

NewClient creates a new Kubernetes REST client

func (*Client) CreatePod

func (c *Client) CreatePod(ctx context.Context, namespace string, pod *types.Pod) (*types.Pod, error)

CreatePod creates a new pod

func (*Client) GetPod

func (c *Client) GetPod(ctx context.Context, namespace, name string) (*types.Pod, error)

GetPod retrieves a pod by namespace and name

func (*Client) GetPodLogs

func (c *Client) GetPodLogs(ctx context.Context, namespace, name string, opts PodLogOptions) (io.ReadCloser, error)

GetPodLogs gets logs from a pod container

func (*Client) PatchPod

func (c *Client) PatchPod(ctx context.Context, namespace, name, subresource string, patchData []byte) (*types.Pod, error)

PatchPod patches a pod using JSON Merge Patch

func (*Client) RESTClient

func (c *Client) RESTClient() *rest.Config

RESTClient returns the underlying REST config (needed for remotecommand)

func (*Client) WatchPods

func (c *Client) WatchPods(ctx context.Context, namespace string, opts WatchOptions) (*PodWatcher, error)

WatchPods watches pods in a namespace

type OverrideType

type OverrideType string
const (
	// OverrideTypeJSON will use an RFC6902 JSON Patch to alter the generated output
	OverrideTypeJSON OverrideType = "json"

	// OverrideTypeMerge will use an RFC7396 JSON Merge Patch to alter the generated output
	OverrideTypeMerge OverrideType = "merge"
)

type PodLogOptions

type PodLogOptions struct {
	Container string
	Follow    bool
}

PodLogOptions contains options for getting pod logs

type PodWatcher

type PodWatcher struct {
	// contains filtered or unexported fields
}

PodWatcher watches changes for pod

func (*PodWatcher) ResultChan

func (w *PodWatcher) ResultChan() <-chan types.PodEvent

ResultChan returns the event channel

func (*PodWatcher) Stop

func (w *PodWatcher) Stop()

Stop stops the watcher

type WatchOptions

type WatchOptions struct {
	FieldSelector string
	Timeout       int64
}

WatchOptions contains options for watching resources

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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