kubernetes

package
v0.0.2-0...-f1021f6 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUFFIX_SECRET                     = "secret"
	SUFFIX_CONFIG_MAP                 = "config-map"
	SECRET_LICENSE                    = "LICENSE"
	CONFIG_POD_REGEX                  = "POD_REGEX"
	CONFIG_NAMESPACES                 = "NAMESPACES"
	CONFIG_SCRIPTING_ENV              = "SCRIPTING_ENV"
	CONFIG_INGRESS_ENABLED            = "INGRESS_ENABLED"
	CONFIG_INGRESS_HOST               = "INGRESS_HOST"
	CONFIG_PROXY_FRONT_PORT           = "PROXY_FRONT_PORT"
	CONFIG_AUTH_ENABLED               = "AUTH_ENABLED"
	CONFIG_AUTH_TYPE                  = "AUTH_TYPE"
	CONFIG_AUTH_SAML_IDP_METADATA_URL = "AUTH_SAML_IDP_METADATA_URL"
)
View Source
const (
	SELF_RESOURCES_PREFIX      = "kubeshark-"
	FrontPodName               = SELF_RESOURCES_PREFIX + "front"
	FrontServiceName           = FrontPodName
	HubPodName                 = SELF_RESOURCES_PREFIX + "hub"
	HubServiceName             = HubPodName
	K8sAllNamespaces           = ""
	MinKubernetesServerVersion = "1.16.0"
)
View Source
const (
	EventAdded    = watch.Added
	EventModified = watch.Modified
	EventDeleted  = watch.Deleted
	EventBookmark = watch.Bookmark
	EventError    = watch.Error
)

Variables

This section is empty.

Functions

func CopyFromPod

func CopyFromPod(ctx context.Context, provider *Provider, pod v1.Pod, srcPath string, dstPath string) error

func FilteredWatch

func FilteredWatch(ctx context.Context, watcherCreator WatchCreator, targetNamespaces []string, filterer EventFilterer) (<-chan *WatchEvent, <-chan error)

func GetHubUrl

func GetHubUrl() string

func GetProxyOnPort

func GetProxyOnPort(port uint16) string

func IsPodRunning

func IsPodRunning(pod *core.Pod) bool

func NewPortForward

func NewPortForward(kubernetesProvider *Provider, namespace string, podRegex *regexp.Regexp, srcPort uint16, dstPort uint16, ctx context.Context) (*portforward.PortForwarder, error)

func SetConfig

func SetConfig(provider *Provider, key string, value string) (updated bool, err error)

func SetSecret

func SetSecret(provider *Provider, key string, value string) (updated bool, err error)

func StartProxy

func StartProxy(kubernetesProvider *Provider, proxyHost string, srcPort uint16, selfNamespace string, selfServiceName string) (*http.Server, error)

func ValidateKubernetesVersion

func ValidateKubernetesVersion(serverVersionSemVer *semver.SemVersion) error

Types

type ClusterBehindProxyError

type ClusterBehindProxyError struct{}

func (*ClusterBehindProxyError) Error

func (e *ClusterBehindProxyError) Error() string

ClusterBehindProxyError implements the Error interface.

type EventFilterer

type EventFilterer interface {
	Filter(*WatchEvent) (bool, error)
}

type EventWatchHelper

type EventWatchHelper struct {
	NameRegexFilter *regexp.Regexp
	Kind            string
	// contains filtered or unexported fields
}

func NewEventWatchHelper

func NewEventWatchHelper(kubernetesProvider *Provider, NameRegexFilter *regexp.Regexp, kind string) *EventWatchHelper

func (*EventWatchHelper) Filter

func (wh *EventWatchHelper) Filter(wEvent *WatchEvent) (bool, error)

Implements the EventFilterer Interface

func (*EventWatchHelper) NewWatcher

func (wh *EventWatchHelper) NewWatcher(ctx context.Context, namespace string) (watch.Interface, error)

Implements the WatchCreator Interface

type InvalidObjectType

type InvalidObjectType struct {
	RequestedType reflect.Type
}

func (*InvalidObjectType) Error

func (iot *InvalidObjectType) Error() string

Implements the error interface

type K8sTapManagerError

type K8sTapManagerError struct {
	OriginalError    error
	TapManagerReason K8sTapManagerErrorReason
}

func (*K8sTapManagerError) Error

func (e *K8sTapManagerError) Error() string

K8sTapManagerError implements the Error interface.

type K8sTapManagerErrorReason

type K8sTapManagerErrorReason string
const (
	TapManagerWorkerUpdateError K8sTapManagerErrorReason = "WORKER_UPDATE_ERROR"
	TapManagerPodWatchError     K8sTapManagerErrorReason = "POD_WATCH_ERROR"
	TapManagerPodListError      K8sTapManagerErrorReason = "POD_LIST_ERROR"
)

type PodWatchHelper

type PodWatchHelper struct {
	NameRegexFilter *regexp.Regexp
	// contains filtered or unexported fields
}

func NewPodWatchHelper

func NewPodWatchHelper(kubernetesProvider *Provider, NameRegexFilter *regexp.Regexp) *PodWatchHelper

func (*PodWatchHelper) Filter

func (wh *PodWatchHelper) Filter(wEvent *WatchEvent) (bool, error)

Implements the EventFilterer Interface

func (*PodWatchHelper) NewWatcher

func (wh *PodWatchHelper) NewWatcher(ctx context.Context, namespace string) (watch.Interface, error)

Implements the WatchCreator Interface

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(kubeConfigPath string, contextName string) (*Provider, error)

func (*Provider) DoesServiceExist

func (provider *Provider) DoesServiceExist(ctx context.Context, namespace string, name string) (bool, error)

func (*Provider) GetKubernetesVersion

func (provider *Provider) GetKubernetesVersion() (*semver.SemVersion, error)

func (*Provider) GetNamespaceEvents

func (provider *Provider) GetNamespaceEvents(ctx context.Context, namespace string) (string, error)

func (*Provider) GetNamespaces

func (provider *Provider) GetNamespaces() []string

func (*Provider) GetPodLogs

func (provider *Provider) GetPodLogs(ctx context.Context, namespace string, podName string, containerName string) (string, error)

func (*Provider) ListAllPodsMatchingRegex

func (provider *Provider) ListAllPodsMatchingRegex(ctx context.Context, regex *regexp.Regexp, namespaces []string) ([]core.Pod, error)

func (*Provider) ListAllRunningPodsMatchingRegex

func (provider *Provider) ListAllRunningPodsMatchingRegex(ctx context.Context, regex *regexp.Regexp, namespaces []string) ([]core.Pod, error)

func (*Provider) ListPodsByAppLabel

func (provider *Provider) ListPodsByAppLabel(ctx context.Context, namespaces string, labels map[string]string) ([]core.Pod, error)

func (*Provider) ValidateNotProxy

func (provider *Provider) ValidateNotProxy() error

ValidateNotProxy We added this after a customer tried to run kubeshark from lens, which used len's kube config, which have cluster server configuration, which points to len's local proxy. The workaround was to use the user's local default kube config. For now - we are blocking the option to run kubeshark through a proxy to k8s server

type WatchCreator

type WatchCreator interface {
	NewWatcher(ctx context.Context, namespace string) (watch.Interface, error)
}

type WatchEvent

type WatchEvent watch.Event

func (*WatchEvent) ToError

func (we *WatchEvent) ToError() error

func (*WatchEvent) ToEvent

func (we *WatchEvent) ToEvent() (*eventsv1.Event, error)

func (*WatchEvent) ToPod

func (we *WatchEvent) ToPod() (*corev1.Pod, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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