probe

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func KubeNamespace added in v0.2.4

func KubeNamespace(ns string, labels map[string]string) *v1.Namespace

Types

type Connectivity

type Connectivity string
const (
	ConnectivityUnknown             Connectivity = "unknown"
	ConnectivityCheckFailed         Connectivity = "checkfailed"
	ConnectivityInvalidNamedPort    Connectivity = "invalidnamedport"
	ConnectivityInvalidPortProtocol Connectivity = "invalidportprotocol"
	ConnectivityBlocked             Connectivity = "blocked"
	ConnectivityAllowed             Connectivity = "allowed"
)

func (Connectivity) ShortString

func (p Connectivity) ShortString() string

type Container

type Container struct {
	Name          string
	Port          int
	Protocol      v1.Protocol
	PortName      string
	BatchJobs     bool
	ImageRegistry string
}

func NewDefaultContainer

func NewDefaultContainer(port int, protocol v1.Protocol, batchJobs bool, imageRegistry string) *Container

func (*Container) Image added in v0.2.4

func (c *Container) Image() string

func (*Container) KubeContainer

func (c *Container) KubeContainer() v1.Container

func (*Container) KubeServicePort

func (c *Container) KubeServicePort() v1.ServicePort

type Item added in v0.2.4

type Item struct {
	From       string
	To         string
	JobResults map[string]*JobResult
}

func (*Item) AddJobResult added in v0.2.4

func (p *Item) AddJobResult(jr *JobResult) error

type Job

type Job struct {
	FromKey             string
	FromNamespace       string
	FromNamespaceLabels map[string]string
	FromPod             string
	FromPodLabels       map[string]string
	FromContainer       string
	FromIP              string

	ToKey             string
	ToHost            string
	ToNamespace       string
	ToNamespaceLabels map[string]string
	ToPodLabels       map[string]string
	ToContainer       string
	ToIP              string

	ResolvedPort     int
	ResolvedPortName string
	Protocol         v1.Protocol

	TimeoutSeconds int
}

func (*Job) ClientCommand

func (j *Job) ClientCommand() []string

func (*Job) Key added in v0.2.4

func (j *Job) Key() string

func (*Job) KubeExecCommand

func (j *Job) KubeExecCommand() []string

func (*Job) ToAddress

func (j *Job) ToAddress() string

func (*Job) Traffic

func (j *Job) Traffic() *matcher.Traffic

type JobBuilder added in v0.4.4

type JobBuilder struct {
	TimeoutSeconds int
}

func (*JobBuilder) GetJobsAllAvailableServers added in v0.4.4

func (j *JobBuilder) GetJobsAllAvailableServers(resources *Resources, mode generator.ProbeMode) *Jobs

func (*JobBuilder) GetJobsForNamedPortProtocol added in v0.4.4

func (j *JobBuilder) GetJobsForNamedPortProtocol(resources *Resources, port intstr.IntOrString, protocol v1.Protocol, mode generator.ProbeMode) *Jobs

func (*JobBuilder) GetJobsForProbeConfig added in v0.4.4

func (j *JobBuilder) GetJobsForProbeConfig(resources *Resources, config *generator.ProbeConfig) *Jobs

type JobResult

type JobResult struct {
	Job      *Job
	Ingress  *Connectivity
	Egress   *Connectivity
	Combined Connectivity
}

func (*JobResult) Key added in v0.2.4

func (jr *JobResult) Key() string

type JobRunner added in v0.2.4

type JobRunner interface {
	RunJobs(job []*Job) []*JobResult
}

type Jobs

type Jobs struct {
	Valid           []*Job
	BadNamedPort    []*Job
	BadPortProtocol []*Job
}

type KubeBatchJobRunner added in v0.2.4

type KubeBatchJobRunner struct {
	Client  *worker.Client
	Workers int
}

func NewKubeBatchJobRunner added in v0.2.4

func NewKubeBatchJobRunner(k8s kube.IKubernetes, workers int) *KubeBatchJobRunner

func (*KubeBatchJobRunner) RunJobs added in v0.2.4

func (k *KubeBatchJobRunner) RunJobs(jobs []*Job) []*JobResult

