kubernetes

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func BytesToUtf8Lf

func BytesToUtf8Lf(file []byte) (string, error)

func GetAPIServer

func GetAPIServer(kubeconfigRaw []byte) (string, error)

func GetClusterName

func GetClusterName(config *rest.Config) string

GetClusterName returns the name of the cluster

func GetClusterNameFromKubeconfig

func GetClusterNameFromKubeconfig(config *clientcmdapi.Config) (clusterName string, server string)

func GetUnstructuredObjects

func GetUnstructuredObjects(data []byte) ([]unstructured.Unstructured, error)

func NewClient

func NewClient(log logger.Logger, kubeconfigPaths ...string) (kubernetes.Interface, *rest.Config, error)

func NewClientFromPathOrConfig

func NewClientFromPathOrConfig(
	logger logger.Logger,
	kubeconfigOrPath string,
) (kubernetes.Interface, *rest.Config, error)

func NewClientWithConfig

func NewClientWithConfig(log logger.Logger, kubeConfig []byte) (kubernetes.Interface, *rest.Config, error)

func RestConfigFingerprint

func RestConfigFingerprint(rc *rest.Config) string

RestConfigFingerprint generates a unique SHA-256 hash to identify the Kubernetes API server and client authentication details from the REST configuration.

Types

type Client

type Client struct {
	kubernetes.Interface

	Config *rest.Config // Prefer updaating token in place
	// contains filtered or unexported fields
}

func NewKubeClient

func NewKubeClient(logger logger.Logger, client kubernetes.Interface, config *rest.Config) *Client

func (*Client) Apply added in v0.1.1

func (c *Client) Apply(ctx context.Context, manifest string) (Resources, error)

func (*Client) ApplyFile added in v0.1.1

func (c *Client) ApplyFile(ctx context.Context, files ...string) (Resources, error)

func (*Client) DeleteByGVK

func (c *Client) DeleteByGVK(ctx context.Context, namespace, name string, gvk schema.GroupVersionKind) (bool, error)

func (*Client) ExecutePodf

func (c *Client) ExecutePodf(
	ctx context.Context,
	namespace, pod, container string,
	command ...string,
) (string, string, error)

func (*Client) ExpandNamespaces

func (c *Client) ExpandNamespaces(ctx context.Context, namespace string) ([]string, error)

func (*Client) FetchResources

func (c *Client) FetchResources(
	ctx context.Context,
	resources ...unstructured.Unstructured,
) ([]unstructured.Unstructured, error)

func (*Client) Get added in v0.1.1

func (c *Client) Get(ctx context.Context, kind, namespace, name string) (*unstructured.Unstructured, error)

func (*Client) GetClientByGroupVersionKind

func (c *Client) GetClientByGroupVersionKind(
	ctx context.Context, group, version, kind string,
) (dynamic.NamespaceableResourceInterface, error)

func (*Client) GetClientByKind

WARN: "Kind" is not specific enough. A cluster can have various resources with the same Kind. example: helmchrats.helm.cattle.io & helmcharts.source.toolkit.fluxcd.io both have HelmChart as the kind.

Use GetClientByGroupVersionKind instead.

func (*Client) GetDynamicClient

func (c *Client) GetDynamicClient() (dynamic.Interface, error)

GetDynamicClient creates a new k8s client

func (*Client) GetPodIP added in v0.1.1

func (c *Client) GetPodIP(ctx context.Context, namespace, selector string) (string, error)

func (*Client) GetPodLogs

func (c *Client) GetPodLogs(ctx context.Context, namespace, podName, container string) (io.ReadCloser, error)

func (*Client) GetResource added in v0.1.1

func (c *Client) GetResource(ctx context.Context, kind, namespace, name string) (*Resource, error)

func (*Client) GetRestMapper

func (c *Client) GetRestMapper() (meta.RESTMapper, error)

func (*Client) List added in v0.1.1

func (c *Client) List(ctx context.Context, kind, namespace, selector string) ([]unstructured.Unstructured, error)

func (*Client) QueryResources

func (c *Client) QueryResources(ctx context.Context, selector types.ResourceSelector) ([]unstructured.Unstructured, error)

func (*Client) Reset

func (c *Client) Reset()

func (*Client) ResetRestMapper

func (c *Client) ResetRestMapper()

func (*Client) RestConfig

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

func (*Client) SetLogger

func (c *Client) SetLogger(logger logger.Logger)

func (*Client) StreamLogsV2

func (c *Client) StreamLogsV2(
	ctx context.Context,
	namespace, name string,
	timeout time.Duration,
	containerNames ...string,
) error

func (*Client) WaitFor added in v0.1.1

func (c *Client) WaitFor(ctx context.Context, kind, namespace, name string, condition func(*unstructured.Unstructured) bool, timeout time.Duration) (*unstructured.Unstructured, error)

func (*Client) WaitForContainerStart

func (c *Client) WaitForContainerStart(
	ctx context.Context,
	namespace, name string,
	timeout time.Duration,
	containerNames ...string,
) error

WaitForContainerStart waits for the specified containers to be started (or any container if no names are specified) - returns an error if the timeout is exceeded

func (*Client) WaitForJob added in v0.1.4

func (c *Client) WaitForJob(
	ctx context.Context,
	namespace, name string,
	timeout time.Duration,
) error

WaitForJob waits for a job to complete or fail within the specified timeout. Returns nil if the job completes successfully, or an error if the job fails or times out.

func (*Client) WaitForPod

func (c *Client) WaitForPod(
	ctx context.Context,
	namespace, name string,
	timeout time.Duration,
	phases ...v1.PodPhase,
) error

WaitForPod waits for a pod to be in the specified phase, or returns an error if the timeout is exceeded

func (*Client) WaitForReady added in v0.1.1

func (c *Client) WaitForReady(ctx context.Context, kind, namespace, name string, timeout ...time.Duration) (*Resource, error)

func (*Client) WithNamespace added in v0.1.1

func (c *Client) WithNamespace(namespace string) *Client

type Resource added in v0.1.1

type Resource struct {
	unstructured.Unstructured
	health.HealthStatus
}

func (*Resource) IsHealthy added in v0.1.1

func (r *Resource) IsHealthy() bool

func (Resource) Pretty added in v0.1.1

func (r Resource) Pretty() api.Text

type Resources added in v0.1.1

type Resources []Resource

func NewResources added in v0.1.1

func NewResources(objs ...unstructured.Unstructured) Resources

func (Resources) AsUnstructured added in v0.1.1

func (r Resources) AsUnstructured() []unstructured.Unstructured

func (Resources) Pretty added in v0.1.1

func (r Resources) Pretty() api.Text

Jump to

Keyboard shortcuts

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