util

package
v0.0.0-...-7120287 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotateEnrolledPod

func AnnotateEnrolledPod(client kubernetes.Interface, pod *metav1.ObjectMeta) error

func AnnotateUnenrollPod

func AnnotateUnenrollPod(client kubernetes.Interface, pod *metav1.ObjectMeta) error

func Execute

func Execute(cmd string, args ...string) error

func ExecuteOutput

func ExecuteOutput(cmd string, args ...string) (string, error)

func GetPlugin

func GetPlugin(rawPlugin any) (plugin map[string]any, err error)

Given the raw plugin interface, return the plugin asserted as a map[string]interface{}

func GetPlugins

func GetPlugins(cniConfigMap map[string]any) (plugins []any, err error)

Given an unmarshalled CNI config JSON map, return the plugin list asserted as a []interface{}

func GetPodIPsIfPresent

func GetPodIPsIfPresent(pod *corev1.Pod) []netip.Addr

Get any IPs currently assigned to the Pod.

If 'PodIPs' exists, it is preferred (and should be guaranteed to contain the address in 'PodIP'), otherwise fallback to 'PodIP'.

Note that very early in the pod's lifecycle (before all the node CNI plugin invocations finish) K8S may not have received the pod IPs yet, and may not report the pod as having any.

func IsZtunnelPod

func IsZtunnelPod(systemNs string, pod *corev1.Pod) bool

func MarshalCNIConfig

func MarshalCNIConfig(cniConfigMap map[string]any) ([]byte, error)

Marshal the CNI config map and append a new line

func PodRedirectionEnabled

func PodRedirectionEnabled(namespace *corev1.Namespace, pod *corev1.Pod) bool

PodRedirectionEnabled determines if a pod should or should not be configured to have traffic redirected thru the node proxy.

func ReadCNIConfigMap

func ReadCNIConfigMap(path string) (map[string]any, error)

Read CNI config from file and return the unmarshalled JSON as a map

Types

type ExecList

type ExecList struct {
	Cmd  string
	Args []string
}

func NewExec

func NewExec(cmd string, args []string) *ExecList

type Watcher

type Watcher struct {
	Events chan struct{}
	Errors chan error
	// contains filtered or unexported fields
}

func CreateFileWatcher

func CreateFileWatcher(paths ...string) (*Watcher, error)

Creates a file watcher that watches for any changes to the directory

func (*Watcher) Close

func (w *Watcher) Close()

func (*Watcher) Wait

func (w *Watcher) Wait(ctx context.Context) error

Waits until a file is modified (returns nil), the context is cancelled (returns context error), or returns error

Jump to

Keyboard shortcuts

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