connectivity

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateResources

func CreateResources(kube *kube.Kubernetes, model *PodModel) error

func KubeContainer

func KubeContainer(name string, protocol v1.Protocol, port int) v1.Container

func KubePod

func KubePod(namespace string, name string, labels map[string]string, containers []*Container) *v1.Pod

KubePod returns the kube pod

func NamespaceSpec

func NamespaceSpec(name string, labels map[string]string) *v1.Namespace

func QualifiedServiceAddress

func QualifiedServiceAddress(serviceName string, namespace string) string

QualifiedServiceAddress returns the address that can be used to hit a service from any namespace in the cluster

func QualifiedServiceAddress(serviceName string, namespace string, dnsDomain string) string {
	return fmt.Sprintf("%s.%s.svc.%s", serviceName, namespace, dnsDomain)

func Service

func Service(namespace string, pod string, labels map[string]string, containers []*Container) *v1.Service

Service returns a kube service spec

func ServiceName

func ServiceName(namespace string, pod string) string

Types

type Container

type Container struct {
	Name     string
	Port     int
	Protocol v1.Protocol
}

type KubeProbeJob

type KubeProbeJob struct {
	FromPod  *NamespacedPod
	ToPod    *NamespacedPod
	Port     int
	Protocol v1.Protocol
}

func (*KubeProbeJob) ClientCommand

func (pj *KubeProbeJob) ClientCommand() []string

func (*KubeProbeJob) FromContainer

func (pj *KubeProbeJob) FromContainer() string

func (*KubeProbeJob) KubeExecCommand

func (pj *KubeProbeJob) KubeExecCommand() []string

func (*KubeProbeJob) ToAddress

func (pj *KubeProbeJob) ToAddress() string

func (*KubeProbeJob) ToURL

func (pj *KubeProbeJob) ToURL() string

type KubeProbeJobResults

type KubeProbeJobResults struct {
	Job         *KubeProbeJob
	IsConnected bool
	Err         error
	Command     string
}

type Namespace

type Namespace struct {
	Pods   map[string]*Pod
	Labels map[string]string
}

type NamespacedPod

type NamespacedPod struct {
	NamespaceName string
	PodName       string
	Namespace     *Namespace
	Pod           *Pod
	Containers    []*Container
}

func (*NamespacedPod) PodString

func (np *NamespacedPod) PodString() PodString

func (*NamespacedPod) ServiceName

func (np *NamespacedPod) ServiceName() string

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 {
	Labels     map[string]string
	IP         string
	Containers []*Container
}

type PodModel

type PodModel struct {
	Namespaces map[string]*Namespace
	// contains filtered or unexported fields
}

func NewDefaultModel

func NewDefaultModel(namespaces []string, podNames []string, port int, protocol v1.Protocol) *PodModel

func (*PodModel) AllPodStrings

func (m *PodModel) AllPodStrings() []PodString

func (*PodModel) AllPods

func (m *PodModel) AllPods() []*NamespacedPod

func (*PodModel) NewTruthTable

func (m *PodModel) NewTruthTable() *TruthTable

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 ProtocolPort

type ProtocolPort struct {
	Protocol v1.Protocol
	Port     int
}

type SyntheticProbeResult

type SyntheticProbeResult struct {
	Port     *ProtocolPort
	Policies *matcher.Policy
	Model    *PodModel
	Ingress  *TruthTable
	Egress   *TruthTable
	Combined *TruthTable
}

func RunSyntheticProbe

func RunSyntheticProbe(policies *matcher.Policy, portProtocol *ProtocolPort, model *PodModel) *SyntheticProbeResult

func RunSyntheticProbes

func RunSyntheticProbes(policies *matcher.Policy, ports []*ProtocolPort, model *PodModel) []*SyntheticProbeResult

type TruthTable

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

	Values map[string]map[string]bool
	// 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 *bool) *TruthTable

NewTruthTable creates a new truth table with froms and tos

func NewTruthTableFromItems

func NewTruthTableFromItems(items []string, defaultValue *bool) *TruthTable

NewTruthTableFromItems creates a new truth table with items

func RunKubeProbe

func RunKubeProbe(k8s *kube.Kubernetes, model *PodModel, port int, protocol v1.Protocol, numberOfWorkers int) *TruthTable

func (*TruthTable) Compare

func (tt *TruthTable) Compare(other *TruthTable) *TruthTable

Compare is used to check two truth tables for equality, returning its result in the form of a third truth table. Both tables are expected to have identical items.

func (*TruthTable) Get

func (tt *TruthTable) Get(from string, to string) bool

Get gets the specified value

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) Set

func (tt *TruthTable) Set(from string, to string, value bool)

Set sets the value for from->to

func (*TruthTable) SetAllFrom

func (tt *TruthTable) SetAllFrom(from string, value bool)

SetAllFrom sets all values where from = 'from'

func (*TruthTable) SetAllTo

func (tt *TruthTable) SetAllTo(to string, value bool)

SetAllTo sets all values where to = 'to'

func (*TruthTable) Table

func (tt *TruthTable) Table() *tablewriter.Table

func (*TruthTable) ValueCounts

func (tt *TruthTable) ValueCounts(ignoreLoopback bool) (int, int, int, int)

Jump to

Keyboard shortcuts

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