Version: v1.3.1 Latest Latest

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

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 36 Imported by: 0




View Source
const DspNamespaceEnv = "DSP_NAMESPACE"
View Source
const DspPodEnv = "DSP_POD"


View Source
var NoKubernetesConfigFile = errors.New("NoKubernetesConfigFile")

NoKubernetesConfig is the error returned by GetKubernetesAPI when no Kubernetes Config file was found or the file does not exist.


func DeserializeFromKubeYaml

func DeserializeFromKubeYaml(data []byte) (object runtime.Object, err error)

func SerializeToKubeYaml

func SerializeToKubeYaml(target runtime.Object, writer io.Writer) (err error)

func SetKubernetesAPI added in v1.1.0

func SetKubernetesAPI(clientSet kubernetes.Interface, netClient netclient.K8sCniCncfIoV1Interface, config *rest.Config)


type ExecOptions

type ExecOptions struct {
	Command []string

	Namespace     string
	PodName       string
	ContainerName string

	Stdin         io.Reader
	CaptureStdout bool
	CaptureStderr bool
	// If false, whitespace in std{err,out} will be removed.
	PreserveWhitespace bool

ExecOptions passed to ExecWithOptions

type KubernetesAPI

type KubernetesAPI struct {
	// mutex is used to sync  some k8s operations that are slow to accomplish (e.g. deployment or undeployment) and is
	// used by provisioner or maybe other frontends
	// contains filtered or unexported fields

func Fake added in v1.1.1

func Fake() *KubernetesAPI

func GetKubernetesAPI

func GetKubernetesAPI(config KubernetesApiConfig) (*KubernetesAPI, error)

Creates new KubernetesAPI object from in-cluster or out-of-cluster configuration based on config.Current.InCluster setting. Use out-of-cluster method on local machine and in-cluster method on pod running in kubernetes. kubectl command must be installed and properly configured on your machine if using out-of-cluster method.

func (*KubernetesAPI) ConfigMapExists

func (k *KubernetesAPI) ConfigMapExists(namespace string, configMap string) bool

func (*KubernetesAPI) ContainsServiceAccount

func (k *KubernetesAPI) ContainsServiceAccount(a v1.ServiceAccountList, x string) bool

func (*KubernetesAPI) CopyConfigMap

func (k *KubernetesAPI) CopyConfigMap(sourceNamespace string, targetNamespace string, sourceConfigMap string, targetConfigMap string) error

func (*KubernetesAPI) CopyDockerSecrets

func (k *KubernetesAPI) CopyDockerSecrets(sourceNamespace string, targetNamespace string) error

func (*KubernetesAPI) CreateConfigMap

func (k *KubernetesAPI) CreateConfigMap(configMap *v1.ConfigMap) (*v1.ConfigMap, error)

func (*KubernetesAPI) CreateCronJob

func (k *KubernetesAPI) CreateCronJob(job *v1beta1.CronJob) (*v1beta1.CronJob, error)

func (*KubernetesAPI) CreateDeployment

func (k *KubernetesAPI) CreateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error)

func (*KubernetesAPI) CreateIngress

func (k *KubernetesAPI) CreateIngress(ingress *v1beta1.Ingress) (*v1beta1.Ingress, error)

func (*KubernetesAPI) CreateJob

func (k *KubernetesAPI) CreateJob(job *v1.Job) (*v1.Job, error)

func (*KubernetesAPI) CreateNamespace

func (k *KubernetesAPI) CreateNamespace(namespace string) error

func (*KubernetesAPI) CreateNetworkAttachmentDefinition added in v1.1.2

func (k *KubernetesAPI) CreateNetworkAttachmentDefinition(nad *nettypes.NetworkAttachmentDefinition) (*nettypes.NetworkAttachmentDefinition, error)

func (*KubernetesAPI) CreateOrResizePersistentVolumeClaim

func (k *KubernetesAPI) CreateOrResizePersistentVolumeClaim(pv *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)

func (*KubernetesAPI) CreateOrUpdateConfigMap

func (k *KubernetesAPI) CreateOrUpdateConfigMap(configMap *v1.ConfigMap) (*v1.ConfigMap, error)

func (*KubernetesAPI) CreateOrUpdateDeployment

func (k *KubernetesAPI) CreateOrUpdateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error)

