kubernetes

package
v0.0.0-...-44ba42e Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 52 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"

	// PersistentVolumes is a constant for a Kubernetes resource with the same name.
	PersistentVolumes = "persistentvolumes"

	// 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"
)
View Source
const KubeConfig = "kubeconfig"

KubeConfig is the key to the kubeconfig

Variables

View Source
var (
	// GardenScheme is the scheme used in the Garden cluster.
	GardenScheme = runtime.NewScheme()
	// SeedScheme is the scheme used in the Seed cluster.
	SeedScheme = runtime.NewScheme()
	// ShootScheme is the scheme used in the Shoot cluster.
	ShootScheme = runtime.NewScheme()
	// PlantScheme is the scheme used in the Plant cluster
	PlantScheme = runtime.NewScheme()

	// DefaultDeleteOptionFuncs use foreground propagation policy and grace period of 60 seconds.
	DefaultDeleteOptionFuncs = []client.DeleteOptionFunc{
		client.PropagationPolicy(metav1.DeletePropagationForeground),
		client.GracePeriodSeconds(60),
	}
)
View Source
var DefaultApplierOptions = ApplierOptions{
	MergeFuncs: map[schema.GroupKind]MergeFunc{
		corev1.SchemeGroupVersion.WithKind("Service").GroupKind(): func(newObj, oldObj *unstructured.Unstructured) {

			oldPorts := oldObj.Object["spec"].(map[string]interface{})["ports"].([]interface{})
			newPorts := newObj.Object["spec"].(map[string]interface{})["ports"].([]interface{})
			ports := []map[string]interface{}{}

			for _, newPort := range newPorts {
				np := newPort.(map[string]interface{})

				for _, oldPort := range oldPorts {
					op := oldPort.(map[string]interface{})

					if fmt.Sprintf("%v", np["port"]) == fmt.Sprintf("%v", op["port"]) {
						if nodePort, ok := op["nodePort"]; ok {
							np["nodePort"] = nodePort
						}
					}
				}
				ports = append(ports, np)
			}

			newObj.Object["spec"].(map[string]interface{})["clusterIP"] = oldObj.Object["spec"].(map[string]interface{})["clusterIP"]
			newObj.Object["spec"].(map[string]interface{})["ports"] = ports
		},
		corev1.SchemeGroupVersion.WithKind("ServiceAccount").GroupKind(): func(newObj, oldObj *unstructured.Unstructured) {

			newObj.Object["secrets"] = oldObj.Object["secrets"]
			newObj.Object["imagePullSecrets"] = oldObj.Object["imagePullSecrets"]
		},
	},
}

DefaultApplierOptions contains options for common k8s objects, e.g. Service, ServiceAccount.

View Source
var NewControllerClient = newControllerClient

NewControllerClient instantiates a new client.Client.

Functions

func GetAdmissionPluginsForVersion

func GetAdmissionPluginsForVersion(v string) []gardenv1beta1.AdmissionPlugin

GetAdmissionPluginsForVersion returns the set of default admission plugins for the given Kubernetes version. If the given Kubernetes version does not explicitly define admission plugins the set of names for the next available version will be returned (e.g., for version X not defined the set of version X-1 will be returned).

func GetPodLogs

func GetPodLogs(podInterface corev1client.PodInterface, name string, options *corev1.PodLogOptions) ([]byte, error)

GetPodLogs retrieves the pod logs of the pod of the given name with the given options.

func NewRuntimeClientForConfig

func NewRuntimeClientForConfig(config *rest.Config, opts client.Options) (client.Client, error)

NewRuntimeClientForConfig returns a new controller runtime client from a config.

func NewRuntimeClientFromBytes

func NewRuntimeClientFromBytes(kubeconfig []byte, opts client.Options) (client.Client, error)

NewRuntimeClientFromBytes creates a new controller runtime Client struct for a given kubeconfig byte slice.

func NewRuntimeClientFromSecret

func NewRuntimeClientFromSecret(secret *corev1.Secret, opts client.Options) (client.Client, error)

NewRuntimeClientFromSecret creates a new controller runtime Client struct for a given secret.

func ScaleDeployment

func ScaleDeployment(ctx context.Context, c client.Client, key client.ObjectKey, replicas int32) error

ScaleDeployment scales a Deployment.

func ScaleStatefulSet

