kubernetes

package
v0.0.0-...-b43e092 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	DiscoverAPIGroups() error

	// Getter & Setter
	Clientset() *kubernetes.Clientset
	GardenClientset() *clientset.Clientset
	GetAPIResourceList() []*metav1.APIResourceList
	GetConfig() *rest.Config
	GetResourceAPIGroups() map[string][]string
	RESTClient() rest.Interface
	SetConfig(*rest.Config)
	SetClientset(*kubernetes.Clientset)
	SetGardenClientset(*clientset.Clientset)
	SetRESTClient(rest.Interface)
	SetResourceAPIGroups(map[string][]string)
	MachineV1alpha1(string, string, string) *rest.Request

	// Cleanup
	ListResources(...string) (unstructured.Unstructured, error)
	CleanupResources(map[string]map[string]bool) error
	CleanupAPIGroupResources(map[string]map[string]bool, string, []string) error
	CheckResourceCleanup(map[string]map[string]bool, string, []string) (bool, error)

	// Namespaces
	CreateNamespace(*corev1.Namespace, bool) (*corev1.Namespace, error)
	UpdateNamespace(*corev1.Namespace) (*corev1.Namespace, error)
	GetNamespace(string) (*corev1.Namespace, error)
	ListNamespaces(metav1.ListOptions) (*corev1.NamespaceList, error)
	DeleteNamespace(string) error

	// Secrets
	CreateSecret(string, string, corev1.SecretType, map[string][]byte, bool) (*corev1.Secret, error)
	CreateSecretObject(*corev1.Secret, bool) (*corev1.Secret, error)
	UpdateSecret(string, string, corev1.SecretType, map[string][]byte) (*corev1.Secret, error)
	UpdateSecretObject(*corev1.Secret) (*corev1.Secret, error)
	ListSecrets(string, metav1.ListOptions) (*corev1.SecretList, error)
	GetSecret(string, string) (*corev1.Secret, error)
	DeleteSecret(string, string) error

	// ConfigMaps
	CreateConfigMap(string, string, map[string]string, bool) (*corev1.ConfigMap, error)
	UpdateConfigMap(string, string, map[string]string) (*corev1.ConfigMap, error)
	GetConfigMap(string, string) (*corev1.ConfigMap, error)
	DeleteConfigMap(string, string) error

	// Services
	GetService(string, string) (*corev1.Service, error)
	DeleteService(string, string) error

	// Deployments
	GetDeployment(string, string) (*mapping.Deployment, error)
	ListDeployments(string, metav1.ListOptions) ([]*mapping.Deployment, error)
	PatchDeployment(string, string, []byte) (*mapping.Deployment, error)
	DeleteDeployment(string, string) error

	// StatefulSets
	DeleteStatefulSet(string, string) error

	// Jobs
	GetJob(string, string) (*batchv1.Job, error)
	DeleteJob(string, string) error

	// ReplicaSets
	ListReplicaSets(string, metav1.ListOptions) ([]*mapping.ReplicaSet, error)
	DeleteReplicaSet(string, string) error

	// Pods
	GetPod(string, string) (*corev1.Pod, error)
	ListPods(string, metav1.ListOptions) (*corev1.PodList, error)
	GetPodLogs(string, string, *corev1.PodLogOptions) (*bytes.Buffer, error)
	ForwardPodPort(string, string, int, int) (chan struct{}, error)
	CheckForwardPodPort(string, string, int, int) (bool, error)
	DeletePod(string, string) error

	// Nodes
	ListNodes(metav1.ListOptions) (*corev1.NodeList, error)

	// RoleBindings
	ListRoleBindings(string, metav1.ListOptions) (*rbacv1.RoleBindingList, error)

	// Arbitrary manifests
	Apply([]byte) error

	// Miscellaneous
	Curl(string) (*rest.Result, error)
	QueryVersion() (string, error)
	Version() string
}

Client is an interface which is used to wrap the interactions with a Kubernetes cluster (which are performed with the help of kubernetes/client-go) in order to allow the implementation of several Kubernetes versions.

func NewClientFromBytes

func NewClientFromBytes(kubeconfig []byte) (Client, error)

NewClientFromBytes creates a new Client struct for a given kubeconfig byte slice.

func NewClientFromFile

func NewClientFromFile(kubeconfigPath string) (Client, error)

NewClientFromFile creates a new Client struct for a given kubeconfig. The kubeconfig will be read from the filesystem at location <kubeconfigPath>. If no filepath is given, the in-cluster configuration will be taken into account.

func NewClientFromSecret

func NewClientFromSecret(k8sClient Client, namespace, secretName string) (Client, error)

NewClientFromSecret creates a new Client struct for a given kubeconfig stored as a Secret in an existing Kubernetes cluster. This cluster will be accessed by the <k8sClient>. It will read the Secret <secretName> in <namespace>. The Secret must contain a field "kubeconfig" which will be used.

func NewClientFromSecretObject

func NewClientFromSecretObject(secret *corev1.Secret) (Client, error)

NewClientFromSecretObject creates a new Client struct for a given Kubernetes Secret object. The Secret must contain a field "kubeconfig" which will be used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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