kube

package
v0.0.0-...-056dfb2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clientset

func Clientset() (*kubernetes.Clientset, error)

func IsIPBlockMatchForIP

func IsIPBlockMatchForIP(ip string, ipBlock *v1.IPBlock) bool

IsIPBlockMatchForIP is completely untested. TODO!

func IsIPInCIDR

func IsIPInCIDR(ip string, cidr string) bool

func IsLabelsMatchLabelSelector

func IsLabelsMatchLabelSelector(labels map[string]string, labelSelector metav1.LabelSelector) bool

IsLabelsMatchLabelSelector matches labels to a kube LabelSelector. From the docs: > A label selector is a label query over a set of resources. The result of matchLabels and > matchExpressions are ANDed. An empty label selector matches all objects. A null > label selector matches no objects.

func IsMatchExpressionMatchForLabels

func IsMatchExpressionMatchForLabels(labels map[string]string, exp metav1.LabelSelectorRequirement) bool

func IsNameMatch

func IsNameMatch(objectName string, matcher string) bool

IsNameMatch follows the kube pattern of "empty string means matches All" It will return:

if matcher is empty: true
if objectName and matcher are the same: true
otherwise false

func QualifiedServiceAddress

func QualifiedServiceAddress(ns string, service string) string

Types

type CurlCommand

type CurlCommand struct {
	TimeoutSeconds int
	URL            string
}

func (*CurlCommand) Command

func (cc *CurlCommand) Command() []string

func (*CurlCommand) ParseOutput

func (cc *CurlCommand) ParseOutput(out string, errorOut string, execErr error) *ProbeResult

type KindClient

type KindClient struct{}

func NewKindClient

func NewKindClient() *KindClient

func (*KindClient) CreateCluster

func (kc *KindClient) CreateCluster(clusterName string, image string, config string) error

func (*KindClient) CreateClusterWithConfigFile

func (kc *KindClient) CreateClusterWithConfigFile(clusterName string, image string, configFilePath string) error

func (*KindClient) GetCluster

func (kc *KindClient) GetCluster(name string) (bool, error)

func (*KindClient) GetClusters

func (kc *KindClient) GetClusters() ([]string, error)

func (*KindClient) GetVersion

func (kc *KindClient) GetVersion() (string, error)

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(ns string) error

func (*Kubernetes) CreateDaemonSet

func (k *Kubernetes) CreateDaemonSet(namespace string, ds *appsv1.DaemonSet) (*appsv1.DaemonSet, error)

func (*Kubernetes) CreateDaemonSetIfNotExists

func (k *Kubernetes) CreateDaemonSetIfNotExists(namespace string, ds *appsv1.DaemonSet) (*appsv1.DaemonSet, error)

func (*Kubernetes) CreateNetworkPolicy

func (k *Kubernetes) CreateNetworkPolicy(netpol *v1net.NetworkPolicy) (*v1net.NetworkPolicy, error)

func (*Kubernetes) CreateOrUpdateNamespace

func (k *Kubernetes) CreateOrUpdateNamespace(n string, labels map[string]string) (*v1.Namespace, error)

func (*Kubernetes) CreateOrUpdateNetworkPolicy

func (k *Kubernetes) CreateOrUpdateNetworkPolicy(ns string, netpol *v1net.NetworkPolicy) (*v1net.NetworkPolicy, error)

func (*Kubernetes) CreateService

func (k *Kubernetes) CreateService(namespace string, svc *v1.Service) (*v1.Service, error)

func (*Kubernetes) CreateServiceIfNotExists

func (k *Kubernetes) CreateServiceIfNotExists(namespace string, svc *v1.Service) (*v1.Service, error)

func (*Kubernetes) ExecuteRemoteCommand

func (k *Kubernetes) ExecuteRemoteCommand(namespace string, pod string, container string, command []string) (string, string, error, error)

ExecuteRemoteCommand executes a remote shell command on the given pod returns the output from stdout and stderr

func (*Kubernetes) GetPodsInNamespaces

func (k *Kubernetes) GetPodsInNamespaces(namespaces []string) ([]v1.Pod, error)

func (*Kubernetes) Probe

func (k *Kubernetes) Probe(job *ProbeJob) (*ProbeResult, error)

func (*Kubernetes) ProbeConnectivity

func (k *Kubernetes) ProbeConnectivity(jobs []*ProbeJob) *netpol.StringTruthTable

func (*Kubernetes) ProbePodToPod

func (k *Kubernetes) ProbePodToPod(namespaces []string, timeoutSeconds int) (*netpol.StringTruthTable, error)

type NetcatCommand

type NetcatCommand struct {
	TimeoutSeconds int
	ToAddress      string
	ToPort         int
}

func (*NetcatCommand) Command

func (nc *NetcatCommand) Command() []string

func (*NetcatCommand) ParseOutput

func (nc *NetcatCommand) ParseOutput(out string, errorOut string, execErr error) *ProbeResult

type ProbeCommand

type ProbeCommand interface {
	Command() []string
	ParseOutput(out string, errorOut string, execErr error) *ProbeResult
}

type ProbeCommandType

type ProbeCommandType string
const (
	ProbeCommandTypeCurl   ProbeCommandType = "ProbeCommandTypeCurl"
	ProbeCommandTypeWget   ProbeCommandType = "ProbeCommandTypeWget"
	ProbeCommandTypeNetcat ProbeCommandType = "ProbeCommandTypeNetcat"
)

type ProbeJob

type ProbeJob struct {
	FromNamespace  string
	FromPod        string
	FromContainer  string
	ToAddress      string
	ToPort         int
	TimeoutSeconds int
	CommandType    ProbeCommandType
	FromKey        string
	ToKey          string
}

func (*ProbeJob) Command

func (pj *ProbeJob) Command() ProbeCommand

func (*ProbeJob) GetFromKey

func (pj *ProbeJob) GetFromKey() string

func (*ProbeJob) GetToKey

func (pj *ProbeJob) GetToKey() string

func (*ProbeJob) KubeExecCommand

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

func (*ProbeJob) ToURL

func (pj *ProbeJob) ToURL() string

type ProbeJobResult

type ProbeJobResult struct {
	Job    *ProbeJob
	Result *ProbeResult
	Err    error
}

ProbeJobResult : if command can't be run, Result should be nil and Err non-nil

type ProbeResult

type ProbeResult struct {
	Out      string
	ErrorOut string
	Err      string
	ExitCode int
}

type WgetCommand

type WgetCommand struct {
	TimeoutSeconds int
	URL            string
}

func (*WgetCommand) Command

func (wc *WgetCommand) Command() []string

func (*WgetCommand) ParseOutput

func (wc *WgetCommand) ParseOutput(out string, errorOut string, execErr error) *ProbeResult

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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