func ScaleStatefulSet(ctx context.Context, c client.Client, key client.ObjectKey, replicas int32) error

ScaleStatefulSet scales a StatefulSet.

Types

type Applier

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

Applier is a default implementation of the ApplyInterface. It applies objects with by first checking whether they exist and then either creating / updating them (update happens with a predefined merge logic).

func NewApplierForConfig

func NewApplierForConfig(config *rest.Config) (*Applier, error)

NewApplierForConfig creates and returns a new Applier for the given rest.Config.

func NewApplierInternal

func NewApplierInternal(config *rest.Config, discoveryClient discovery.CachedDiscoveryInterface) (*Applier, error)

NewApplierInternal constructs a new Applier from the given config and DiscoveryInterface. This method should only be used for testing. TODO(AC): Once https://github.com/kubernetes/kubernetes/issues/68865 is resolved, this should be adapted to use the updated RESTMapper (https://github.com/kubernetes/kubernetes/issues/75383) and not do the invalidation / checks on its own (depending on whether the controller-runtime/client might even automatically use this updated mapper then).

func (*Applier) ApplyManifest

func (c *Applier) ApplyManifest(ctx context.Context, r UnstructuredReader, options ApplierOptions) error

ApplyManifest 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 (*Applier) DeleteManifest

func (c *Applier) DeleteManifest(ctx context.Context, r UnstructuredReader) error

