util

package
v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 60 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFirewallRule

func AddFirewallRule()

func BytesToInt

func BytesToInt(b []byte) uint32

func DeleteWindowsFirewallRule

func DeleteWindowsFirewallRule(ctx context.Context)

DeleteWindowsFirewallRule Delete all action block firewall rule

func FindRule

func FindRule() bool

func GetAvailableTCPPortOrDie

func GetAvailableTCPPortOrDie() int

func GetAvailableUDPPortOrDie

func GetAvailableUDPPortOrDie() int

func GetCIDRElegant added in v1.1.9

func GetCIDRElegant(clientset *kubernetes.Clientset, restclient *rest.RESTClient, restconfig *rest.Config, namespace string) (result []*net.IPNet, err1 error)

GetCIDRElegant 1) dump cluster info 2) grep cmdline 3) create svc + cat *.conflist 4) create svc + get pod ip with svc mask

func GetCIDRFromResourceUgly added in v1.1.9

func GetCIDRFromResourceUgly(clientset *kubernetes.Clientset, namespace string) ([]*net.IPNet, error)

GetCIDRFromResourceUgly use podIP/16 and serviceIP/16 as cidr

func GetPodTemplateSpecPath

func GetPodTemplateSpecPath(u *unstructured.Unstructured) (*v1.PodTemplateSpec, []string, error)

func GetTopOwnerReference

func GetTopOwnerReference(factory cmdutil.Factory, namespace, workload string) (*runtimeresource.Info, error)

func GetTopOwnerReferenceBySelector

func GetTopOwnerReferenceBySelector(factory cmdutil.Factory, namespace, selector string) (sets.String, error)

GetTopOwnerReferenceBySelector assume pods, controller has same labels

func GetUnstructuredObject

func GetUnstructuredObject(f cmdutil.Factory, namespace string, workloads string) (*runtimeresource.Info, error)

func GetUnstructuredObjectBySelector

func GetUnstructuredObjectBySelector(f cmdutil.Factory, namespace string, selector string) ([]*runtimeresource.Info, error)

func Heartbeats

func Heartbeats(ctx context.Context)

func InitLogger

func InitLogger(debug bool)

func IsAdmin

func IsAdmin() bool

func IsPortListening

func IsPortListening(port int) bool

func IsWindows

func IsWindows() bool

func Ping

func Ping(targetIP string) (bool, error)

func PortForwardPod

func PortForwardPod(config *rest.Config, clientset *rest.RESTClient, podName, namespace, port string, readyChan chan struct{}, stopChan <-chan struct{}) error

func RolloutStatus

func RolloutStatus(factory cmdutil.Factory, namespace, workloads string, timeout time.Duration) error

func RunWithElevated

func RunWithElevated()

func RunWithRollingOutWithChecker

func RunWithRollingOutWithChecker(cmd *osexec.Cmd, checker func(log string)) (string, string, error)

func Shell

func Shell(clientset *kubernetes.Clientset, restclient *rest.RESTClient, config *rest.Config, podName, namespace, cmd string) (string, error)

func WaitPod

func WaitPod(podInterface v12.PodInterface, list metav1.ListOptions, checker func(*v1.Pod) bool) error

func WaitPortToBeFree

func WaitPortToBeFree(ctx context.Context, port int) error

Types

type Format

type Format struct {
	log.Formatter
}

func (*Format) Format

func (*Format) Format(e *log.Entry) ([]byte, error)
2009/01/23 01:23:23 d.go:23: message

same like log.SetFlags(log.LstdFlags | log.Lshortfile)

type ForwardedPort

type ForwardedPort struct {
	Local  uint16
	Remote uint16
}

ForwardedPort contains a Local:Remote port pairing.

type PodRouteConfig

type PodRouteConfig struct {
	LocalTunIP           string
	InboundPodTunIP      string
	TrafficManagerRealIP string
	Route                string
}

type PortForwarder

type PortForwarder struct {
	Ready chan struct{}
	// contains filtered or unexported fields
}

PortForwarder knows how to listen for local connections and forward them to a remote pod via an upgraded HTTP request.

func NewOnAddresses

func NewOnAddresses(dialer httpstream.Dialer, addresses []string, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error)

NewOnAddresses creates a new PortForwarder with custom listen addresses.

func (*PortForwarder) Close

func (pf *PortForwarder) Close()

Close stops all listeners of PortForwarder.

func (*PortForwarder) ForwardPorts

func (pf *PortForwarder) ForwardPorts() error

ForwardPorts formats and executes a port forwarding request. The connection will remain open until stopChan is closed.

func (*PortForwarder) GetPorts

func (pf *PortForwarder) GetPorts() ([]ForwardedPort, error)

GetPorts will return the ports that were forwarded; this can be used to retrieve the locally-bound port in cases where the input was port 0. This function will signal an error if the Ready channel is nil or if the listeners are not ready yet; this function will succeed after the Ready channel has been closed.

Jump to

Keyboard shortcuts

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