func (*KubernetesAPI) CreateOrUpdateIngress

func (k *KubernetesAPI) CreateOrUpdateIngress(ingress *v1beta1.Ingress) (*v1beta1.Ingress, error)

func (*KubernetesAPI) CreateOrUpdateNetworkAttachmentDefinition added in v1.1.1

func (k *KubernetesAPI) CreateOrUpdateNetworkAttachmentDefinition(nad *nettypes.NetworkAttachmentDefinition) (*nettypes.NetworkAttachmentDefinition, error)

func (*KubernetesAPI) CreateOrUpdatePersistentVolume added in v1.1.0

func (k *KubernetesAPI) CreateOrUpdatePersistentVolume(pv *v1.PersistentVolume) (*v1.PersistentVolume, error)

func (*KubernetesAPI) CreateOrUpdatePersistentVolumeClaim

func (k *KubernetesAPI) CreateOrUpdatePersistentVolumeClaim(pv *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)

func (*KubernetesAPI) CreateOrUpdateRole

func (k *KubernetesAPI) CreateOrUpdateRole(
	sourceNamespace string, targetNamespace string, roleName string) error

func (*KubernetesAPI) CreateOrUpdateRoleBinding

func (k *KubernetesAPI) CreateOrUpdateRoleBinding(roleBindingName string, roleName string, serviceAccountName string, namespace string) error

func (*KubernetesAPI) CreateOrUpdateSecret

func (k *KubernetesAPI) CreateOrUpdateSecret(secret *v1.Secret, namespace string) error

func (*KubernetesAPI) CreateOrUpdateService

func (k *KubernetesAPI) CreateOrUpdateService(service *v1.Service) (*v1.Service, error)

func (*KubernetesAPI) CreatePersistentVolume added in v1.1.0

func (k *KubernetesAPI) CreatePersistentVolume(pv *v1.PersistentVolume) (*v1.PersistentVolume, error)

func (*KubernetesAPI) CreatePersistentVolumeClaim

func (k *KubernetesAPI) CreatePersistentVolumeClaim(pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)

func (*KubernetesAPI) CreateRoleBinding

func (k *KubernetesAPI) CreateRoleBinding(roleBindingName string, roleName string, serviceAccountName string, namespace string) error

func (*KubernetesAPI) CreateService

func (k *KubernetesAPI) CreateService(service *v1.Service) (*v1.Service, error)

func (*KubernetesAPI) CreateServiceAccount

func (k *KubernetesAPI) CreateServiceAccount(serviceAccountName string, namespace string) error

func (*KubernetesAPI) CronJobExists

func (k *KubernetesAPI) CronJobExists(namespace string, cronJob string) bool

func (*KubernetesAPI) DeleteConfigMap

func (k *KubernetesAPI) DeleteConfigMap(namespace string, configMap string) error

func (*KubernetesAPI) DeleteCronJob

func (k *KubernetesAPI) DeleteCronJob(namespace string, cronJob string) error

func (*KubernetesAPI) DeleteDeployment

func (k *KubernetesAPI) DeleteDeployment(namespace string, deployment string) error

func (*KubernetesAPI) DeleteIngress

func (k *KubernetesAPI) DeleteIngress(namespace string, ingress string) error

func (*KubernetesAPI) DeleteJob

func (k *KubernetesAPI) DeleteJob(namespace string, job string) error

func (*KubernetesAPI) DeleteNamespace

func (k *KubernetesAPI) DeleteNamespace(namespace string, gracefully bool) error

Function deletes namespace either gracefully (namespace will only be deleted, if it is empty) if gracefully flag is set or forcibly (namespace and all remaining elements will be forcibly deleted) if gracefully flag is not set

