kubernetesbase

package
v0.0.0-...-133fb1b Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: Apache-2.0 Imports: 26 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 struct {
	Config          *rest.Config
	ClientConfig    clientcmd.ClientConfig
	Clientset       *kubernetes.Clientset
	GardenClientset *gardenclientset.Clientset
	RESTClient      rest.Interface
	// 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 New

func New(config *rest.Config, clientset *kubernetes.Clientset, clientConfig clientcmd.ClientConfig) (*Client, error)

New returns a new Kubernetes base client.

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) Bootstrap

func (c *Client) Bootstrap() error

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

func (*Client) BuildPath

func (c *Client) BuildPath(apiVersion, kind, namespace string) (string, error)

BuildPath creates the Kubernetes API REST URL for the given API group and kind (depending on whether the kind is namespaced or not).

func (*Client) CheckCRDCleanup

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

CheckCRDCleanup will check whether all the CRDs in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckDaemonSetCleanup

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

CheckDaemonSetCleanup will check whether all the DaemonSets in the Shoot cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckDeploymentCleanup

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

CheckDeploymentCleanup will check whether all the Deployments in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

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) CheckJobCleanup

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

CheckJobCleanup will check whether all the Jobs in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckNamespaceCleanup

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

CheckNamespaceCleanup will check whether all the Namespaces in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckPersistentVolumeClaimCleanup

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

CheckPersistentVolumeClaimCleanup will check whether all the PersistentVolumeClaims in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckPodCleanup

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

CheckPodCleanup will check whether all the Pods in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckReplicaSetCleanup

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

CheckReplicaSetCleanup will check whether all the ReplicaSets in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckReplicationControllerCleanup

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

CheckReplicationControllerCleanup will check whether all the ReplicationControllers in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckResourceCleanup

func (c *Client) CheckResourceCleanup(exceptions map[string]bool, scoped bool, absPath ...string) (bool, error)

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

func (*Client) CheckServiceCleanup

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

CheckServiceCleanup will check whether all the Services in the cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CheckStatefulSetCleanup

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

CheckStatefulSetCleanup will check whether all the StatefulSets in the Shoot cluster other than those stored in the exceptions map <exceptions> have been deleted. It will return an error in case it has not finished yet, and nil if all resources are gone.

func (*Client) CleanupCRDs

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

CleanupCRDs deletes all the TPRs/CRDs in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupDaemonSets

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

CleanupDaemonSets deletes all the DaemonSets in the Shoot cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupDeployments

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

CleanupDeployments deletes all the Deployments in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupJobs

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

CleanupJobs deletes all the Jobs in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupNamespaces

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

CleanupNamespaces deletes all the Namespaces in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupPersistentVolumeClaims

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

CleanupPersistentVolumeClaims deletes all the PersistentVolumeClaims in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupPods

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

CleanupPods deletes all the Pods in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupReplicaSets

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

CleanupReplicaSets deletes all the ReplicaSets in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupReplicationControllers

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

CleanupReplicationControllers deletes all the ReplicationControllers in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupResource

func (c *Client) CleanupResource(exceptions map[string]bool, scoped bool, absPath ...string) error

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

func (*Client) CleanupServices

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

CleanupServices deletes all the Services in the cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CleanupStatefulSets

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

CleanupStatefulSets deletes all the StatefulSets in the Shoot cluster other than those stored in the exceptions map <exceptions>.

func (*Client) CreateNamespace

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

CreateNamespace creates a new Namespace object.

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) CreateShoot

func (c *Client) CreateShoot(shoot *gardenv1beta1.Shoot) (*gardenv1beta1.Shoot, error)

CreateShoot creates a new Shoot resource.

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) 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) 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) DeleteShoot

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

DeleteShoot deletes an existing Shoot resource.

func (*Client) DeleteStatefulSet

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

DeleteStatefulSet deletes a StatefulSet object.

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) GetAPIResourceList

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

GetAPIResourceList will return the Kubernetes API resource list.

func (*Client) GetCRD

func (c *Client) GetCRD(name string) (*mapping.CustomResourceDefinition, error)

GetCRD returns a CustomResourceDefinition object. For the sake of simplicity, we do not use the APIExtensions client.

func (*Client) GetClientset

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

GetClientset will return the Clientset attribute of the Client object.

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) (*mapping.Deployment, error)

GetDeployment returns a Deployment object.

func (*Client) GetGardenClientset

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

GetGardenClientset will return the GardenClientset attribute of the Client 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) GetRESTClient

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

GetRESTClient will return the RESTClient 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) GetServiceAccount

func (c *Client) GetServiceAccount(namespace, name string) (*corev1.ServiceAccount, error)

GetServiceAccount returns a ServiceAccount object.

func (*Client) GetShoot

func (c *Client) GetShoot(namespace, name string) (*gardenv1beta1.Shoot, error)

GetShoot returns a Shoot resource.

func (*Client) ListDeployments

func (c *Client) ListDeployments(namespace string, listOptions metav1.ListOptions) ([]*mapping.Deployment, 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) ([]*mapping.ReplicaSet, error)

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

func (*Client) ListResources

func (c *Client) ListResources(scoped bool, absPath []string) ([]byte, 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) ([]*mapping.RoleBinding, 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) ListShoots

func (c *Client) ListShoots(namespace string) (*gardenv1beta1.ShootList, error)

ListShoots returns a list of shoot resources in a given <namespace>.

func (*Client) PatchServiceAccount

func (c *Client) PatchServiceAccount(namespace, name string, data []byte) (*corev1.ServiceAccount, error)

PatchServiceAccount returns the desired Service object.

func (*Client) PatchShoot

func (c *Client) PatchShoot(shoot *gardenv1beta1.Shoot, body []byte) (*gardenv1beta1.Shoot, error)

PatchShoot patches an existing Shoot resource.

func (*Client) QueryVersion

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

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

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) SetRESTClient

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

SetRESTClient will set the RESTClient attribute of the Client object.

func (*Client) UpdateNamespace

func (c *Client) UpdateNamespace(name string) (*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) UpdateShoot

func (c *Client) UpdateShoot(shoot *gardenv1beta1.Shoot) (*gardenv1beta1.Shoot, error)

UpdateShoot update an existing Shoot resource.

func (*Client) UpdateShootStatus

func (c *Client) UpdateShootStatus(shoot *gardenv1beta1.Shoot) (*gardenv1beta1.Shoot, error)

UpdateShootStatus update an existing Shoot resource's status.

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