k8s

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckEphemeralContainerSupport added in v0.0.4

func CheckEphemeralContainerSupport(v VersionGetter) error

func CheckPodsContext added in v0.0.4

func CheckPodsContext(pods []v1.Pod) error

func GetKubeForwarder

func GetKubeForwarder(
	r *rest.Config,
	path string,
	rch, sch chan struct{},
	proxyport int32,
) (*portforward.PortForwarder, int, error)

func PortForward

func PortForward(forwarder Forwarder, readych chan struct{}, timeout time.Duration) error

func SelectPods

func SelectPods(pods []string, all bool, h PodLister) ([]v1.Pod, error)

func SetupEphemeralContainers

func SetupEphemeralContainers(pods []v1.Pod, h KubeEphemeralHandler, opts AgentOpts) error

func SetupProxy

func SetupProxy(h KubeProxyHandler, opts ProxyOpts) (string, error)

func TearDownProxy

func TearDownProxy(id string, h KubeProxyHandler) error

Types

type AgentOpt

type AgentOpt func(o AgentOpts) AgentOpts

func WithAgentCaptureTimeOut

func WithAgentCaptureTimeOut(n time.Duration) AgentOpt

func WithAgentDevice

func WithAgentDevice(n string) AgentOpt

func WithAgentPromiscuous

func WithAgentPromiscuous(n bool) AgentOpt

func WithAgentSetupTimeOut

func WithAgentSetupTimeOut(n time.Duration) AgentOpt

func WithAgentSnapLen

func WithAgentSnapLen(n int32) AgentOpt

func WithAgentUUID

func WithAgentUUID(u string) AgentOpt

type AgentOpts

type AgentOpts struct {
	SnapshotLen  int32         // https://www.tcpdump.org/manpages/pcap_set_snaplen.3pcap.html
	Promiscuous  bool          // https://www.tcpdump.org/manpages/pcap_set_promisc.3pcap.html
	Device       string        // https://www.tcpdump.org/manpages/pcap_create.3pcap.html
	Timeout      time.Duration // https://www.tcpdump.org/manpages/pcap_set_timeout.3pcap.html
	TargetIP     string        // proxy endpoint address to send packet via gRPC
	TargetPort   int           // proxy endpoint port to send packet via gRPC
	UUID         string        // kpture uuid used in  ephemeral container name
	SetupTimeout time.Duration // timeout for ephemeral container injection
}

func LoadAgentOpts

func LoadAgentOpts(os ...AgentOpt) AgentOpts

func (AgentOpts) WithTargetIP

func (a AgentOpts) WithTargetIP(s string) AgentOpts

func (AgentOpts) WithTargetPort

func (a AgentOpts) WithTargetPort(p int) AgentOpts

type Forwarder

type Forwarder interface {
	ForwardPorts() error
}

type KubeClient

type KubeClient struct {
	Clientset *kubernetes.Clientset
	RestConf  *rest.Config
	Namespace string
}

func GetClient

func GetClient(namespace string) (*KubeClient, error)

type KubeEphemeralHandler

type KubeEphemeralHandler interface {
	Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.Pod, error)
	UpdateEphemeralContainers(ctx context.Context, podName string, pod *v1.Pod, opts metav1.UpdateOptions) (*v1.Pod, error)
	List(ctx context.Context, opts metav1.ListOptions) (*v1.PodList, error)
}

type KubeProxyHandler

type KubeProxyHandler interface {
	Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.Pod, error)
	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
	Create(ctx context.Context, pod *v1.Pod, opts metav1.CreateOptions) (*v1.Pod, error)
}

type PodLister

type PodLister interface {
	List(ctx context.Context, opts metav1.ListOptions) (*v1.PodList, error)
}

type ProxyOpt

type ProxyOpt func(o ProxyOpts) ProxyOpts

func WithProxyServerPort

func WithProxyServerPort(u int32) ProxyOpt

func WithProxySetupTimeout

func WithProxySetupTimeout(u time.Duration) ProxyOpt

func WithProxyUUID

func WithProxyUUID(u string) ProxyOpt

type ProxyOpts

type ProxyOpts struct {
	ServerPort   int32
	UUID         string
	SetupTimeout time.Duration // timeout for pod creation
}

func LoadProxyOpts

func LoadProxyOpts(os ...ProxyOpt) ProxyOpts

type VersionGetter added in v0.0.4

type VersionGetter interface {
	ServerVersion() (*version.Info, error)
}

Jump to

Keyboard shortcuts

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