kubernetesbase

package
v0.0.0-...-32fc51b Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2018 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CronJobs is a constant for a Kubernetes resource with the same name.
	CronJobs = "cronjobs"

	// CustomResourceDefinitions is a constant for a Kubernetes resource with the same name.
	CustomResourceDefinitions = "customresourcedefinitions"

	// DaemonSets is a constant for a Kubernetes resource with the same name.
	DaemonSets = "daemonsets"

	// Deployments is a constant for a Kubernetes resource with the same name.
	Deployments = "deployments"

	// Ingresses is a constant for a Kubernetes resource with the same name.
	Ingresses = "ingresses"

	// Jobs is a constant for a Kubernetes resource with the same name.
	Jobs = "jobs"

	// Namespaces is a constant for a Kubernetes resource with the same name.
	Namespaces = "namespaces"

	// PersistentVolumeClaims is a constant for a Kubernetes resource with the same name.
	PersistentVolumeClaims = "persistentvolumeclaims"

	// Pods is a constant for a Kubernetes resource with the same name.
	Pods = "pods"

	// ReplicaSets is a constant for a Kubernetes resource with the same name.
	ReplicaSets = "replicasets"

	// ReplicationControllers is a constant for a Kubernetes resource with the same name.
	ReplicationControllers = "replicationcontrollers"

	// Services is a constant for a Kubernetes resource with the same name.
	Services = "services"

	// StatefulSets is a constant for a Kubernetes resource with the same name.
	StatefulSets = "statefulsets"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a struct containing the configuration for the respective Kubernetes cluster, the collection of Kubernetes clients <Clientset> containing all REST clients for the built-in Kubernetes API groups, and the GardenClientset which is a REST clientset for the Garden API group. The RESTClient itself is a normal HTTP client for the respective Kubernetes cluster, allowing requests to arbitrary URLs. The version string contains only the major/minor part in the form <major>.<minor>.

func NewForConfig

func NewForConfig(config *rest.Config) (*Client, error)

NewForConfig returns a new Kubernetes base client.

func (*Client) APIExtensionsClientset

func (c *Client) APIExtensionsClientset() *apiextensionclientset.Clientset

APIExtensionsClientset will return the apiextensionsClientset attribute of the Client object.

func (*Client) APIRegistrationClientset

func (c *Client) APIRegistrationClientset() *apiregistrationclientset.Clientset

APIRegistrationClientset will return the apiregistrationClientset attribute of the Client object.

func (*Client) Apply

func (c *Client) Apply(m []byte) error

Apply is a function which does the same like `kubectl apply -f <file>`. It takes a bunch of manifests <m>, all concatenated in a byte slice, and sends them one after the other to the API server. If a resource already exists at the API server, it will update it. It returns an error as soon as the first error occurs.

func (*Client) CheckForwardPodPort

func (c *Client) CheckForwardPodPort(namespace, name string, local, remote int) (bool, error)

CheckForwardPodPort tries to forward the <remote> port of the pod with name <name> in namespace <namespace> to the <local> port. If <local> equals zero, a free port will be chosen randomly. It returns true if the port forward connection has been established successfully or false otherwise.

func (*Client) CheckResourceCleanup

func (c *Client) CheckResourceCleanup(logger *logrus.Entry, exceptions map[string]map[string]bool, resource string, apiGroupPath []string) (bool, error)

CheckResourceCleanup will check whether all resources except for those in the <exceptions> map have been deleted.

func (*Client) CleanupAPIGroupResources

func (c *Client) CleanupAPIGroupResources(exceptions map[string]map[string]bool, resource string, apiGroupPath []string) error

CleanupAPIGroupResources will clean up all resources of a single API group.

func (*Client) CleanupResources

func (c *Client) CleanupResources(exceptions map[string]map[string]bool) error

CleanupResources will delete all resources except for those stored in the <exceptions> map.

func (*Client) Clientset

func (c *Client) Clientset() *kubernetes.Clientset

Clientset will return the clientset attribute of the Client object.

func (*Client) CreateConfigMap

