kubernetes

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package kubernetes provides an interface to manage a kubernetes cluster with the help of kind en kubernetes' client-go modules. Use the Builder to create a new cluster.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	KubeConfig *kubeconfig.KubeConfig
	// contains filtered or unexported fields
}

Cluster object can be used to interact with kubernetes clusters. It abstracts away calls to the kubernetes client-go api.

func (Cluster) GetNodes

func (c Cluster) GetNodes() (*corev1.NodeList, error)

GetNodes returns the number of nodes in the cluster, or an error if it couldn't get these.

func (*Cluster) GetNumberOfNodes

func (c *Cluster) GetNumberOfNodes() (int, error)

GetNumberOfNodes returns the number of nodes in the cluster, or an error if it couldn't get these.

func (*Cluster) GetNumberOfPods

func (c *Cluster) GetNumberOfPods(namespace string) (int, error)

GetNumberOfPods returns the number of pods in the cluster, or an error if it couldn't get these.

func (*Cluster) GetNumberOfReadyNodes

func (c *Cluster) GetNumberOfReadyNodes() (int, error)

GetNumberOfReadyNodes returns the number of nodes in the cluster, or an error if it couldn't get these.

func (Cluster) GetPods

func (c Cluster) GetPods(namespace string) (*corev1.PodList, error)

GetPods gets a list of pods from kubernetes using the specified namespace

func (*Cluster) RemoveAllApateletsFromCluster

func (c *Cluster) RemoveAllApateletsFromCluster() error

RemoveAllApateletsFromCluster removes all apatelets from the Kubernetes cluster.

func (Cluster) RemoveNodeFromCluster

func (c Cluster) RemoveNodeFromCluster(nodename string) error

RemoveNodeFromCluster removes a node with a given name from the cluster.

func (Cluster) RemoveNodesFromCluster

func (c Cluster) RemoveNodesFromCluster(uuids []uuid.UUID) error

RemoveNodesFromCluster removes all apatelet nodes with the given uuids from the cluster.

func (*Cluster) Shutdown

func (c *Cluster) Shutdown() error

Shutdown performs clean up on the cluster before shutdown.

type ClusterAPI

type ClusterAPI interface {
	GetNodes() (*corev1.NodeList, error)
	GetPods(namespace string) (*corev1.PodList, error)

	GetNumberOfNodes() (int, error)
	GetNumberOfReadyNodes() (int, error)
	GetNumberOfPods(namespace string) (int, error)

	RemoveAllApateletsFromCluster() error
	RemoveNodesFromCluster(uuids []uuid.UUID) error
	RemoveNodeFromCluster(nodename string) error
}

ClusterAPI are API calls for a cluster connection

type ClusterManager

type ClusterManager interface {
	// GetKubeConfig returns the KubeConfig by this cluster. This is also the place where one can create the cluster if necessary.
	GetKubeConfig() (*kubeconfig.KubeConfig, error)

	// Shutdown is called when the program exits. This can be used to clean up a cluster if necessary.
	Shutdown(*Cluster) error
}

ClusterManager contains utilities to handle connecting / creating a cluster and shutting it down if necessary.

type ClusterManagerHandler

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

ClusterManagerHandler contains utilities to create cluster objects based on a certain manager.

func NewClusterManagerHandler

func NewClusterManagerHandler() ClusterManagerHandler

NewClusterManagerHandler creates a new ClusterManagerHandler, depending on what environment variables have been set

func (*ClusterManagerHandler) NewCluster

func (cmh *ClusterManagerHandler) NewCluster() (*Cluster, error)

NewCluster creates a new cluster object by calling GetKubeConfig on its manager

func (*ClusterManagerHandler) NewClusterFromKubeConfig

func (cmh *ClusterManagerHandler) NewClusterFromKubeConfig(kubeConfig *kubeconfig.KubeConfig) (*Cluster, error)

NewClusterFromKubeConfig creates a new KubernetesCluster from a location of a kubeconfig.

type KinDClusterManager

type KinDClusterManager struct{}

KinDClusterManager is a struct which implements ClusterManager by creating a kind cluster.

func (*KinDClusterManager) GetKubeConfig

func (k *KinDClusterManager) GetKubeConfig() (*kubeconfig.KubeConfig, error)

GetKubeConfig validates the cluster name, creates the Kind cluster and returns its kubeconfig.

func (*KinDClusterManager) Shutdown

func (k *KinDClusterManager) Shutdown(*Cluster) error

Shutdown deletes the KinD cluster.

type UnmanagedClusterManager

type UnmanagedClusterManager struct{}

UnmanagedClusterManager is a struct which implements ClusterManager by writing the given kubeconfig to a file.

func (*UnmanagedClusterManager) GetKubeConfig

func (u *UnmanagedClusterManager) GetKubeConfig() (*kubeconfig.KubeConfig, error)

GetKubeConfig writes the given kubeconfig and returns it as a struct.

func (*UnmanagedClusterManager) Shutdown

func (u *UnmanagedClusterManager) Shutdown(cluster *Cluster) error

Shutdown currently does nothing.

Directories

Path Synopsis
Package kubeconfig provides the ability to create, read, and manage the kubeconfig file/bytes.
Package kubeconfig provides the ability to create, read, and manage the kubeconfig file/bytes.
Package mock_kubernetes is a generated GoMock package.
Package mock_kubernetes is a generated GoMock package.
Package node contains some utilities to describe Kubernetes nodes
Package node contains some utilities to describe Kubernetes nodes

Jump to

Keyboard shortcuts

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