func (*KubernetesAPI) DeleteNetworkAttachmentDefinition added in v1.1.1

func (k *KubernetesAPI) DeleteNetworkAttachmentDefinition(namespace string, name string) error

func (*KubernetesAPI) DeletePersistentVolume added in v1.1.0

func (k *KubernetesAPI) DeletePersistentVolume(pv string) error

func (*KubernetesAPI) DeletePersistentVolumeClaim

func (k *KubernetesAPI) DeletePersistentVolumeClaim(namespace string, pvc string) error

func (*KubernetesAPI) DeletePod added in v1.1.1

func (k *KubernetesAPI) DeletePod(namespace string, pod string) error

func (*KubernetesAPI) DeleteSecret added in v1.1.1

func (k *KubernetesAPI) DeleteSecret(namespace string, secret string) error

func (*KubernetesAPI) DeleteService

func (k *KubernetesAPI) DeleteService(namespace string, service string) error

func (*KubernetesAPI) DeploymentExists

func (k *KubernetesAPI) DeploymentExists(namespace string, deployment string) bool

func (*KubernetesAPI) DockerSecretNames

func (k *KubernetesAPI) DockerSecretNames(namespace string) ([]string, error)

func (*KubernetesAPI) EnsureNamespace

func (k *KubernetesAPI) EnsureNamespace(namespaceName string) error

In some cases a namespace can be existent but also in state terminated

func (*KubernetesAPI) ExecCommandInContainer

func (k *KubernetesAPI) ExecCommandInContainer(namespace, podName, containerName string, cmd ...string) (string, error)

ExecCommandInContainer executes a command in the specified container.

func (*KubernetesAPI) ExecCommandInContainerWithFullOutput

func (k *KubernetesAPI) ExecCommandInContainerWithFullOutput(namespace, podName, containerName string, cmd ...string) (string, string, error)

ExecCommandInContainerWithFullOutput executes a command in the specified container and return stdout, stderr and error

func (*KubernetesAPI) ExecCommandInPod

func (k *KubernetesAPI) ExecCommandInPod(namespace string, podName string, cmd ...string) (string, error)

func (*KubernetesAPI) ExecCommandInPodWithFullOutput

func (k *KubernetesAPI) ExecCommandInPodWithFullOutput(namespace string, podName string, cmd ...string) (string, string, error)

func (*KubernetesAPI) ExecShellInContainer

func (k *KubernetesAPI) ExecShellInContainer(namespace, podName, containerName string, cmd string) (string, error)

func (*KubernetesAPI) ExecShellInPod

func (k *KubernetesAPI) ExecShellInPod(podName string, cmd string) (string, error)

func (*KubernetesAPI) ExecShellInPodWithFullOutput

func (k *KubernetesAPI) ExecShellInPodWithFullOutput(podName string, cmd string) (string, string, error)

func (*KubernetesAPI) ExecWithOptions

func (k *KubernetesAPI) ExecWithOptions(options ExecOptions) (string, string, error)

ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.

func (*KubernetesAPI) GetConfigMap

func (k *KubernetesAPI) GetConfigMap(namespace string, configMap string) (*v1.ConfigMap, error)

func (*KubernetesAPI) GetConfigMaps

func (k *KubernetesAPI) GetConfigMaps(namespace string) (*v1.ConfigMapList, error)

func (*KubernetesAPI) GetCronJob

func (k *KubernetesAPI) GetCronJob(namespace string, cronJob string) (*v1beta1.CronJob, error)

func (*KubernetesAPI) GetCurrentPod

func (k *KubernetesAPI) GetCurrentPod() (*v1Api.Pod, error)

func (*KubernetesAPI) GetDeployment

func (k *KubernetesAPI) GetDeployment(namespace string, deployment string) (*appsv1.Deployment, error)

func (*KubernetesAPI) GetIngress

func (k *KubernetesAPI) GetIngress(namespace string, ingress string) (*v1beta1.Ingress, error)