func (c *Client) CreateConfigMap(namespace, name string, data map[string]string, updateIfExists bool) (*corev1.ConfigMap, error)

CreateConfigMap creates a new ConfigMap object.

func (*Client) CreateNamespace

func (c *Client) CreateNamespace(namespace *corev1.Namespace, updateIfExists bool) (*corev1.Namespace, error)

CreateNamespace creates a new Namespace object.

func (*Client) CreateOrPatchRoleBinding

func (c *Client) CreateOrPatchRoleBinding(meta metav1.ObjectMeta, transform func(*rbacv1.RoleBinding) *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)

CreateOrPatchRoleBinding either creates the object or patches the existing one with the strategic merge patch type.

func (*Client) CreateSecret

func (c *Client) CreateSecret(namespace, name string, secretType corev1.SecretType, data map[string][]byte, updateIfExists bool) (*corev1.Secret, error)

CreateSecret creates a new Secret object.

func (*Client) CreateSecretObject

func (c *Client) CreateSecretObject(secret *corev1.Secret, updateIfExists bool) (*corev1.Secret, error)

CreateSecretObject creates a new Secret object.

func (*Client) Curl

func (c *Client) Curl(path string) (*rest.Result, error)

Curl performs an HTTP GET request to the API server and returns the result.

func (*Client) DeleteAPIService

func (c *Client) DeleteAPIService(name string) error

DeleteAPIService will gracefully delete an APIService with the given <name>.

func (*Client) DeleteAPIServiceForcefully

func (c *Client) DeleteAPIServiceForcefully(name string) error

DeleteAPIServiceForcefully will forcefully delete an APIService with the given <name>.

func (*Client) DeleteCRDForcefully

func (c *Client) DeleteCRDForcefully(name string) error

DeleteCRDForcefully will forcefully delete a CRD with the given <name>.

func (*Client) DeleteConfigMap

func (c *Client) DeleteConfigMap(namespace, name string) error

DeleteConfigMap deletes a ConfigMap object.

func (*Client) DeleteDeployment

func (c *Client) DeleteDeployment(namespace, name string) error

DeleteDeployment deletes a Deployment object.

func (*Client) DeleteJob

func (c *Client) DeleteJob(namespace, name string) error

DeleteJob deletes a Job object.

func (*Client) DeleteNamespace

func (c *Client) DeleteNamespace(name string) error

DeleteNamespace deletes a namespace.

func (*Client) DeletePod

func (c *Client) DeletePod(namespace, name string) error

DeletePod will delete a Pod with the given <name> in the given <namespace>.

func (*Client) DeletePodForcefully

func (c *Client) DeletePodForcefully(namespace, name string) error

DeletePodForcefully will forcefully delete a Pod with the given <name> in the given <namespace>.

func (*Client) DeleteReplicaSet

func (c *Client) DeleteReplicaSet(namespace, name string) error

DeleteReplicaSet deletes a ReplicaSet object.

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(namespace, name string) error

DeleteSecret deletes an already existing Secret object.

func (*Client) DeleteService

func (c *Client) DeleteService(namespace, name string) error

DeleteService deletes an already existing Service object.

func (*Client) DeleteStatefulSet

func (c *Client) DeleteStatefulSet(namespace, name string) error

DeleteStatefulSet deletes a StatefulSet object.

func (*Client) DiscoverAPIGroups

func (c *Client) DiscoverAPIGroups() error

DiscoverAPIGroups will fetch all Kubernetes server resources, i.e. all registered API groups and the associated resources.

func (*Client) ForwardPodPort

func (c *Client) ForwardPodPort(namespace, name string, local, remote int) (chan struct{}, error)

ForwardPodPort tries to forward the <remote> port of the pod with name <name> in namespace <namespace> to the <local> port. If <local> equals zero, a free port will be chosen randomly. It returns the stop channel which must be closed when the port forward connection should be terminated.

func (*Client) GardenClientset

func (c *Client) GardenClientset() *gardenclientset.Clientset

GardenClientset will return the gardenClientset attribute of the Client object.

func (*Client) GetAPIResourceList

