kube

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsIPAddressMatchForIPBlock

func IsIPAddressMatchForIPBlock(ip string, ipBlock *networkingv1.IPBlock) (bool, error)

func IsIPInCIDR

func IsIPInCIDR(ip string, cidr string) (bool, error)

func IsLabelSelectorEmpty added in v0.0.8

func IsLabelSelectorEmpty(l metav1.LabelSelector) 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 LabelSelectorTableLines added in v0.2.0

func LabelSelectorTableLines(selector metav1.LabelSelector) string

func ParseProtocol added in v0.1.0

func ParseProtocol(protocol string) (v1.Protocol, error)

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 RunIPAddressTests added in v0.0.8

func RunIPAddressTests()

func SerializeLabelSelector added in v0.0.8

func SerializeLabelSelector(ls metav1.LabelSelector) string

SerializeLabelSelector deterministically converts a metav1.LabelSelector into a string

Types

type Kubernetes

type Kubernetes struct {
	ClientSet  *kubernetes.Clientset
	RestConfig *rest.Config
}

func NewKubernetesForContext added in v0.0.3

func NewKubernetesForContext(context string) (*Kubernetes, error)

func (*Kubernetes) CreateNetworkPolicy

func (k *Kubernetes) CreateNetworkPolicy(policy *networkingv1.NetworkPolicy) (*networkingv1.NetworkPolicy, error)

func (*Kubernetes) CreateOrUpdateNamespace

func (k *Kubernetes) CreateOrUpdateNamespace(ns *v1.Namespace) (*v1.Namespace, error)

func (*Kubernetes) CreateOrUpdateService

func (k *Kubernetes) CreateOrUpdateService(svc *v1.Service) (*v1.Service, error)

func (*Kubernetes) CreatePod

func (k *Kubernetes) CreatePod(pod *v1.Pod) (*v1.Pod, error)

func (*Kubernetes) CreatePodIfNotExists

func (k *Kubernetes) CreatePodIfNotExists(pod *v1.Pod) (*v1.Pod, error)

func (*Kubernetes) CreateService

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

func (*Kubernetes) CreateServiceIfNotExists

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

func (*Kubernetes) DeleteAllNetworkPoliciesInNamespace

func (k *Kubernetes) DeleteAllNetworkPoliciesInNamespace(ns string) error

func (*Kubernetes) DeleteAllNetworkPoliciesInNamespaces

func (k *Kubernetes) DeleteAllNetworkPoliciesInNamespaces(nss []string) error

func (*Kubernetes) DeleteNamespace added in v0.1.1

func (k *Kubernetes) DeleteNamespace(ns string) error

func (*Kubernetes) DeleteNetworkPolicy added in v0.1.0

func (k *Kubernetes) DeleteNetworkPolicy(ns string, name string) 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) GetNamespace added in v0.1.0

func (k *Kubernetes) GetNamespace(namespace string) (*v1.Namespace, error)

func (*Kubernetes) GetNetworkPoliciesInNamespaces added in v0.0.3

func (k *Kubernetes) GetNetworkPoliciesInNamespaces(namespaces []string) ([]networkingv1.NetworkPolicy, error)

func (*Kubernetes) GetPod

func (k *Kubernetes) GetPod(namespace string, podName string) (*v1.Pod, error)

func (*Kubernetes) GetPodsInNamespaces

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

func (*Kubernetes) GetService added in v0.1.0

func (k *Kubernetes) GetService(namespace string, name string) (*v1.Service, error)

func (*Kubernetes) SetNamespaceLabels added in v0.1.0

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

func (*Kubernetes) SetPodLabels added in v0.1.0

func (k *Kubernetes) SetPodLabels(namespace string, podName string, labels map[string]string) (*v1.Pod, error)

func (*Kubernetes) UpdateNetworkPolicy added in v0.1.0

func (k *Kubernetes) UpdateNetworkPolicy(policy *networkingv1.NetworkPolicy) (*networkingv1.NetworkPolicy, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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