func (*KubernetesAPI) GetJob

func (k *KubernetesAPI) GetJob(namespace string, job string) (*v1.Job, error)

func (*KubernetesAPI) GetNamespace

func (k *KubernetesAPI) GetNamespace(namespace string) (*v1.Namespace, error)

func (*KubernetesAPI) GetNamespaces added in v1.1.0

func (k *KubernetesAPI) GetNamespaces(opts metav1.ListOptions) (*v1.NamespaceList, error)

func (*KubernetesAPI) GetNetworkAttachmentDefinition added in v1.1.1

func (k *KubernetesAPI) GetNetworkAttachmentDefinition(namespace string, networkAttachmentName string) (*nettypes.NetworkAttachmentDefinition, error)

func (*KubernetesAPI) GetNetworkAttachmentDefinitions added in v1.1.1

func (k *KubernetesAPI) GetNetworkAttachmentDefinitions(namespace string) (*nettypes.NetworkAttachmentDefinitionList, error)

func (*KubernetesAPI) GetPersistentVolume added in v1.1.0

func (k *KubernetesAPI) GetPersistentVolume(pv string) (*v1.PersistentVolume, error)

func (*KubernetesAPI) GetPersistentVolumeClaim

func (k *KubernetesAPI) GetPersistentVolumeClaim(namespace string, pvc string) (*v1.PersistentVolumeClaim, error)

func (*KubernetesAPI) GetPersistentVolumeClaims added in v1.1.0

func (k *KubernetesAPI) GetPersistentVolumeClaims(namespace string, opts metav1.ListOptions) (*v1.PersistentVolumeClaimList, error)

func (*KubernetesAPI) GetPersistentVolumes added in v1.1.0

func (k *KubernetesAPI) GetPersistentVolumes(opts metav1.ListOptions) (*v1.PersistentVolumeList, error)

func (*KubernetesAPI) GetPod

func (k *KubernetesAPI) GetPod(namespace string, podName string) (*v1Api.Pod, error)

func (*KubernetesAPI) GetPods

func (k *KubernetesAPI) GetPods(namespace string) (*v1Api.PodList, error)

func (*KubernetesAPI) GetPodsWithOptions added in v1.1.0

func (k *KubernetesAPI) GetPodsWithOptions(namespace string, opts v1Machinery.ListOptions) (*v1Api.PodList, error)

func (*KubernetesAPI) GetRoleBindings

func (k *KubernetesAPI) GetRoleBindings(namespace string) (*v1.RoleBindingList, error)

func (*KubernetesAPI) GetRoles

func (k *KubernetesAPI) GetRoles(namespace string) (*v1.RoleList, error)

func (*KubernetesAPI) GetSecret added in v1.1.0

func (k *KubernetesAPI) GetSecret(namespace string, secret string) (*v1.Secret, error)

func (*KubernetesAPI) GetSecrets

func (k *KubernetesAPI) GetSecrets(namespace string) (*v1.SecretList, error)

func (*KubernetesAPI) GetService

func (k *KubernetesAPI) GetService(namespace string, service string) (*v1.Service, error)

func (*KubernetesAPI) GetServiceAccounts

func (k *KubernetesAPI) GetServiceAccounts(namespace string) (*v1.ServiceAccountList, error)

func (*KubernetesAPI) IngressExists

func (k *KubernetesAPI) IngressExists(namespace string, ingress string) bool

func (*KubernetesAPI) IsNamespaceEmpty

func (k *KubernetesAPI) IsNamespaceEmpty(namespace string) (bool, error)

func (*KubernetesAPI) IsReachable added in v1.1.2

func (k *KubernetesAPI) IsReachable() (bool, error)

func (*KubernetesAPI) JobExists

func (k *KubernetesAPI) JobExists(namespace string, job string) bool

func (*KubernetesAPI) NamespaceExists

func (k *KubernetesAPI) NamespaceExists(namespace string) bool

