k8s

package
v2.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyUnstructured

func ApplyUnstructured(ctx context.Context, objects []*unstructured.Unstructured,
	dynamicClient dynamic.Interface, mapper *restmapper.DeferredDiscoveryRESTMapper) error

ApplyUnstructured applies a list of unstructured objects to the K8s cluster.

func CheckRollingRestartLogic

func CheckRollingRestartLogic(events []watch.Event) bool

CheckRollingRestartLogic checks if the rolling restart logic is correctly followed based on the provided list of Kubernetes watch events. The function first sort events by time, then checks for pod creation events and verifies the restart events to ensure that the rolling restart logic is adhered to. An example of a rolling restart event sequence is like:

  1. pod1 added
  2. pod2 added
  3. pod2 deleted
  4. pod2 added
  5. pod1 deleted
  6. pod1 added

func DecodeYAML

func DecodeYAML(r io.Reader) ([]*unstructured.Unstructured, error)

DecodeYAML decodes a YAML file into a list of unstructured objects.

func ForwardOnePort

func ForwardOnePort(fw PortForwarder, ns, resourceName string, port uint16) (
	fwdHost string, fwdPort uint16, cancel context.CancelFunc, err error)

ForwardOnePort is a helper utility to forward one port of Kubernetes resource.

func GetPodUIDMap

func GetPodUIDMap(ctx context.Context, clientSet kubernetes.Interface, namespace string, opts metav1.ListOptions) (map[string]string, error)

func GetPodUIDMapFromPodList

func GetPodUIDMapFromPodList(ctx context.Context, podList *corev1.PodList) map[string]string

func LoadConfig

func LoadConfig() (*rest.Config, error)

LoadConfig loads the k8s config from the default location.

Types

type PortForwarder

type PortForwarder interface {
	Forward(namespace, resourceName string, addresses []string, ports []string) ([]portforward.ForwardedPort, context.CancelFunc, error)
	ForwardPod(pod *corev1.Pod, addresses []string, ports []string) ([]portforward.ForwardedPort, context.CancelFunc, error)
}

PortForwarder represents an interface which can forward local ports to a pod.

func NewPortForwarder

func NewPortForwarder(ctx context.Context, restClientGetter genericclioptions.RESTClientGetter) (PortForwarder, error)

type YAMLApplier

type YAMLApplier struct {
	DynamicClient dynamic.Interface
	Mapper        *restmapper.DeferredDiscoveryRESTMapper
}

YAMLApplier applies a list of unstructured objects to the K8s cluster.

func NewYAMLApplier

func NewYAMLApplier(dynamicClient dynamic.Interface, mapper *restmapper.DeferredDiscoveryRESTMapper) *YAMLApplier

NewYAMLApplier creates a new YAMLApplier.

func (*YAMLApplier) Apply

func (a *YAMLApplier) Apply(ctx context.Context, r io.Reader) error

Apply applies a list of unstructured objects to the K8s cluster.

Jump to

Keyboard shortcuts

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