DeleteManifest is a function which does the same like `kubectl delete -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 for deletion. It returns an error as soon as the first error occurs.

type ApplierInterface

type ApplierInterface interface {
	ApplyManifest(ctx context.Context, unstructured UnstructuredReader, options ApplierOptions) error
	DeleteManifest(ctx context.Context, unstructured UnstructuredReader) error
}

ApplierInterface is an interface which describes declarative operations to apply multiple Kubernetes objects.

type ApplierOptions

type ApplierOptions struct {
	MergeFuncs map[schema.GroupKind]MergeFunc
}

ApplierOptions contains options used by the Applier.

func CopyApplierOptions

func CopyApplierOptions(in ApplierOptions) ApplierOptions

CopyApplierOptions returns a copies of the provided applier options.

type ChartApplier

type ChartApplier interface {
	chartrenderer.Interface
	ApplierInterface

	ApplyChartWithOptions(ctx context.Context, chartPath, namespace, name string, defaultValues, additionalValues map[string]interface{}, options ApplierOptions) error
	ApplyChart(ctx context.Context, chartPath, namespace, name string, defaultValues, additionalValues map[string]interface{}) error
	ApplyChartInNamespaceWithOptions(ctx context.Context, chartPath, namespace, name string, defaultValues, additionalValues map[string]interface{}, options ApplierOptions) error
	ApplyChartInNamespace(ctx context.Context, chartPath, namespace, name string, defaultValues, additionalValues map[string]interface{}) error

	DeleteChart(ctx context.Context, chartPath, namespace, name string) error
}

ChartApplier is an interface that describes needed methods that render and apply Helm charts in Kubernetes clusters.

func NewChartApplier

func NewChartApplier(renderer chartrenderer.Interface, applier ApplierInterface) ChartApplier

NewChartApplier returns a new chart applier.

func NewChartApplierForConfig

func NewChartApplierForConfig(config *rest.Config) (ChartApplier, error)

NewChartApplierForConfig returns a new chart applier based on the given REST config.

type Clientset

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

Clientset 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 Garden 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 (*Clientset) APIExtension

func (c *Clientset) APIExtension() apiextensionclientset.Interface

APIExtension will return the apiextensionsClientset attribute of the Client object.

func (*Clientset) APIRegistration

func (c *Clientset) APIRegistration() apiregistrationclientset.Interface

APIRegistration will return the apiregistration attribute of the Client object.

func (*Clientset) Applier

func (c *Clientset) Applier() ApplierInterface

Applier returns the applier of this Clientset.

func (*Clientset) CheckForwardPodPort

func (c *Clientset) CheckForwardPodPort(namespace, name string, local, remote int) 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 (*Clientset) Client

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

Client returns the client of this Clientset.

func (*Clientset) CreateConfigMap

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

CreateConfigMap creates a new ConfigMap object.

func (*Clientset) CreateNamespace

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

CreateNamespace creates a new Namespace object.

func (*Clientset) CreateOrPatchRoleBinding

func (c *Clientset) 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 (*Clientset) CreateSecret

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

CreateSecret creates a new Secret object.

func (*Clientset) CreateSecretObject

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

CreateSecretObject creates a new Secret object.

func (*Clientset) DeleteClusterRole

func (c *Clientset) DeleteClusterRole(name string) error

DeleteClusterRole deletes a ClusterRole object.

func (*Clientset) DeleteClusterRoleBinding

func (c *Clientset) DeleteClusterRoleBinding(name string) error

DeleteClusterRoleBinding deletes a ClusterRoleBinding object.

func (*Clientset) DeleteConfigMap

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

DeleteConfigMap deletes a ConfigMap object.

func (*Clientset) DeleteCronJob

func (c *Clientset) DeleteCronJob(namespace, name string) error

DeleteCronJob deletes a CronJob object.

func (*Clientset) DeleteDaemonSet

func (c *Clientset) DeleteDaemonSet(namespace, name string) error

DeleteDaemonSet deletes a DaemonSet object.

func (*Clientset) DeleteDeployment

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

DeleteDeployment deletes a Deployment object.

func (*Clientset) DeleteHorizontalPodAutoscaler

func (c *Clientset) DeleteHorizontalPodAutoscaler(namespace, name string) error

DeleteHorizontalPodAutoscaler deletes a HorizontalPodAutoscaler object.

func (*Clientset) DeleteIngress

func (c *Clientset) DeleteIngress(namespace, name string) error

DeleteIngress deletes an Ingress object.

func (*Clientset) DeleteJob

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

DeleteJob deletes a Job object.

func (*Clientset) DeleteNamespace

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

DeleteNamespace deletes a namespace.

func (*Clientset) DeleteNetworkPolicy

func (c *Clientset) DeleteNetworkPolicy(namespace, name string) error

DeleteNetworkPolicy deletes an NetworkPolicy object.

func (*Clientset) DeletePod

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

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

func (*Clientset) DeletePodForcefully

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

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

func (*Clientset) DeleteReplicaSet

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

DeleteReplicaSet deletes a ReplicaSet object.

func (*Clientset) DeleteRoleBinding

func (c *Clientset) DeleteRoleBinding(namespace, name string) error

DeleteRoleBinding deletes a RoleBindung object.

func (*Clientset) DeleteSecret

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

DeleteSecret deletes an already existing Secret object.

func (*Clientset) DeleteService

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

DeleteService deletes an already existing Service object.

func (*Clientset) DeleteServiceAccount

func (c *Clientset) DeleteServiceAccount(namespace, name string) error

DeleteServiceAccount deletes a ServiceAccount object.

func (*Clientset) DeleteStatefulSet

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

DeleteStatefulSet deletes a StatefulSet object.

func (*Clientset) ForwardPodPort

func (c *Clientset) 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 (*Clientset) Garden

func (c *Clientset) Garden() gardenclientset.Interface

Garden will return the garden attribute of the Client object.

func (*Clientset) GardenCore

func (c *Clientset) GardenCore() gardencoreclientset.Interface

GardenCore will return the gardenCore attribute of the Client object.

func (*Clientset) GetConfigMap

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

GetConfigMap returns a ConfigMap object.

func (*Clientset) GetDeployment

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

GetDeployment returns a Deployment object.

func (*Clientset) GetJob

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

GetJob returns a Job object.

func (*Clientset) GetNamespace

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

GetNamespace returns a Namespace object.

func (*Clientset) GetPod

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

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

func (*Clientset) GetSecret

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

GetSecret returns a Secret object.

func (*Clientset) GetService

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

GetService returns the desired Service object.

func (*Clientset) Kubernetes

func (c *Clientset) Kubernetes() kubernetes.Interface

Kubernetes will return the kubernetes attribute of the Client object.

func (*Clientset) ListDaemonSets

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

ListDaemonSets returns the list of DaemonSets in the given namespace.

func (*Clientset) ListDeployments

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

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

func (*Clientset) ListNamespaces

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

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

func (*Clientset) ListNodes

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

ListNodes returns a list of Nodes.

func (*Clientset) ListPods

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

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

func (*Clientset) ListReplicaSets

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

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

func (*Clientset) ListRoleBindings

func (c *Clientset) 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 (*Clientset) ListSecrets

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

ListSecrets lists all Secrets in a given <namespace>.

func (*Clientset) ListStatefulSets

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

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

func (*Clientset) Machine

func (c *Clientset) Machine() machineclientset.Interface

Machine will return the machine attribute of the Client object.

func (*Clientset) PatchDeployment

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

PatchDeployment patches a Deployment object.

func (*Clientset) PatchNamespace

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

PatchNamespace patches a Namespace object.

func (*Clientset) RESTClient

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

RESTClient will return the restClient attribute of the Client object.

func (*Clientset) RESTConfig

func (c *Clientset) RESTConfig() *rest.Config

RESTConfig will return the config attribute of the Client object.

func (*Clientset) RESTMapper

func (c *Clientset) RESTMapper() meta.RESTMapper

RESTMapper returns the restMapper of this Clientset.

func (*Clientset) UpdateConfigMap

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

UpdateConfigMap updates an already existing ConfigMap object.

func (*Clientset) UpdateNamespace

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

UpdateNamespace updates an already existing Namespace object.

func (*Clientset) UpdateSecret

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

UpdateSecret updates an already existing Secret object.

func (*Clientset) UpdateSecretObject

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

UpdateSecretObject updates an already existing Secret object.

func (*Clientset) Version

func (c *Clientset) Version() string

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

type Interface

type Interface interface {
	RESTConfig() *rest.Config
	RESTMapper() meta.RESTMapper
	RESTClient() rest.Interface

	Client() client.Client
	Applier() ApplierInterface

	Kubernetes() kubernetesclientset.Interface
	Garden() gardenclientset.Interface
	GardenCore() gardencoreclientset.Interface
	Machine() machineclientset.Interface
	APIExtension() apiextensionsclientset.Interface
	APIRegistration() apiregistrationclientset.Interface

	// Namespaces
	// Deprecated: Use `Client()` and utils instead.
	CreateNamespace(*corev1.Namespace, bool) (*corev1.Namespace, error)
	// Deprecated: Use `Client()` and utils instead.
	GetNamespace(string) (*corev1.Namespace, error)
	// Deprecated: Use `Client()` and utils instead.
	ListNamespaces(metav1.ListOptions) (*corev1.NamespaceList, error)
	// Deprecated: Use `Client()` and utils instead.
	PatchNamespace(name string, body []byte) (*corev1.Namespace, error)
	// Deprecated: Use `Client()` and utils instead.
	DeleteNamespace(string) error

	// Secrets
	// Deprecated: Use `Client()` and utils instead.
	CreateSecret(string, string, corev1.SecretType, map[string][]byte, bool) (*corev1.Secret, error)
	// Deprecated: Use `Client()` and utils instead.
	CreateSecretObject(*corev1.Secret, bool) (*corev1.Secret, error)
	// Deprecated: Use `Client()` and utils instead.
	UpdateSecretObject(*corev1.Secret) (*corev1.Secret, error)
	// Deprecated: Use `Client()` and utils instead.
	ListSecrets(string, metav1.ListOptions) (*corev1.SecretList, error)
	// Deprecated: Use `Client()` and utils instead.
	GetSecret(string, string) (*corev1.Secret, error)
	// Deprecated: Use `Client()` and utils instead.
	DeleteSecret(string, string) error

	// ConfigMaps
	// Deprecated: Use `Client()` and utils instead.
	CreateConfigMap(string, string, map[string]string, bool) (*corev1.ConfigMap, error)
	// Deprecated: Use `Client()` and utils instead.
	UpdateConfigMap(string, string, map[string]string) (*corev1.ConfigMap, error)
	// Deprecated: Use `Client()` and utils instead.
	GetConfigMap(string, string) (*corev1.ConfigMap, error)
	// Deprecated: Use `Client()` and utils instead.
	DeleteConfigMap(string, string) error

	// Services
	// Deprecated: Use `Client()` and utils instead.
	GetService(string, string) (*corev1.Service, error)
	// Deprecated: Use `Client()` and utils instead.
	DeleteService(string, string) error

	// Deployments
	// Deprecated: Use `Client()` and utils instead.
	GetDeployment(string, string) (*appsv1.Deployment, error)
	// Deprecated: Use `Client()` and utils instead.
	ListDeployments(string, metav1.ListOptions) (*appsv1.DeploymentList, error)
	// Deprecated: Use `Client()` and utils instead.
	PatchDeployment(string, string, []byte) (*appsv1.Deployment, error)
	// Deprecated: Use `Client()` and utils instead.
	DeleteDeployment(string, string) error

	// StatefulSets
	// Deprecated: Use `Client()` and utils instead.
	ListStatefulSets(string, metav1.ListOptions) (*appsv1.StatefulSetList, error)
	// Deprecated: Use `Client()` and utils instead.
	DeleteStatefulSet(string, string) error

	// DaemonSets
	// Deprecated: Use `Client()` and utils instead.
	DeleteDaemonSet(string, string) error

	// Jobs
	// Deprecated: Use `Client()` and utils instead.
	GetJob(string, string) (*batchv1.Job, error)
	// Deprecated: Use `Client()` and utils instead.
	DeleteJob(string, string) error
	// Deprecated: Use `Client()` and utils instead.
	DeleteCronJob(string, string) error

	// Pods
	// Deprecated: Use `Client()` and utils instead.
	GetPod(string, string) (*corev1.Pod, error)
	// Deprecated: Use `Client()` and utils instead.
	ListPods(string, metav1.ListOptions) (*corev1.PodList, error)

	// Deprecated: Use `Client()` and utils instead.
	ForwardPodPort(string, string, int, int) (chan struct{}, error)
	CheckForwardPodPort(string, string, int, int) error
	// Deprecated: Use `Client()` and utils instead.
	DeletePod(string, string) error
	// Deprecated: Use `Client()` and utils instead.
	DeletePodForcefully(string, string) error

	// Nodes
	// Deprecated: Use `Client()` and utils instead.
	ListNodes(metav1.ListOptions) (*corev1.NodeList, error)

	// RBAC
	// Deprecated: Use `Client()` and utils instead.
	ListRoleBindings(string, metav1.ListOptions) (*rbacv1.RoleBindingList, error)
	// Deprecated: Use `Client()` and utils instead.
	DeleteClusterRole(name string) error
	// Deprecated: Use `Client()` and utils instead.
	DeleteClusterRoleBinding(name string) error
	// Deprecated: Use `Client()` and utils instead.
	DeleteRoleBinding(namespace, name string) error

	// ServiceAccounts
	// Deprecated: Use `Client()` and utils instead.
	DeleteServiceAccount(namespace, name string) error

	// HorizontalPodAutoscalers
	// Deprecated: Use `Client()` and utils instead.
	DeleteHorizontalPodAutoscaler(namespace, name string) error

	// Ingresses
	// Deprecated: Use `Client()` and utils instead.
	DeleteIngress(namespace, name string) error

	// NetworkPolicies
	// Deprecated: Use `Client()` and utils instead.
	DeleteNetworkPolicy(namespace, name string) error

	Version() string
}

Interface 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, opts client.Options) (Interface, error)

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

func NewClientFromFile

func NewClientFromFile(masterURL, kubeconfigPath string, opts client.Options) (Interface, error)

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

func NewClientFromSecret

func NewClientFromSecret(k8sClient Interface, namespace, secretName string, opts client.Options) (Interface, 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, opts client.Options) (Interface, error)

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

func NewForConfig

func NewForConfig(config *rest.Config, options client.Options) (Interface, error)

NewForConfig returns a new Kubernetes base client.

type MergeFunc

type MergeFunc func(newObj, oldObj *unstructured.Unstructured)

MergeFunc determines how oldOj is merged into new oldObj.

type PodExecutor

type PodExecutor interface {
	Execute(ctx context.Context, namespace, name, containerName, command string) (io.Reader, error)
}

PodExecutor is the pod executor interface

func NewPodExecutor

func NewPodExecutor(config *rest.Config) PodExecutor

NewPodExecutor returns a podExecutor

type UnstructuredReader

type UnstructuredReader interface {
	Read() (*unstructured.Unstructured, error)
}

UnstructuredReader an interface that all manifest readers should implement

func NewManifestReader

func NewManifestReader(manifest []byte) UnstructuredReader

NewManifestReader initializes a reader for yaml manifests

func NewNamespaceSettingReader

func NewNamespaceSettingReader(mReader UnstructuredReader, namespace string) UnstructuredReader

NewNamespaceSettingReader initializes a reader for yaml manifests with support for setting the namespace

Jump to

Keyboard shortcuts

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