func (*KubernetesAPI) NetworkAttachmentDefinitionExists added in v1.1.1

func (k *KubernetesAPI) NetworkAttachmentDefinitionExists(namespace string, networkAttachmentName string) bool

func (*KubernetesAPI) PersistentVolumeClaimExists

func (k *KubernetesAPI) PersistentVolumeClaimExists(namespace string, pvc string) bool

func (*KubernetesAPI) PersistentVolumeExists added in v1.1.0

func (k *KubernetesAPI) PersistentVolumeExists(pv string) bool

func (*KubernetesAPI) PodExists added in v1.1.1

func (k *KubernetesAPI) PodExists(namespace string, pod string) bool

func (*KubernetesAPI) ResizePersistentVolumeClaim

func (k *KubernetesAPI) ResizePersistentVolumeClaim(pvc *v1.PersistentVolumeClaim, newQuantity resource.Quantity) (*v1.PersistentVolumeClaim, error)

func (*KubernetesAPI) RoleBindingExists

func (k *KubernetesAPI) RoleBindingExists(namespace string, roleBindingName string) bool

func (*KubernetesAPI) SecretExists

func (k *KubernetesAPI) SecretExists(namespace string, secret string) bool

func (*KubernetesAPI) UpdateConfigMap

func (k *KubernetesAPI) UpdateConfigMap(configMap *v1.ConfigMap) (*v1.ConfigMap, error)

func (*KubernetesAPI) UpdateDeployment

func (k *KubernetesAPI) UpdateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error)

func (*KubernetesAPI) UpdateIngress

func (k *KubernetesAPI) UpdateIngress(ingress *v1beta1.Ingress) (*v1beta1.Ingress, error)

func (*KubernetesAPI) UpdateNamespace added in v1.1.0

func (k *KubernetesAPI) UpdateNamespace(namespace *v1.Namespace) (*v1.Namespace, error)

func (*KubernetesAPI) UpdateNetworkAttachmentDefinition added in v1.1.2

func (k *KubernetesAPI) UpdateNetworkAttachmentDefinition(nad *nettypes.NetworkAttachmentDefinition) (*nettypes.NetworkAttachmentDefinition, error)

CRD network attachment definition can not be updated when object meta resource version is empty or filled nad should be deleted before re-creation

func (*KubernetesAPI) UpdatePersistentVolume added in v1.1.0

func (k *KubernetesAPI) UpdatePersistentVolume(pv *v1.PersistentVolume) (*v1.PersistentVolume, error)

func (*KubernetesAPI) UpdatePersistentVolumeClaim

func (k *KubernetesAPI) UpdatePersistentVolumeClaim(pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)

func (*KubernetesAPI) UpdateRoleBinding

func (k *KubernetesAPI) UpdateRoleBinding(roleBindingName string, roleName string, serviceAccountName string, namespace string) error

func (*KubernetesAPI) UpdateService

func (k *KubernetesAPI) UpdateService(service *v1.Service) (*v1.Service, error)

func (*KubernetesAPI) WatchPods added in v1.1.0

func (k *KubernetesAPI) WatchPods(namespace string, opts *v1Machinery.ListOptions) (watch.Interface, error)

type KubernetesApiConfig

type KubernetesApiConfig interface {

	//gets the path to an explicit kubernetes client config file
	//if nil is returned it is assumed to be running within a kubernetes cluster AND local the service-account is used
	//if "" is returned it defaults to ~/.kube/config
	//any other value is assumed to be a valid path to a kubernetes config file
	KubernetesConfigFilePath() *string
	ClientContentType() string

type PodReference

type PodReference struct {
	Namespace string `json:"namespace"`
	Pod       string `json:"pod"`

func GetCurrentPodReference

func GetCurrentPodReference() (*PodReference, error)

type PvcResizingError added in v1.3.1

type PvcResizingError struct {
	Err error

func (*PvcResizingError) Error added in v1.3.1

func (re *PvcResizingError) Error() string

Jump to

Keyboard shortcuts

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