kclient

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 24 Imported by: 56

Documentation

Index

Constants

View Source
const (
	DeploymentKind       = "Deployment"
	DeploymentAPIVersion = "apps/v1"
)

constants for deployments

View Source
const (
	PersistentVolumeClaimKind       = "PersistentVolumeClaim"
	PersistentVolumeClaimAPIVersion = "v1"
)

constants for volumes

Variables

This section is empty.

Functions

func AddPVCAndVolumeMount added in v1.1.1

func AddPVCAndVolumeMount(podTemplateSpec *corev1.PodTemplateSpec, volumeNameToPVCName map[string]string, componentAliasToVolumes map[string][]common.DevfileVolume) error

AddPVCAndVolumeMount adds PVC and volume mount to the pod template spec volumeNameToPVCName is a map of volume name to the PVC created componentAliasToVolumes is a map of the Devfile component alias to the Devfile Volumes

func AddPVCToPodTemplateSpec added in v1.1.1

func AddPVCToPodTemplateSpec(podTemplateSpec *corev1.PodTemplateSpec, volumeName, pvcName string)

AddPVCToPodTemplateSpec adds the given PVC to the podTemplateSpec

func AddVolumeMountToPodTemplateSpec added in v1.1.1

func AddVolumeMountToPodTemplateSpec(podTemplateSpec *corev1.PodTemplateSpec, volumeName string, componentAliasToMountPaths map[string][]string) error

AddVolumeMountToPodTemplateSpec adds the Volume Mounts in componentAliasToMountPaths to the podTemplateSpec containers for a given pvc and volumeName componentAliasToMountPaths is a map of a container alias to an array of its Mount Paths

func CreateObjectMeta added in v1.1.1

func CreateObjectMeta(name, namespace string, labels, annotations map[string]string) metav1.ObjectMeta

CreateObjectMeta creates a common object meta

func FakeNew

func FakeNew() (*Client, *FakeClientset)

FakeNew creates new fake client for testing returns Client that is filled with fake clients and FakeClientSet that holds fake Clientsets to access Actions, Reactors etc... in fake client

func FakePodStatus added in v1.1.1

func FakePodStatus(status corev1.PodPhase, podName string) *corev1.Pod

FakePodStatus returns a pod with the status

func GenerateContainer added in v1.1.1

func GenerateContainer(name, image string, isPrivileged bool, command, args []string, envVars []corev1.EnvVar, resourceReqs corev1.ResourceRequirements) *corev1.Container

GenerateContainer creates a container spec that can be used when creating a pod

func GenerateDeploymentSpec added in v1.1.1

func GenerateDeploymentSpec(podTemplateSpec corev1.PodTemplateSpec) *appsv1.DeploymentSpec

GenerateDeploymentSpec creates a deployment spec

func GenerateIngressSpec added in v1.1.1

func GenerateIngressSpec(ingressParam IngressParameter) *extensionsv1.IngressSpec

GenerateIngressSpec creates an ingress spec

func GenerateOwnerReference added in v1.1.1

func GenerateOwnerReference(deployment *appsv1.Deployment) metav1.OwnerReference

GenerateOwnerReference genertes an ownerReference from the deployment which can then be set as owner for various Kubernetes objects and ensure that when the owner object is deleted from the cluster, all other objects are automatically removed by Kubernetes garbage collector

func GeneratePVCSpec added in v1.1.1

func GeneratePVCSpec(quantity resource.Quantity) *corev1.PersistentVolumeClaimSpec

GeneratePVCSpec creates a pvc spec

func GeneratePodTemplateSpec added in v1.1.1

func GeneratePodTemplateSpec(objectMeta metav1.ObjectMeta, containers []corev1.Container) *corev1.PodTemplateSpec

GeneratePodTemplateSpec creates a pod template spec that can be used to create a deployment spec

Types

type Client

type Client struct {
	KubeClient       kubernetes.Interface
	KubeConfig       clientcmd.ClientConfig
	KubeClientConfig *rest.Config
	Namespace        string
	OperatorClient   *operatorsclientset.OperatorsV1alpha1Client
}