type KubeJobRunner added in v0.2.4

type KubeJobRunner struct {
	Kubernetes kube.IKubernetes
	Workers    int
}

func (*KubeJobRunner) RunJobs added in v0.2.4

func (k *KubeJobRunner) RunJobs(jobs []*Job) []*JobResult

type Peer

type Peer struct {
	Namespace string
	Pod       string
}

Peer is used for matching pods by either or both of the pod's namespace and name.

func (*Peer) Matches

func (p *Peer) Matches(pod PodString) bool

Matches checks whether the Peer matches the PodString: - an empty namespace means the namespace will always match - otherwise, the namespace must match the PodString's namespace - same goes for Pod: empty matches everything, otherwise must match exactly

type Pod

type Pod struct {
	Namespace  string
	Name       string
	Labels     map[string]string
	ServiceIP  string
	IP         string
	Containers []*Container
}

func NewDefaultPod

func NewDefaultPod(ns string, name string, ports []int, protocols []v1.Protocol, batchJobs bool, imageRegistry string) *Pod

func NewPod

func NewPod(ns string, name string, labels map[string]string, ip string, containers []*Container) *Pod

func (*Pod) Host added in v0.4.0

func (p *Pod) Host(probeMode generator.ProbeMode) string

func (*Pod) IsEqualToKubePod added in v0.3.0

func (p *Pod) IsEqualToKubePod(kubePod v1.Pod) (string, bool)

func (*Pod) IsServingPortProtocol

func (p *Pod) IsServingPortProtocol(port int, protocol v1.Protocol) bool

func (*Pod) KubeContainers

func (p *Pod) KubeContainers() []v1.Container

func (*Pod) KubePod

func (p *Pod) KubePod() *v1.Pod

func (*Pod) KubeService

func (p *Pod) KubeService() *v1.Service

func (*Pod) PodString

func (p *Pod) PodString() PodString

func (*Pod) ResolveNamedPort

func (p *Pod) ResolveNamedPort(port string) (int, error)

func (*Pod) ResolveNumberedPort

func (p *Pod) ResolveNumberedPort(port int) (string, error)

func (*Pod) ServiceName

func (p *Pod) ServiceName() string

func (*Pod) SetLabels

func (p *Pod) SetLabels(labels map[string]string) *Pod

type PodString

type PodString string

PodString represents a namespace 'x' + pod 'a' as "x/a".

func NewPodString

func NewPodString(namespace string, podName string) PodString

NewPodString instantiates a PodString from the given namespace and name.

func (PodString) Namespace

func (pod PodString) Namespace() string

Namespace extracts the namespace

func (PodString) PodName

func (pod PodString) PodName() string

PodName extracts the pod name

func (PodString) String

func (pod PodString) String() string

String converts back to a string

type Resources

type Resources struct {
	Namespaces map[string]map[string]string
	Pods       []*Pod
}

func NewDefaultResources

func NewDefaultResources(kubernetes kube.IKubernetes, namespaces []string, podNames []string, ports []int, protocols []v1.Protocol, externalIPs []string, podCreationTimeoutSeconds int, batchJobs bool, imageRegistry string) (*Resources, error)

func (*Resources) CreateNamespace added in v0.2.4

func (r *Resources) CreateNamespace(ns string, labels map[string]string) (*Resources, error)

CreateNamespace returns a new object with a new namespace. It should not affect the original Resources object.

func (*Resources) CreatePod added in v0.2.4

func (r *Resources) CreatePod(ns string, podName string, labels map[string]string) (*Resources, error)

CreatePod returns a new object with a new pod. It should not affect the original Resources object.

func (*Resources) CreateResourcesInKube

func (r *Resources) CreateResourcesInKube(kubernetes kube.IKubernetes) error

func (*Resources) DeleteNamespace added in v0.2.4

func (r *Resources) DeleteNamespace(ns string) (*Resources, error)

DeleteNamespace returns a new object without the namespace. It should not affect the original Resources object.

func (*Resources) DeletePod added in v0.2.4

func (r *Resources) DeletePod(ns string, podName string) (*Resources, error)

DeletePod returns a new object without the deleted pod. It should not affect the original Resources object.

