Documentation ¶
Index ¶
- Constants
- Variables
- func AddLabelsToPodOptionsFromContext(ctx context.Context, options *PodOptions, targetKey string)
- func ConfigNamespace() (string, error)
- func ContainerNameFromPodOptsOrDefault(po *PodOptions) string
- func CreateAndMergeJSONPatch(original, override crv1alpha1.JSONMap) (crv1alpha1.JSONMap, error)
- func CreateConfigMap(ctx context.Context, cli kubernetes.Interface, namespace string, spec string) (*corev1.ConfigMap, error)
- func CreateDeployment(ctx context.Context, cli kubernetes.Interface, namespace string, spec string) (*appsv1.Deployment, error)
- func CreatePod(ctx context.Context, cli kubernetes.Interface, opts *PodOptions) (*corev1.Pod, error)
- func CreateStatefulSet(ctx context.Context, cli kubernetes.Interface, namespace string, spec string) (*appsv1.StatefulSet, error)
- func DeletePod(ctx context.Context, cli kubernetes.Interface, pod *corev1.Pod) error
- func DeploymentConfigPods(ctx context.Context, osCli osversioned.Interface, kubeCli kubernetes.Interface, ...) ([]corev1.Pod, []corev1.Pod, error)
- func DeploymentConfigReady(ctx context.Context, osCli osversioned.Interface, cli kubernetes.Interface, ...) (bool, error)
- func DeploymentConfigReplicas(ctx context.Context, osCli osversioned.Interface, namespace, name string) (int32, error)
- func DeploymentConfigVolumes(osCli osversioned.Interface, depConfig *osAppsv1.DeploymentConfig, ...) (volNameToPvc map[string]string)
- func DeploymentPods(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) ([]corev1.Pod, []corev1.Pod, error)
- func DeploymentReady(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) (bool, string, error)
- func DeploymentReplicas(ctx context.Context, kubeCli kubernetes.Interface, namespace, name string) (int32, error)
- func DeploymentVolumes(cli kubernetes.Interface, d *appsv1.Deployment) (volNameToPvc map[string]string)
- func Exec(ctx context.Context, cli kubernetes.Interface, ...) (string, string, error)
- func ExecOutput(ctx context.Context, cli kubernetes.Interface, ...) error
- func ExecWithOptions(ctx context.Context, kubeCli kubernetes.Interface, options ExecOptions) error
- func FetchPods(cli kubernetes.Interface, namespace string, uid types.UID) (runningPods []corev1.Pod, notRunningPods []corev1.Pod, err error)
- func FetchReplicaSet(cli kubernetes.Interface, namespace string, uid types.UID, revision string) (*appsv1.ReplicaSet, error)
- func FetchReplicationController(cli kubernetes.Interface, namespace string, uid types.UID, revision string) (*corev1.ReplicationController, error)
- func FetchUnstructuredObject(ctx context.Context, resource schema.GroupVersionResource, ...) (runtime.Unstructured, error)
- func FetchUnstructuredObjectWithCli(ctx context.Context, cli dynamic.Interface, ...) (runtime.Unstructured, error)
- func GetControllerNamespace() (string, error)
- func GetControllerPodName() (string, error)
- func GetControllerServiceAccount(k8sclient kubernetes.Interface) (string, error)
- func GetPodContainerFromDeployment(ctx context.Context, cli kubernetes.Interface, namespace, deployName string) (podName string, containerName string, err error)
- func GetPodContainerFromDeploymentConfig(ctx context.Context, osCli osversioned.Interface, cli kubernetes.Interface, ...) (podName, containerName string, err error)
- func GetPodContainerFromStatefulSet(ctx context.Context, cli kubernetes.Interface, namespace, ssName string) (podName string, containerName string, err error)
- func GetPodLogs(ctx context.Context, cli kubernetes.Interface, ...) (string, error)
- func GetPodObjectFromPodOptions(ctx context.Context, cli kubernetes.Interface, opts *PodOptions) (*corev1.Pod, error)
- func GetPodReadyWaitTimeout() time.Duration
- func GetRegionFromLabels(labels map[string]string) string
- func GetRegionFromNode(node corev1.Node) string
- func GetRegionFromPV(pv corev1.PersistentVolume) string
- func GetZoneFromLabels(labels map[string]string) string
- func GetZoneFromNode(node corev1.Node) string
- func GetZoneFromPV(pv corev1.PersistentVolume) string
- func IsGroupVersionAvailable(ctx context.Context, cli discovery.DiscoveryInterface, ...) (bool, error)
- func IsNodeReady(node *corev1.Node) bool
- func IsNodeSchedulable(node *corev1.Node) bool
- func IsOSAppsGroupAvailable(ctx context.Context, cli discovery.DiscoveryInterface) (bool, error)
- func IsOSRouteGroupAvailable(ctx context.Context, cli discovery.DiscoveryInterface) (bool, error)
- func IsPodRunning(cli kubernetes.Interface, podName, podNamespace string) (bool, error)
- func IsResAvailableInGroupVersion(ctx context.Context, cli discovery.DiscoveryInterface, ...) (bool, error)
- func ListUnstructuredObject(resource schema.GroupVersionResource, namespace string) (runtime.Unstructured, error)
- func ListUnstructuredObjectWithCli(cli dynamic.Interface, resource schema.GroupVersionResource, namespace string) (runtime.Unstructured, error)
- func LoadConfig() (*rest.Config, error)
- func NewCRDClient() (crdclient.Interface, error)
- func NewClient() (kubernetes.Interface, error)
- func NewDynamicClient() (dynamic.Interface, error)
- func PVCContainsReadOnlyAccessMode(pvc *corev1.PersistentVolumeClaim) bool
- func PatchDefaultPodSpecs(defaultPodSpecs corev1.PodSpec, override crv1alpha1.JSONMap) (corev1.PodSpec, error)
- func PodContainers(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) ([]corev1.Container, error)
- func ScaleDeployment(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) error
- func ScaleDeploymentConfig(ctx context.Context, kubeCli kubernetes.Interface, osCli osversioned.Interface, ...) error
- func ScaleStatefulSet(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) error
- func StatefulSetPods(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) ([]corev1.Pod, []corev1.Pod, error)
- func StatefulSetReady(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) (bool, string, error)
- func StatefulSetReplicas(ctx context.Context, kubeCli kubernetes.Interface, namespace, name string) (int32, error)
- func StatefulSetVolumes(cli kubernetes.Interface, sset *appsv1.StatefulSet, pod *corev1.Pod) (volNameToPvc map[string]string)
- func StreamPodLogs(ctx context.Context, cli kubernetes.Interface, ...) (io.ReadCloser, error)
- func WaitForPodCompletion(ctx context.Context, cli kubernetes.Interface, namespace, name string) error
- func WaitForPodReady(ctx context.Context, cli kubernetes.Interface, namespace, name string) error
- func WaitOnDeploymentConfigReady(ctx context.Context, osCli osversioned.Interface, kubeCli kubernetes.Interface, ...) error
- func WaitOnDeploymentReady(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) error
- func WaitOnStatefulSetReady(ctx context.Context, kubeCli kubernetes.Interface, namespace string, ...) error
- type ExecError
- type ExecOptions
- type FakePodCommandExecutor
- type FakePodController
- func (fpc *FakePodController) GetCommandExecutor() (PodCommandExecutor, error)
- func (fpc *FakePodController) GetFileWriter() (PodFileWriter, error)
- func (fpc *FakePodController) Pod() *corev1.Pod
- func (fpc *FakePodController) PodName() string
- func (fpc *FakePodController) Run(ctx context.Context, ...) (map[string]interface{}, error)
- func (fpc *FakePodController) StartPod(_ context.Context) error
- func (fpc *FakePodController) StopPod(ctx context.Context, stopTimeout time.Duration, gracePeriodSeconds int64) error
- func (fpc *FakePodController) StreamPodLogs(_ context.Context) (io.ReadCloser, error)
- func (fpc *FakePodController) WaitForPodCompletion(_ context.Context) error
- func (fpc *FakePodController) WaitForPodReady(_ context.Context) error
- type FakePodControllerProcessor
- func (f *FakePodControllerProcessor) CreatePod(_ context.Context, options *PodOptions) (*corev1.Pod, error)
- func (f *FakePodControllerProcessor) DeletePod(_ context.Context, namespace string, podName string, opts metav1.DeleteOptions) error
- func (f *FakePodControllerProcessor) WaitForPodCompletion(_ context.Context, namespace, podName string) error
- func (f *FakePodControllerProcessor) WaitForPodReady(_ context.Context, namespace, podName string) error
- type FakePodFileRemover
- type FakePodFileWriter
- type KubectlOperation
- type LogTail
- type Operation
- type PodCommandExecutor
- type PodCommandExecutorProcessor
- type PodController
- type PodControllerOption
- type PodControllerProcessor
- type PodFileRemover
- type PodFileWriter
- type PodFileWriterProcessor
- type PodOptions
- type PodRunner
- type PodWriter
- type VolumeMountOptions
Constants ¶
const ( // DefaultPodReadyWaitTimeout is the time to wait for pod to be ready DefaultPodReadyWaitTimeout = 15 * time.Minute // PodReadyWaitTimeoutEnv is the env var to get pod ready wait timeout PodReadyWaitTimeoutEnv = "KANISTER_POD_READY_WAIT_TIMEOUT" DefaultContainerName = "container" )
const ( PodNSEnvVar = "POD_NAMESPACE" PodSAEnvVar = "POD_SERVICE_ACCOUNT" )
const ( // FDZoneLabelName is a known k8s label. used to specify volume zone FDZoneLabelName = "failure-domain.beta.kubernetes.io/zone" // TopologyZoneLabelName is a known k8s label. used to specify volume zone for kubernetes 1.17 onwards TopologyZoneLabelName = "topology.kubernetes.io/zone" // FDRegionLabelName is a known k8s label FDRegionLabelName = "failure-domain.beta.kubernetes.io/region" // TopologyRegionLabelName is a known k8s label. used to specify volume region for kubernetes 1.17 onwards TopologyRegionLabelName = "topology.kubernetes.io/region" // LocationSecretVolumeMountName is the name of location secret volume mount LocationSecretVolumeMountName = "location-secret" // LocationSecretMountPath is the path where location secret would be mounted LocationSecretMountPath = "/mnt/secrets/location" )
const ( // RevisionAnnotation is the revision annotation of a deployment's replica sets which records its rollout sequence RevisionAnnotation = "deployment.kubernetes.io/revision" // ReplicationControllerRevisionAnnotation is annotation of deploymentconfig's repliationcontroller ReplicationControllerRevisionAnnotation = "openshift.io/deployment-config.latest-version" )
Variables ¶
var ( ErrPodControllerNotInitialized = errkit.NewSentinelErr("pod has not been initialized") ErrPodControllerPodAlreadyStarted = errkit.NewSentinelErr("pod has already been started") ErrPodControllerPodNotReady = errkit.NewSentinelErr("pod is not yet ready") ErrPodControllerPodNotStarted = errkit.NewSentinelErr("pod is not yet started") PodControllerDefaultStopTime = 30 * time.Second PodControllerInfiniteStopTime = 0 * time.Second )
Functions ¶
func AddLabelsToPodOptionsFromContext ¶
func AddLabelsToPodOptionsFromContext( ctx context.Context, options *PodOptions, targetKey string, )
AddLabelsToPodOptionsFromContext adds a label to `PodOptions`. It extracts the value from the context if targetKey is present and assigns to the options.
func ConfigNamespace ¶
ConfigNamespace returns the namespace from config
func ContainerNameFromPodOptsOrDefault ¶
func ContainerNameFromPodOptsOrDefault(po *PodOptions) string
ContainerNameFromPodOptsOrDefault returns the container name if it's set in the passed `podOptions` value. If not, it's returns the default container name. This should be used whenever we create pods for Kanister functions.
func CreateAndMergeJSONPatch ¶
func CreateAndMergeJSONPatch(original, override crv1alpha1.JSONMap) (crv1alpha1.JSONMap, error)
CreateAndMergeJSONPatch uses Strategic Merge to merge two Pod spec configuration
func CreateConfigMap ¶
func CreateConfigMap(ctx context.Context, cli kubernetes.Interface, namespace string, spec string) (*corev1.ConfigMap, error)
CreateConfigMap creates a configmap set from a yaml spec.
func CreateDeployment ¶
func CreateDeployment(ctx context.Context, cli kubernetes.Interface, namespace string, spec string) (*appsv1.Deployment, error)
CreateDeployment creates a deployment set from a yaml spec.
func CreatePod ¶
func CreatePod(ctx context.Context, cli kubernetes.Interface, opts *PodOptions) (*corev1.Pod, error)
CreatePod creates a pod with a single container based on the specified image
func CreateStatefulSet ¶
func CreateStatefulSet(ctx context.Context, cli kubernetes.Interface, namespace string, spec string) (*appsv1.StatefulSet, error)
CreateStatefulSet creates a stateful set from a yaml spec.
func DeploymentConfigPods ¶
func DeploymentConfigPods(ctx context.Context, osCli osversioned.Interface, kubeCli kubernetes.Interface, namespace, name string) ([]corev1.Pod, []corev1.Pod, error)
DeploymentConfigPods return list of running and not running pod created by this/name deployment config
func DeploymentConfigReady ¶
func DeploymentConfigReady(ctx context.Context, osCli osversioned.Interface, cli kubernetes.Interface, namespace, name string) (bool, error)
DeploymentConfigReady checks to see the deploymentconfig has desired number of available replicas.
func DeploymentConfigVolumes ¶
func DeploymentConfigVolumes(osCli osversioned.Interface, depConfig *osAppsv1.DeploymentConfig, pod *corev1.Pod) (volNameToPvc map[string]string)
DeploymentConfigVolumes returns the PVCs references by a pod in this deployment config as a [pod spec volume name]-> [PVC name] map will mostly be used for the applications running in open shift clusters
func DeploymentPods ¶
func DeploymentPods(ctx context.Context, kubeCli kubernetes.Interface, namespace string, name string) ([]corev1.Pod, []corev1.Pod, error)
DeploymentPods returns list of running and notrunning pods created by the deployment.
func DeploymentReady ¶
func DeploymentReady(ctx context.Context, kubeCli kubernetes.Interface, namespace string, name string) (bool, string, error)
DeploymentReady checks to see if the deployment has the desired number of available replicas.
func DeploymentReplicas ¶
func DeploymentVolumes ¶
func DeploymentVolumes(cli kubernetes.Interface, d *appsv1.Deployment) (volNameToPvc map[string]string)
DeploymentVolumes returns the PVCs referenced by this deployment as a [pods spec volume name]->[PVC name] map
func Exec ¶
func Exec( ctx context.Context, cli kubernetes.Interface, namespace, pod, container string, command []string, stdin io.Reader, ) (string, string, error)
Exec is our version of the call to `kubectl exec` that does not depend on k8s.io/kubernetes.
func ExecOutput ¶
func ExecOutput( ctx context.Context, cli kubernetes.Interface, namespace, pod, container string, command []string, stdin io.Reader, stdout, stderr io.Writer, ) error
ExecOutput is similar to Exec, except that inbound outputs are written to the provided stdout and stderr. Unlike Exec, the outputs are not returned to the caller.
func ExecWithOptions ¶
func ExecWithOptions(ctx context.Context, kubeCli kubernetes.Interface, options ExecOptions) error
ExecWithOptions executes a command in the specified container, returning an error. `options` allowed for additional parameters to be passed.
func FetchPods ¶
func FetchPods(cli kubernetes.Interface, namespace string, uid types.UID) (runningPods []corev1.Pod, notRunningPods []corev1.Pod, err error)
FetchPods fetches the pods matching the specified owner UID and splits them into 2 groups (running/not-running)
func FetchReplicaSet ¶
func FetchReplicaSet(cli kubernetes.Interface, namespace string, uid types.UID, revision string) (*appsv1.ReplicaSet, error)
FetchReplicaSet fetches the replicaset matching the specified owner UID
func FetchReplicationController ¶
func FetchReplicationController(cli kubernetes.Interface, namespace string, uid types.UID, revision string) (*corev1.ReplicationController, error)
FetchReplicationController fetches the replication controller that has owner with UID provided uid
func FetchUnstructuredObject ¶
func FetchUnstructuredObject(ctx context.Context, resource schema.GroupVersionResource, namespace, name string) (runtime.Unstructured, error)
FetchUnstructuredObject returns the referenced API object as a map[string]interface{}
func FetchUnstructuredObjectWithCli ¶
func FetchUnstructuredObjectWithCli(ctx context.Context, cli dynamic.Interface, resource schema.GroupVersionResource, namespace, name string) (runtime.Unstructured, error)
FetchUnstructuredObjectWithCli returns the referenced API object as a map[string]interface{} using the specified CLI TODO: deprecate `FetchUnstructuredObject`
func GetControllerNamespace ¶
GetControllerNamespace returns controller namespace
func GetControllerPodName ¶
GetControllerPodName returns controller pod name
func GetControllerServiceAccount ¶
func GetControllerServiceAccount(k8sclient kubernetes.Interface) (string, error)
GetControllerServiceAccount returns controller ServiceAccount
func GetPodContainerFromDeployment ¶
func GetPodContainerFromDeployment(ctx context.Context, cli kubernetes.Interface, namespace, deployName string) (podName string, containerName string, err error)
GetPodContainerFromDeployment returns a pod and container running the deployment
func GetPodContainerFromDeploymentConfig ¶
func GetPodContainerFromDeploymentConfig(ctx context.Context, osCli osversioned.Interface, cli kubernetes.Interface, namespace, deployConfigName string) (podName, containerName string, err error)
GetPodContainerFromDeploymentConfig returns a pod and container that is running from the provided deployment config
func GetPodContainerFromStatefulSet ¶
func GetPodContainerFromStatefulSet(ctx context.Context, cli kubernetes.Interface, namespace, ssName string) (podName string, containerName string, err error)
GetPodContainerFromStatefulSet returns a pod and container running the stateful set
func GetPodLogs ¶
func GetPodLogs(ctx context.Context, cli kubernetes.Interface, namespace, podName, containerName string) (string, error)
GetPodLogs fetches the logs from the given pod
func GetPodObjectFromPodOptions ¶
func GetPodObjectFromPodOptions(ctx context.Context, cli kubernetes.Interface, opts *PodOptions) (*corev1.Pod, error)
func GetPodReadyWaitTimeout ¶
GetPodReadyWaitTimeout returns the pod ready wait timeout from ENV if configured returns the default of 15 minutes otherwise
func GetRegionFromLabels ¶
func GetRegionFromNode ¶
func GetRegionFromPV ¶
func GetRegionFromPV(pv corev1.PersistentVolume) string
func GetZoneFromLabels ¶
func GetZoneFromNode ¶
func GetZoneFromPV ¶
func GetZoneFromPV(pv corev1.PersistentVolume) string
func IsGroupVersionAvailable ¶
func IsGroupVersionAvailable(ctx context.Context, cli discovery.DiscoveryInterface, groupName, version string) (bool, error)
IsGroupVersionAvailable returns true if given group/version is registered.
func IsNodeReady ¶
IsNodeReady returns true if it's Ready condition is set to true Derived from "k8s.io/kubernetes/test/e2e/framework/node"
func IsNodeSchedulable ¶
IsNodeSchedulable returns true if it doesn't have "unschedulable" field set Derived from "k8s.io/kubernetes/test/e2e/framework/node"
func IsOSAppsGroupAvailable ¶
IsOSAppsGroupAvailable returns true if the openshift apps group is registered in service discovery.
func IsOSRouteGroupAvailable ¶
IsOSRouteGroupAvailable returns true is the openshift route group is registered in service discovery
func IsPodRunning ¶
func IsPodRunning(cli kubernetes.Interface, podName, podNamespace string) (bool, error)
IsPodRunning checks if the provided pod is ready or not
func IsResAvailableInGroupVersion ¶
func IsResAvailableInGroupVersion(ctx context.Context, cli discovery.DiscoveryInterface, groupName, version, resource string) (bool, error)
IsResAvailableInGroupVersion takes a resource and checks if that exists in the passed group and version
func ListUnstructuredObject ¶
func ListUnstructuredObject(resource schema.GroupVersionResource, namespace string) (runtime.Unstructured, error)
ListUnstructuredObject returns the referenced API objects as a map[string]interface{}
func ListUnstructuredObjectWithCli ¶
func ListUnstructuredObjectWithCli(cli dynamic.Interface, resource schema.GroupVersionResource, namespace string) (runtime.Unstructured, error)
ListUnstructuredObjectWithCli returns the referenced API objects as a map[string]interface{} using the specified CLI TODO: deprecate `ListUnstructuredObject`
func LoadConfig ¶
LoadConfig returns a kubernetes client config based on global settings.
func NewCRDClient ¶
NewCRDClient returns a Dynamic client configured by the Kanister environment.
func NewClient ¶
func NewClient() (kubernetes.Interface, error)
NewClient returns a k8 client configured by the kanister environment.
func NewDynamicClient ¶
NewDynamicClient returns a Dynamic client configured by the Kanister environment.
func PVCContainsReadOnlyAccessMode ¶
func PVCContainsReadOnlyAccessMode(pvc *corev1.PersistentVolumeClaim) bool
PVCContainsReadOnlyAccessMode return true if AccessModes of PVC contain `ReadOnlyMany`
func PatchDefaultPodSpecs ¶
func PatchDefaultPodSpecs(defaultPodSpecs corev1.PodSpec, override crv1alpha1.JSONMap) (corev1.PodSpec, error)
PatchDefaultPodSpecs paches default pod specs with the passed override using Strategic Merge.
func PodContainers ¶
func PodContainers(ctx context.Context, kubeCli kubernetes.Interface, namespace string, name string) ([]corev1.Container, error)
PodContainers returns list of containers specified by the pod
func ScaleDeployment ¶
func ScaleDeploymentConfig ¶
func ScaleStatefulSet ¶
func StatefulSetPods ¶
func StatefulSetPods(ctx context.Context, kubeCli kubernetes.Interface, namespace string, name string) ([]corev1.Pod, []corev1.Pod, error)
StatefulSetPods returns list of running and notrunning pods created by the deployment.
func StatefulSetReady ¶
func StatefulSetReady(ctx context.Context, kubeCli kubernetes.Interface, namespace string, name string) (bool, string, error)
StatefulSetReady checks if a statefulset has the desired number of ready replicas.
func StatefulSetReplicas ¶
func StatefulSetVolumes ¶
func StatefulSetVolumes(cli kubernetes.Interface, sset *appsv1.StatefulSet, pod *corev1.Pod) (volNameToPvc map[string]string)
StatefulSetVolumes returns the PVCs referenced by a pod in this statefulset as a [pod spec volume name]->[PVC name] map
func StreamPodLogs ¶
func StreamPodLogs(ctx context.Context, cli kubernetes.Interface, namespace, podName, containerName string) (io.ReadCloser, error)
func WaitForPodCompletion ¶
func WaitForPodCompletion(ctx context.Context, cli kubernetes.Interface, namespace, name string) error
WaitForPodCompletion waits for a pod to reach a terminal state, or timeout
func WaitForPodReady ¶
WaitForPodReady waits for a pod to exit the pending state
func WaitOnDeploymentConfigReady ¶
func WaitOnDeploymentConfigReady(ctx context.Context, osCli osversioned.Interface, kubeCli kubernetes.Interface, namespace, name string) error
WaitOnDeploymentConfigReady waits for deploymentconfig to be ready
func WaitOnDeploymentReady ¶
func WaitOnDeploymentReady(ctx context.Context, kubeCli kubernetes.Interface, namespace string, name string) error
WaitOnDeploymentReady waits for the deployment to be ready
func WaitOnStatefulSetReady ¶
func WaitOnStatefulSetReady(ctx context.Context, kubeCli kubernetes.Interface, namespace string, name string) error
WaitOnStatefulSetReady waits for the stateful set to be ready
Types ¶
type ExecError ¶
type ExecError struct {
// contains filtered or unexported fields
}
ExecError is an error returned by kube.Exec, kube.ExecOutput and kube.ExecWithOptions. It contains not only error happened during an execution, but also keeps tails of stdout/stderr streams. These tails could be used by the invoker to construct more precise error.
func NewExecError ¶
NewExecError creates an instance of ExecError
type ExecOptions ¶
type ExecOptions struct { Command []string Namespace string PodName string ContainerName string Stdin io.Reader Stdout io.Writer Stderr io.Writer }
ExecOptions passed to ExecWithOptions
type FakePodCommandExecutor ¶
type FakePodController ¶
type FakePodController struct { Podname string PodObj *corev1.Pod StartPodCalled bool StartPodErr error WaitForPodReadyCalled bool WaitForPodReadyErr error GetCommandExecutorRet PodCommandExecutor GetCommandExecutorErr error GetFileWriterCalled bool GetFileWriterRet *FakePodFileWriter GetFileWriterErr error StopPodCalled bool StopPodErr error InStopPodStopTimeout time.Duration InStopPodGracePeriod int64 }
func (*FakePodController) GetCommandExecutor ¶
func (fpc *FakePodController) GetCommandExecutor() (PodCommandExecutor, error)
func (*FakePodController) GetFileWriter ¶
func (fpc *FakePodController) GetFileWriter() (PodFileWriter, error)
func (*FakePodController) Pod ¶
func (fpc *FakePodController) Pod() *corev1.Pod
func (*FakePodController) PodName ¶
func (fpc *FakePodController) PodName() string
func (*FakePodController) StartPod ¶
func (fpc *FakePodController) StartPod(_ context.Context) error
func (*FakePodController) StreamPodLogs ¶
func (fpc *FakePodController) StreamPodLogs(_ context.Context) (io.ReadCloser, error)
func (*FakePodController) WaitForPodCompletion ¶
func (fpc *FakePodController) WaitForPodCompletion(_ context.Context) error
func (*FakePodController) WaitForPodReady ¶
func (fpc *FakePodController) WaitForPodReady(_ context.Context) error
type FakePodControllerProcessor ¶
type FakePodControllerProcessor struct { InWaitForPodReadyNamespace string InWaitForPodReadyPodName string WaitForPodReadyErr error InWaitForPodCompletionNamespace string InWaitForPodCompletionPodName string WaitForPodCompletionErr error InDeletePodNamespace string InDeletePodPodName string InDeletePodOptions metav1.DeleteOptions DeletePodErr error InCreatePodOptions *PodOptions CreatePodRet *corev1.Pod CreatePodErr error }
FakePodControllerProcessor implements PodControllerProcessor
func (*FakePodControllerProcessor) CreatePod ¶
func (f *FakePodControllerProcessor) CreatePod(_ context.Context, options *PodOptions) (*corev1.Pod, error)
func (*FakePodControllerProcessor) DeletePod ¶
func (f *FakePodControllerProcessor) DeletePod(_ context.Context, namespace string, podName string, opts metav1.DeleteOptions) error
func (*FakePodControllerProcessor) WaitForPodCompletion ¶
func (f *FakePodControllerProcessor) WaitForPodCompletion(_ context.Context, namespace, podName string) error
func (*FakePodControllerProcessor) WaitForPodReady ¶
func (f *FakePodControllerProcessor) WaitForPodReady(_ context.Context, namespace, podName string) error
type FakePodFileRemover ¶
type FakePodFileRemover struct {
// contains filtered or unexported fields
}
func (*FakePodFileRemover) Path ¶
func (fr *FakePodFileRemover) Path() string
type FakePodFileWriter ¶
type FakePodFileWriter struct {
// contains filtered or unexported fields
}
func (*FakePodFileWriter) Write ¶
func (fpfw *FakePodFileWriter) Write(_ context.Context, filePath string, content io.Reader) (PodFileRemover, error)
type KubectlOperation ¶
type KubectlOperation struct {
// contains filtered or unexported fields
}
KubectlOperation implements methods to perform kubectl operations
func NewKubectlOperations ¶
func NewKubectlOperations(dynCli dynamic.Interface) *KubectlOperation
NewKubectlOperations returns new KubectlOperations object
func (*KubectlOperation) Create ¶
func (k *KubectlOperation) Create(spec io.Reader, namespace string) (*crv1alpha1.ObjectReference, error)
Create k8s resource from spec manifest
func (*KubectlOperation) Delete ¶
func (k *KubectlOperation) Delete(ctx context.Context, objRef crv1alpha1.ObjectReference, namespace string) (*crv1alpha1.ObjectReference, error)
Delete k8s resource referred by objectReference. Waits for the resource to be deleted
type LogTail ¶
LogTail interface allows to store last N lines of log written to it
func NewLogTail ¶
NewLogTail creates logTail struct containing circular buffer for storing `len` last lines of log written through Write method
type PodCommandExecutor ¶
type PodCommandExecutor interface {
Exec(ctx context.Context, command []string, stdin io.Reader, stdout, stderr io.Writer) error
}
PodCommandExecutor provides a way to execute a command within the pod. Is intended to be returned by PodController and works with pod controlled by it.
type PodCommandExecutorProcessor ¶
type PodCommandExecutorProcessor interface {
ExecWithOptions(ctx context.Context, opts ExecOptions) error
}
PodCommandExecutorProcessor is an interface wrapping kubernetes API invocation it is purposed to be replaced by fake implementation in tests
type PodController ¶
type PodController interface { PodName() string Pod() *corev1.Pod StartPod(ctx context.Context) error WaitForPodReady(ctx context.Context) error WaitForPodCompletion(ctx context.Context) error StopPod(ctx context.Context, timeout time.Duration, gracePeriodSeconds int64) error StreamPodLogs(ctx context.Context) (io.ReadCloser, error) GetCommandExecutor() (PodCommandExecutor, error) GetFileWriter() (PodFileWriter, error) }
PodController specifies interface needed for starting, stopping pod and operations with it
The purpose of this interface is to provide single mechanism of pod manipulation, reduce number of parameters which caller needs to pass (since we keep pod related things internally) and eliminate human errors.
func NewPodController ¶
func NewPodController(cli kubernetes.Interface, options *PodOptions, opts ...PodControllerOption) PodController
NewPodController returns a new PodController given Kubernetes Client and PodOptions
func NewPodControllerForExistingPod ¶
func NewPodControllerForExistingPod(cli kubernetes.Interface, pod *corev1.Pod) (PodController, error)
NewPodControllerForExistingPod returns a new PodController for the given running pod. Invocation of StartPod of returned PodController instance will fail, since the pod is expected to be running already. Note: If the pod is not in the ready state, it will wait for up to KANISTER_POD_READY_WAIT_TIMEOUT (15 minutes by default) until the pod becomes ready.
type PodControllerOption ¶
type PodControllerOption func(p *podController)
func WithPodControllerProcessor ¶
func WithPodControllerProcessor(processor PodControllerProcessor) PodControllerOption
WithPodControllerProcessor provides mechanism for passing fake implementation of PodControllerProcessor for testing purposes.
type PodControllerProcessor ¶
type PodControllerProcessor interface { CreatePod(ctx context.Context, options *PodOptions) (*corev1.Pod, error) WaitForPodReady(ctx context.Context, namespace, podName string) error WaitForPodCompletion(ctx context.Context, namespace, podName string) error DeletePod(ctx context.Context, namespace string, podName string, opts metav1.DeleteOptions) error }
PodControllerProcessor is an interface wrapping kubernetes API invocation it is purposed to be replaced by fake implementation in tests
type PodFileRemover ¶
PodFileRemover provides mechanism for removing particular file written to the pod by PodFileWriter.
type PodFileWriter ¶
type PodFileWriter interface {
Write(ctx context.Context, filePath string, content io.Reader) (PodFileRemover, error)
}
PodFileWriter provides a way to write a file to the pod. Is intended to be returned by PodController and works with pod controlled by it.
type PodFileWriterProcessor ¶
type PodFileWriterProcessor interface {
NewPodWriter(filePath string, content io.Reader) PodWriter
}
PodFileWriterProcessor is an interface wrapping kubernetes API invocation it is purposed to be replaced by fake implementation in tests
type PodOptions ¶
type PodOptions struct { Annotations map[string]string Command []string ContainerName string Name string GenerateName string Image string Labels map[string]string Namespace string ServiceAccountName string Volumes map[string]VolumeMountOptions BlockVolumes map[string]string // PodSecurityContext and ContainerSecurityContext can be used to set the security context // at the pod level and container level respectively. // You can still use podOverride to set the pod security context, but these fields will take precedence. // We chose these fields to specify security context instead of just using podOverride because // the merge behaviour of the pods spec is confusing in case of podOverride, and this is more readable. PodSecurityContext *corev1.PodSecurityContext ContainerSecurityContext *corev1.SecurityContext PodOverride crv1alpha1.JSONMap Resources corev1.ResourceRequirements RestartPolicy corev1.RestartPolicy OwnerReferences []metav1.OwnerReference EnvironmentVariables []corev1.EnvVar Lifecycle *corev1.Lifecycle }
PodOptions specifies options for `CreatePod`
func (*PodOptions) AddAnnotations ¶
func (po *PodOptions) AddAnnotations(annotations map[string]string)
func (*PodOptions) AddLabels ¶
func (po *PodOptions) AddLabels(labels map[string]string)
type PodRunner ¶
type PodRunner interface { // Run creates pod using the PodController interface and forwards it to the functor. // Pod will be deleted as soon as functor exits. Run(ctx context.Context, fn func(context.Context, PodController) (map[string]interface{}, error)) (map[string]interface{}, error) }
PodRunner allows us to start / stop pod, write file to pod and execute command within it
func NewPodRunner ¶
func NewPodRunner(cli kubernetes.Interface, options *PodOptions) PodRunner
NewPodRunner returns a new PodRunner given Kubernetes Client and PodOptions
func NewPodRunnerWithPodController ¶
func NewPodRunnerWithPodController(pc PodController) PodRunner
NewPodRunnerWithPodController returns a new PodRunner given PodController object This provides mechanism for passing fake PodControllerProcessor through PodController for testing purposes.
type PodWriter ¶
type PodWriter interface { // Write will create a new file(if not present) and write the provided content to the file Write(ctx context.Context, namespace, podName, containerName string) error // Remove will delete the file created by Write() func Remove(ctx context.Context, namespace, podName, containerName string) error }
PodWriter specifies interface needed for manipulating files in a pod
func NewPodWriter ¶
NewPodWriter returns a new PodWriter given Kubernetes Client, path of file and content
type VolumeMountOptions ¶
Source Files ¶
- client.go
- discover.go
- exec.go
- fake_pod_command_executor.go
- fake_pod_controller.go
- fake_pod_controller_processor.go
- kubectl.go
- log_reader.go
- log_tail.go
- pod.go
- pod_command_executor.go
- pod_command_executor_processor.go
- pod_controller.go
- pod_controller_processor.go
- pod_file_writer.go
- pod_file_writer_processor.go
- pod_runner.go
- pod_writer.go
- podinfo.go
- unstructured.go
- utils.go
- workload.go