Client is a collection of fields used for client configuration and interaction

func New

func New() (*Client, error)

New creates a new client

func (*Client) CreateDeployment added in v1.1.1

func (c *Client) CreateDeployment(deploymentSpec appsv1.DeploymentSpec) (*appsv1.Deployment, error)

CreateDeployment creates a deployment based on the given deployment spec

func (*Client) CreateIngress added in v1.1.1

func (c *Client) CreateIngress(objectMeta metav1.ObjectMeta, spec extensionsv1.IngressSpec) (*extensionsv1.Ingress, error)

CreateIngress creates an ingress object for the given service and with the given labels

func (*Client) CreatePVC added in v1.1.1

CreatePVC creates a PVC resource in the cluster with the given name, size and labels

func (*Client) CreateTLSSecret added in v1.1.1

func (c *Client) CreateTLSSecret(tlsCertificate []byte, tlsPrivKey []byte, componentName string, applicationName string, portNumber int) (*corev1.Secret, error)

CreateTLSSecret creates a TLS Secret with the given certificate and private key serviceName is the name of the service for the target reference ingressDomain is the ingress domain to use for the ingress portNumber is the target port of the ingress

func (*Client) DeleteIngress added in v1.1.1

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

DeleteIngress deletes the given ingress

func (*Client) ExecCMDInContainer

func (c *Client) ExecCMDInContainer(podName, containerName string, cmd []string, stdout io.Writer, stderr io.Writer, stdin io.Reader, tty bool) error

ExecCMDInContainer execute command in the container of a pod, pass an empty string for containerName to execute in the first container of the pod

func (*Client) GetClusterServiceVersionList added in v1.1.1

func (c *Client) GetClusterServiceVersionList() (*olm.ClusterServiceVersionList, error)

GetClusterServiceVersionList returns a list of CSVs in the cluster It is equivalent to doing `oc get csvs` using oc cli

func (*Client) GetDeploymentByName added in v1.1.1

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

GetDeploymentByName gets a deployment by querying by name

func (*Client) GetPVCsFromSelector added in v1.1.1

func (c *Client) GetPVCsFromSelector(selector string) ([]corev1.PersistentVolumeClaim, error)

GetPVCsFromSelector returns the PVCs based on the given selector

func (*Client) ListIngressNames added in v1.1.1

func (c *Client) ListIngressNames(labelSelector string) ([]string, error)

ListIngressNames lists all the names of the ingresses based on the given label selector

func (*Client) ListIngresses added in v1.1.1

func (c *Client) ListIngresses(labelSelector string) ([]extensionsv1.Ingress, error)

ListIngresses lists all the ingresses based on the given label selector

func (*Client) ListSecrets added in v1.1.1

func (c *Client) ListSecrets(labelSelector string) ([]corev1.Secret, error)

ListSecrets lists all the secrets based on the given label selector

func (*Client) UpdateDeployment added in v1.1.1

func (c *Client) UpdateDeployment(deploymentSpec appsv1.DeploymentSpec) (*appsv1.Deployment, error)

UpdateDeployment updates a deployment based on the given deployment spec

func (*Client) WaitAndGetPod

func (c *Client) WaitAndGetPod(watchOptions metav1.ListOptions, desiredPhase corev1.PodPhase, waitMessage string) (*corev1.Pod, error)

WaitAndGetPod block and waits until pod matching selector is in the desired phase desiredPhase cannot be PodFailed or PodUnknown

type FakeClientset

type FakeClientset struct {
	Kubernetes *fakeKubeClientset.Clientset
}

FakeClientset holds fake ClientSets this is returned by FakeNew to access methods of fake client sets

type IngressParameter added in v1.1.1

type IngressParameter struct {
	ServiceName   string
	IngressDomain string
	PortNumber    intstr.IntOrString
	TLSSecretName string
}

IngressParameter struct for function createIngress serviceName is the name of the service for the target reference ingressDomain is the ingress domain to use for the ingress portNumber is the target port of the ingress TLSSecretName is the target TLS Secret name of the ingress

Jump to

Keyboard shortcuts

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