Documentation ¶
Index ¶
- func Client() (*kubernetes.Clientset, error)
- type Connectivity
- type Kubernetes
- func (k *Kubernetes) CleanNetworkPolicies(namespaces []string) error
- func (k *Kubernetes) CreateOrUpdateDeployment(ns, deploymentName string, replicas int32, labels map[string]string) (*appsv1.Deployment, error)
- func (k *Kubernetes) CreateOrUpdateNamespace(n string, labels map[string]string) (*v1.Namespace, error)
- func (k *Kubernetes) CreateOrUpdateNetworkPolicy(ns string, netpol *v1net.NetworkPolicy) (*v1net.NetworkPolicy, error)
- func (k *Kubernetes) ExecuteRemoteCommand(pod v1.Pod, cname string, command []string) (string, string, error)
- func (k *Kubernetes) GetPod(ns string, name string) (*v1.Pod, error)
- func (k *Kubernetes) GetPods(ns string, key string, val string) ([]v1.Pod, error)
- func (k *Kubernetes) Probe(ns1, pod1, ns2, pod2 string, port int) (bool, error)
- type NetworkPolicySpecBuilder
- func (n *NetworkPolicySpecBuilder) AddEgress(protoc v1.Protocol, port *int, portName *string, cidr *string, ...) *NetworkPolicySpecBuilder
- func (n *NetworkPolicySpecBuilder) AddIngress(protoc v1.Protocol, port *int, portName *string, cidr *string, ...) *NetworkPolicySpecBuilder
- func (n *NetworkPolicySpecBuilder) Get() *networkingv1.NetworkPolicy
- func (n *NetworkPolicySpecBuilder) SetName(namespace string, name string) *NetworkPolicySpecBuilder
- func (n *NetworkPolicySpecBuilder) SetPodSelector(labels map[string]string) *NetworkPolicySpecBuilder
- func (n *NetworkPolicySpecBuilder) SetTypeBoth() *NetworkPolicySpecBuilder
- func (n *NetworkPolicySpecBuilder) SetTypeEgress() *NetworkPolicySpecBuilder
- func (n *NetworkPolicySpecBuilder) SetTypeIngress() *NetworkPolicySpecBuilder
- func (n *NetworkPolicySpecBuilder) WithEgressDNS() *NetworkPolicySpecBuilder
- type Pod
- type Reachability
- func (r *Reachability) Expect(pod1 Pod, pod2 Pod, isConnected bool)
- func (r *Reachability) ExpectAllEgress(pod Pod, connected bool)
- func (r *Reachability) ExpectAllIngress(pod Pod, connected bool)
- func (r *Reachability) ExpectConn(spec *Connectivity)
- func (r *Reachability) Observe(pod1 Pod, pod2 Pod, isConnected bool)
- func (r *Reachability) PrintSummary(printExpected bool, printObserved bool, printComparison bool)
- func (r *Reachability) Summary() (trueObs int, falseObs int, comparison *TruthTable)
- type TruthTable
- func (tt *TruthTable) Compare(other *TruthTable) *TruthTable
- func (tt *TruthTable) Get(from string, to string) bool
- func (tt *TruthTable) IsComplete() bool
- func (tt *TruthTable) PrettyPrint(indent string) string
- func (tt *TruthTable) Set(from string, to string, value bool)
- func (tt *TruthTable) SetAllFrom(from string, value bool)
- func (tt *TruthTable) SetAllTo(to string, value bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Client ¶
func Client() (*kubernetes.Clientset, error)
Types ¶
type Connectivity ¶
type Kubernetes ¶
type Kubernetes struct { ClientSet *kubernetes.Clientset // contains filtered or unexported fields }
func NewKubernetes ¶
func NewKubernetes() (*Kubernetes, error)
func (*Kubernetes) CleanNetworkPolicies ¶
func (k *Kubernetes) CleanNetworkPolicies(namespaces []string) error
CleanNetworkPolicies is a convenience function for deleting network policies before startup of any new test.
func (*Kubernetes) CreateOrUpdateDeployment ¶
func (k *Kubernetes) CreateOrUpdateDeployment(ns, deploymentName string, replicas int32, labels map[string]string) (*appsv1.Deployment, error)
CreateOrUpdateDeployment is a convenience function for idempotent setup of deployments
func (*Kubernetes) CreateOrUpdateNamespace ¶
func (k *Kubernetes) CreateOrUpdateNamespace(n string, labels map[string]string) (*v1.Namespace, error)
CreateOrUpdateNamespace is a convenience function for idempotent setup of namespaces
func (*Kubernetes) CreateOrUpdateNetworkPolicy ¶
func (k *Kubernetes) CreateOrUpdateNetworkPolicy(ns string, netpol *v1net.NetworkPolicy) (*v1net.NetworkPolicy, error)
CreateOrUpdateNetworkPolicy is a convenience function for updating/creating netpols. Updating is important since some tests update a network policy to confirm that mutation works with a CNI.
func (*Kubernetes) ExecuteRemoteCommand ¶
func (k *Kubernetes) ExecuteRemoteCommand(pod v1.Pod, cname string, command []string) (string, string, error)
ExecuteRemoteCommand executes a remote shell command on the given pod returns the output from stdout and stderr
func (*Kubernetes) GetPods ¶
GetPods returns an array of all pods in the given namespace having a k/v label pair.
func (*Kubernetes) Probe ¶
func (k *Kubernetes) Probe(ns1, pod1, ns2, pod2 string, port int) (bool, error)
Probe execs into a pod and checks its connectivity to another pod. Of course it assumes that the target pod is serving on the input port, and also that wget is installed. For perf it uses spider rather then actually getting the full contents.
type NetworkPolicySpecBuilder ¶
type NetworkPolicySpecBuilder struct { Spec networkingv1.NetworkPolicySpec Name string Namespace string }
func (*NetworkPolicySpecBuilder) AddEgress ¶
func (n *NetworkPolicySpecBuilder) AddEgress(protoc v1.Protocol, port *int, portName *string, cidr *string, exceptCIDRs []string, podSelector map[string]string, nsSelector map[string]string, podSelectorMatchExp *[]metav1.LabelSelectorRequirement, nsSelectorMatchExp *[]metav1.LabelSelectorRequirement) *NetworkPolicySpecBuilder
func (*NetworkPolicySpecBuilder) AddIngress ¶
func (n *NetworkPolicySpecBuilder) AddIngress(protoc v1.Protocol, port *int, portName *string, cidr *string, exceptCIDRs []string, podSelector map[string]string, nsSelector map[string]string, podSelectorMatchExp *[]metav1.LabelSelectorRequirement, nsSelectorMatchExp *[]metav1.LabelSelectorRequirement) *NetworkPolicySpecBuilder
TODO: Add tests to match expressions
func (*NetworkPolicySpecBuilder) Get ¶
func (n *NetworkPolicySpecBuilder) Get() *networkingv1.NetworkPolicy
func (*NetworkPolicySpecBuilder) SetName ¶
func (n *NetworkPolicySpecBuilder) SetName(namespace string, name string) *NetworkPolicySpecBuilder
func (*NetworkPolicySpecBuilder) SetPodSelector ¶
func (n *NetworkPolicySpecBuilder) SetPodSelector(labels map[string]string) *NetworkPolicySpecBuilder
func (*NetworkPolicySpecBuilder) SetTypeBoth ¶
func (n *NetworkPolicySpecBuilder) SetTypeBoth() *NetworkPolicySpecBuilder
func (*NetworkPolicySpecBuilder) SetTypeEgress ¶
func (n *NetworkPolicySpecBuilder) SetTypeEgress() *NetworkPolicySpecBuilder
func (*NetworkPolicySpecBuilder) SetTypeIngress ¶
func (n *NetworkPolicySpecBuilder) SetTypeIngress() *NetworkPolicySpecBuilder
func (*NetworkPolicySpecBuilder) WithEgressDNS ¶
func (n *NetworkPolicySpecBuilder) WithEgressDNS() *NetworkPolicySpecBuilder
AddEgressDNS mutates the nth policy rule to allow DNS, convenience method
type Reachability ¶
type Reachability struct { Expected *TruthTable Observed *TruthTable Pods []Pod }
func NewReachability ¶
func NewReachability(pods []Pod, defaultExpectation bool) *Reachability
func (*Reachability) ExpectAllEgress ¶
func (r *Reachability) ExpectAllEgress(pod Pod, connected bool)
ExpectAllEgress defines that any traffic going out of the pod will be allowed/denied (true/false)
func (*Reachability) ExpectAllIngress ¶
func (r *Reachability) ExpectAllIngress(pod Pod, connected bool)
ExpectAllIngress defines that any traffic going into the pod will be allowed/denied (true/false)
func (*Reachability) ExpectConn ¶
func (r *Reachability) ExpectConn(spec *Connectivity)
ExpectConn is an experimental way to describe connectivity with named fields
func (*Reachability) PrintSummary ¶
func (r *Reachability) PrintSummary(printExpected bool, printObserved bool, printComparison bool)
func (*Reachability) Summary ¶
func (r *Reachability) Summary() (trueObs int, falseObs int, comparison *TruthTable)
type TruthTable ¶
type TruthTable struct { Items []string Values map[string]map[string]bool // contains filtered or unexported fields }
func NewTruthTable ¶
func NewTruthTable(items []string, defaultValue *bool) *TruthTable
func (*TruthTable) Compare ¶
func (tt *TruthTable) Compare(other *TruthTable) *TruthTable
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) PrettyPrint ¶
func (tt *TruthTable) PrettyPrint(indent string) string
func (*TruthTable) SetAllFrom ¶
func (tt *TruthTable) SetAllFrom(from string, value bool)
func (*TruthTable) SetAllTo ¶
func (tt *TruthTable) SetAllTo(to string, value bool)