func (*Resources) GetPod

func (r *Resources) GetPod(ns string, name string) (*Pod, error)

func (*Resources) NamespacesSlice

func (r *Resources) NamespacesSlice() []string

func (*Resources) RenderTable

func (r *Resources) RenderTable() string

func (*Resources) SetPodLabels

func (r *Resources) SetPodLabels(ns string, podName string, labels map[string]string) (*Resources, error)

SetPodLabels returns a new object with an updated pod. It should not affect the original Resources object.

func (*Resources) SortedPodNames added in v0.2.4

func (r *Resources) SortedPodNames() []string

func (*Resources) UpdateNamespaceLabels

func (r *Resources) UpdateNamespaceLabels(ns string, labels map[string]string) (*Resources, error)

UpdateNamespaceLabels returns a new object with an updated namespace. It should not affect the original Resources object.

type Runner added in v0.2.4

type Runner struct {
	JobRunner  JobRunner
	JobBuilder *JobBuilder
}

func NewKubeBatchRunner added in v0.2.4

func NewKubeBatchRunner(kubernetes kube.IKubernetes, workers int, jobBuilder *JobBuilder) *Runner

func NewKubeRunner added in v0.2.4

func NewKubeRunner(kubernetes kube.IKubernetes, workers int, jobBuilder *JobBuilder) *Runner

func NewSimulatedRunner added in v0.2.4

func NewSimulatedRunner(policies *matcher.Policy, jobBuilder *JobBuilder) *Runner

func (*Runner) RunProbeForConfig added in v0.2.4

func (p *Runner) RunProbeForConfig(probeConfig *generator.ProbeConfig, resources *Resources) *Table

type SimulatedJobRunner added in v0.2.4

type SimulatedJobRunner struct {
	Policies *matcher.Policy
}

func (*SimulatedJobRunner) RunJob added in v0.2.4

func (s *SimulatedJobRunner) RunJob(job *Job) *JobResult

func (*SimulatedJobRunner) RunJobs added in v0.2.4

func (s *SimulatedJobRunner) RunJobs(jobs []*Job) []*JobResult

type Table

type Table struct {
	Wrapped *TruthTable
}

func NewTable

func NewTable(items []string) *Table

func NewTableFromJobResults added in v0.2.4

func NewTableFromJobResults(resources *Resources, jobResults []*JobResult) *Table

func (*Table) Get

func (t *Table) Get(from string, to string) *Item

func (*Table) RenderEgress added in v0.2.4

func (t *Table) RenderEgress() string

func (*Table) RenderIngress added in v0.2.4

func (t *Table) RenderIngress() string

func (*Table) RenderTable

func (t *Table) RenderTable() string

type TableKey

type TableKey struct {
	From string
	To   string
}

type TruthTable

type TruthTable struct {
	Froms []string
	Tos   []string

	Values map[string]map[string]interface{}
	// contains filtered or unexported fields
}

TruthTable takes in n items and maintains an n x n table of booleans for each ordered pair

func NewTruthTable

func NewTruthTable(froms []string, tos []string, defaultValue func(fr, to string) interface{}) *TruthTable

NewTruthTable creates a new truth table with froms and tos

func NewTruthTableFromItems

func NewTruthTableFromItems(items []string, defaultValue func(fr, to string) interface{}) *TruthTable

NewTruthTableFromItems creates a new truth table with items

func (*TruthTable) Get

func (tt *TruthTable) Get(from string, to string) interface{}

Get gets the specified value

func (*TruthTable) GetKey

func (tt *TruthTable) GetKey(key *TableKey) interface{}

func (*TruthTable) IsComplete

func (tt *TruthTable) IsComplete() bool

IsComplete returns true if there's a value set for every single pair of items, otherwise it returns false.

func (*TruthTable) Keys

func (tt *TruthTable) Keys() []*TableKey

func (*TruthTable) Set

func (tt *TruthTable) Set(from string, to string, value interface{})

Set sets the value for from->to

func (*TruthTable) Table

func (tt *TruthTable) Table(schema string, rowLine bool, printElement func(string, string, interface{}) string) string

Jump to

Keyboard shortcuts

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