Documentation ¶
Overview ¶
Package connection is a wrapper for the connection to the Kubernetes API
Index ¶
- type APIResource
- type Conn
- func (connection *Conn) ClusterIsDeployed() error
- func (connection *Conn) CreatePodFromObject(pod *apiv1.Pod, probeName string) (*apiv1.Pod, error)
- func (connection *Conn) DeletePodIfExists(podName, namespace, probeName string) error
- func (connection *Conn) ExecCommand(cmd, namespace, podName string) (exitCode int, stdout string, stderr string, err error)
- func (connection *Conn) GetNamespace(namespace string) (*apiv1.Namespace, error)
- func (connection *Conn) GetOrCreateNamespace(namespace string) (*apiv1.Namespace, error)
- func (connection *Conn) GetPodIPs(namespace, podName string) (podIP string, hostIP string, err error)
- func (connection *Conn) GetPodsByNamespace(namespace string) (*apiv1.PodList, error)
- func (connection *Conn) GetRawResourceByName(apiEndPoint, namespace, resourceType, resourceName string) (resource APIResource, err error)
- func (connection *Conn) PostRawResource(apiEndPoint string, namespace string, resourceName string, ...) (resource APIResource, err error)
- func (connection *Conn) WaitForPod(namespace string, podName string) (err error)
- type Connection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIResource ¶
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 ¶
ClusterIsDeployed verifies that the connection instantiation did not report a failure at any point
func (*Conn) CreatePodFromObject ¶
CreatePodFromObject creates a pod from the supplied pod object within an existing namespace
func (*Conn) DeletePodIfExists ¶
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 ¶
GetNamespace returns a particular namespace object for a given name
func (*Conn) GetOrCreateNamespace ¶
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 ¶
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: "{...}"
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