func (c *Client) GetAPIResourceList() []*metav1.APIResourceList

GetAPIResourceList will return the Kubernetes API resource list.

func (*Client) GetConfig

func (c *Client) GetConfig() *rest.Config

GetConfig will return the config attribute of the Client object.

func (*Client) GetConfigMap

func (c *Client) GetConfigMap(namespace, name string) (*corev1.ConfigMap, error)

GetConfigMap returns a ConfigMap object.

func (*Client) GetDeployment

func (c *Client) GetDeployment(namespace, name string) (*appsv1.Deployment, error)

GetDeployment returns a Deployment object.

func (*Client) GetJob

func (c *Client) GetJob(namespace, name string) (*batch_v1.Job, error)

GetJob returns a Job object.

func (*Client) GetNamespace

func (c *Client) GetNamespace(name string) (*corev1.Namespace, error)

GetNamespace returns a Namespace object.

func (*Client) GetPod

func (c *Client) GetPod(namespace, name string) (*corev1.Pod, error)

GetPod will return the Pod object for the given <name> in the given <namespace>.

func (*Client) GetPodLogs

func (c *Client) GetPodLogs(namespace, name string, podLogOptions *corev1.PodLogOptions) (*bytes.Buffer, error)

GetPodLogs will get the logs of all containers within the Pod for the given <name> in the given <namespace> for the given <podLogOptions>.

func (*Client) GetResourceAPIGroups

func (c *Client) GetResourceAPIGroups() map[string][]string

GetResourceAPIGroups will return the resourceAPIGroups attribute of the Client object.

func (*Client) GetSecret

func (c *Client) GetSecret(namespace, name string) (*corev1.Secret, error)

GetSecret returns a Secret object.

func (*Client) GetService

func (c *Client) GetService(namespace, name string) (*corev1.Service, error)

GetService returns the desired Service object.

func (*Client) ListAPIServices

func (c *Client) ListAPIServices(opts metav1.ListOptions) (*apiregistrationv1beta1.APIServiceList, error)

ListAPIServices will list all the APIServices for the given <listOptions>.

func (*Client) ListCRDs

ListCRDs will list all the CRDs for the given <listOptions>.

func (*Client) ListDaemonSets

func (c *Client) ListDaemonSets(namespace string, opts metav1.ListOptions) (*appsv1.DaemonSetList, error)

ListDaemonSets returns the list of DaemonSets in the given namespace.

func (*Client) ListDeployments

func (c *Client) ListDeployments(namespace string, listOptions metav1.ListOptions) (*appsv1.DeploymentList, error)

ListDeployments returns the list of Deployments in the given <namespace>.

func (*Client) ListNamespaces

func (c *Client) ListNamespaces(selector metav1.ListOptions) (*corev1.NamespaceList, error)

ListNamespaces returns a list of namespaces. The selection can be restricted by passing a <selector>.

func (*Client) ListNodes

func (c *Client) ListNodes(listOptions metav1.ListOptions) (*corev1.NodeList, error)

ListNodes returns a list of Nodes.

func (*Client) ListPods

func (c *Client) ListPods(namespace string, listOptions metav1.ListOptions) (*corev1.PodList, error)

ListPods will list all the Pods in the given <namespace> for the given <listOptions>.

func (*Client) ListReplicaSets

func (c *Client) ListReplicaSets(namespace string, listOptions metav1.ListOptions) (*appsv1.ReplicaSetList, error)

ListReplicaSets returns the list of ReplicaSets in the given <namespace>.

func (*Client) ListResources

func (c *Client) ListResources(absPath ...string) (unstructured.Unstructured, error)

ListResources will return a list of Kubernetes resources as JSON byte slice.

func (*Client) ListRoleBindings

func (c *Client) ListRoleBindings(namespace string, selector metav1.ListOptions) (*rbacv1.RoleBindingList, error)

ListRoleBindings returns a list of rolebindings in a given <namespace>. The selection can be restricted by passsing an <selector>.

func (*Client) ListSecrets

