connection

package
v0.9.20 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package connection is a wrapper for the connection to the Kubernetes API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResource

type APIResource struct {
	APIVersion string
	Kind       string
	Metadata   map[string]string
}

APIResource encapsulates the response from a raw/rest call to the Kubernetes API when getting a resource by name

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn simplifies the kubernetes API connection

func Get

func Get() *Conn

Get retrieves the connection object. Instantiates the connection if necessary

func (*Conn) ClusterIsDeployed

func (connection *Conn) ClusterIsDeployed() error

ClusterIsDeployed verifies that the connection instantiation did not report a failure at any point

func (*Conn) CreatePodFromObject

func (connection *Conn) CreatePodFromObject(pod *apiv1.Pod, probeName string) (*apiv1.Pod, error)

CreatePodFromObject creates a pod from the supplied pod object within an existing namespace

func (*Conn) DeletePodIfExists

func (connection *Conn) DeletePodIfExists(podName, namespace, probeName string) error

DeletePodIfExists deletes the given pod in the specified namespace.

func (*Conn) ExecCommand

func (connection *Conn) ExecCommand(cmd, namespace, podName string) (exitCode int, stdout string, stderr string, err error)

ExecCommand executes the supplied command on the given pod name in the specified namespace.

func (*Conn) GetNamespace

func (connection *Conn) GetNamespace(namespace string) (*apiv1.Namespace, error)

GetNamespace returns a particular namespace object for a given name

func (*Conn) GetOrCreateNamespace

func (connection *Conn) GetOrCreateNamespace(namespace string) (*apiv1.Namespace, error)

GetOrCreateNamespace will retrieve or create a namespace within the current Kubernetes cluster

func (*Conn) GetPodIPs

func (connection *Conn) GetPodIPs(namespace, podName string) (podIP string, hostIP string, err error)

GetPodIPs will retrieve a pod by name and return its IP and its host's IP

func (*Conn) GetPodsByNamespace

func (connection *Conn) GetPodsByNamespace(namespace string) (*apiv1.PodList, error)

GetPodsByNamespace returns list of pods within specified namespace

func (*Conn) GetRawResourceByName

func (connection *Conn) GetRawResourceByName(apiEndPoint, namespace, resourceType, resourceName string) (resource APIResource, err error)

GetRawResourceByName makes a 'raw' REST call to the specified K8s api endpoint to get a resource by name and namespace. This is used to interact with available custom resources in the cluster, such as azureidentitybindings. An empty value for 'namespace' means retrieving all resources accross all namespaces Sample request params:

apiEndPoint:	apis/aadpodidentity.k8s.io/v1
namespace:		"demo-ns"
resourceName:	"azureidentitybindings"

func (*Conn) PostRawResource

func (connection *Conn) PostRawResource(apiEndPoint string, namespace string, resourceName string, resourceBody interface{}) (resource APIResource, err error)

PostRawResource makes a 'raw' POST call to the specified K8s api endpoint to create a resource. This is used to interact with available custom resources in the cluster, such as azureidentitybindings. Sample request params:

apiEndPoint:	apis/aadpodidentity.k8s.io/v1
namespace:		"demo-ns"
resourceName:	"azureidentitybindings"
resourceBody:	"{...}"

func (*Conn) WaitForPod added in v0.9.3

func (connection *Conn) WaitForPod(namespace string, podName string) (err error)

WaitForPod ensures pod has entered a running state, or returns any error encountered

type Connection

type Connection interface {
	ClusterIsDeployed() error
	CreatePodFromObject(pod *apiv1.Pod, probeName string) (*apiv1.Pod, error)
	DeletePodIfExists(podName, namespace, probeName string) error
	ExecCommand(command, namespace, podName string) (status int, stdout string, stderr string, err error)
	GetPodsByNamespace(namespace string) (*apiv1.PodList, error)
	GetPodIPs(namespace, podName string) (string, string, error)
	GetRawResourceByName(apiEndPoint, namespace, resourceType, resourceName string) (resource APIResource, err error)
	PostRawResource(apiEndPoint string, namespace string, resourceName string, resourceBody interface{}) (resource APIResource, err error)
	WaitForPod(namespace string, podName string) (err error)
}

Connection should be used instead of Conn within probes to allow mocking during testing

Directories

Path Synopsis
Package aks is a wrapper for the connection to the Azure Kubernetes API
Package aks is a wrapper for the connection to the Azure Kubernetes API

Jump to

Keyboard shortcuts

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