func (c *Client) ListSecrets(namespace string, listOptions metav1.ListOptions) (*corev1.SecretList, error)

ListSecrets lists all Secrets in a given <namespace>.

func (*Client) ListStatefulSets

func (c *Client) ListStatefulSets(namespace string, listOptions metav1.ListOptions) (*appsv1.StatefulSetList, error)

ListStatefulSets returns the list of StatefulSets in the given <namespace>.

func (*Client) MachineClientset

func (c *Client) MachineClientset() *machineclientset.Clientset

MachineClientset will return the machineClientset attribute of the Client object.

func (*Client) MachineV1alpha1

func (c *Client) MachineV1alpha1(verb, resource, namespace string) *rest.Request

MachineV1alpha1 creates a RESTClient request object for the given <verb> and the given <machineClassPlural>.

func (*Client) PatchDeployment

func (c *Client) PatchDeployment(namespace, name string, body []byte) (*appsv1.Deployment, error)

PatchDeployment patches a Deployment object.

func (*Client) PatchNamespace

func (c *Client) PatchNamespace(name string, body []byte) (*corev1.Namespace, error)

PatchNamespace patches a Namespace object.

func (*Client) QueryVersion

func (c *Client) QueryVersion() (string, error)

QueryVersion queries the version of the API server and returns the GitVersion (e.g., v1.11.2).

func (*Client) RESTClient

func (c *Client) RESTClient() rest.Interface

RESTClient will return the restClient attribute of the Client object.

func (*Client) ScaleDeployment

func (c *Client) ScaleDeployment(namespace, name string, replicas int32) (*appsv1.Deployment, error)

ScaleDeployment scales a Deployment object.

func (*Client) SetClientset

func (c *Client) SetClientset(clientset *kubernetes.Clientset)

SetClientset will set the clientset attribute of the Client object.

func (*Client) SetConfig

func (c *Client) SetConfig(config *rest.Config)

SetConfig will set the config attribute of the Client object.

func (*Client) SetGardenClientset

func (c *Client) SetGardenClientset(client *gardenclientset.Clientset)

SetGardenClientset will set the gardenClientset attribute of the Client object.

func (*Client) SetMachineClientset

func (c *Client) SetMachineClientset(client *machineclientset.Clientset)

SetMachineClientset will set the machineClientset attribute of the Client object.

func (*Client) SetRESTClient

func (c *Client) SetRESTClient(client rest.Interface)

SetRESTClient will set the restClient attribute of the Client object.

func (*Client) SetResourceAPIGroup

func (c *Client) SetResourceAPIGroup(group string, path []string)

SetResourceAPIGroup sets the specified resource API group path.

func (*Client) SetResourceAPIGroups

func (c *Client) SetResourceAPIGroups(groups map[string][]string)

SetResourceAPIGroups set the resourceAPIGroups attribute of the Client object.

func (*Client) StrategicMergePatchDeployment

func (c *Client) StrategicMergePatchDeployment(oldObj, newObj *appsv1.Deployment) (*appsv1.Deployment, error)

StrategicMergePatchDeployment performs a strategic merge patch on a Deployment object.

func (*Client) UpdateConfigMap

func (c *Client) UpdateConfigMap(namespace, name string, data map[string]string) (*corev1.ConfigMap, error)

UpdateConfigMap updates an already existing ConfigMap object.

func (*Client) UpdateNamespace

func (c *Client) UpdateNamespace(namespace *corev1.Namespace) (*corev1.Namespace, error)

UpdateNamespace updates an already existing Namespace object.

func (*Client) UpdateSecret

func (c *Client) UpdateSecret(namespace, name string, secretType corev1.SecretType, data map[string][]byte) (*corev1.Secret, error)

UpdateSecret updates an already existing Secret object.

func (*Client) UpdateSecretObject

func (c *Client) UpdateSecretObject(secret *corev1.Secret) (*corev1.Secret, error)

UpdateSecretObject updates an already existing Secret object.

func (*Client) Version

func (c *Client) Version() string

Version returns the GitVersion of the Kubernetes client stored on the object.

Jump to

Keyboard shortcuts

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