kubectl

package
v0.0.0-...-88490aa Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package kubectl provides utilities for creating and updating Kubernetes resources. It does so by writing YAML out to the test-resources subdirectory and calling kubectl create or kubectl apply as appropriate. As this is intended for testing, all resources are basic and their details are relatively inflexible.

All create and update functions return the filename of the YAML they have written, along with any error that may have occurred. TODO: Communicate directly with the API server, rather than going through kubectl

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateISCSIPV

func CreateISCSIPV(name string, mb int, lun int) (string, error)

CreateISCSIPV creates an ISCSI PV with the given LUN and size, using the target portal and IQN specified in $TARGET_PORTAL and $IQN. All ISCSI PVs use the access modes specified in iscsiAccessModes.

func CreatePV

func CreatePV(name string, mb int,
	accessModes []api.PersistentVolumeAccessMode) (string, error)

CreatePV creates an NFS PV that mounts $EXPORT_ROOT. Specifically, it calls CreatePVAtExport with "" as the export.

func CreatePVAtExport

func CreatePVAtExport(name, export string, mb int,
	accessModes []api.PersistentVolumeAccessMode) (string, error)

CreatePVAtExport creates an NFS PV that mounts the specified export. Export should be a subdirectory of $EXPORT_ROOT; thus, if empty, it creates a PV mounting $EXPORT_ROOT.

func CreatePVC

func CreatePVC(name, namespace string, mb int,
	accessModes []api.PersistentVolumeAccessMode) (string, error)

Creates a Kubernetes PVC with the specified attributes.

func CreatePod

func CreatePod(name, namespace string,
	containerDescs []resources.ContainerDesc) (string, error)

CreatePod creates a basic pod in Kubernetes with the specified containers.

func DeleteTestResources

func DeleteTestResources()

DeleteTestResources calls kubectl delete for every resource found in test-resources/. Note that, as implemented, baseDir depends on the package in which the initial test is invoked. Thus, each package needs to do their own cleanup, as tests won't clean up resources from tests run in other packages.

func GetContainerDescs

func GetContainerDescs(
	pvcsForContainers [][]resources.VolumeMount,
) []resources.ContainerDesc

GetContainerDescs is a utility function for CreatePod and UpdatePod that produces an array of resources.ContainerDesc, each of which contains the volumes specified in each top level entry of pvcsForContainers. Each container is named "busybox-%d", where %d is the index of the container in the returned array, and runs a busybox image with the command "sleep 3600"

func GetExportPath

func GetExportPath(subdir string) string

func GetExportRoot

func GetExportRoot() string

func GetFSType

func GetFSType() string

func GetFilerIP

func GetFilerIP() string

We use getters for the package variables above, since they should remain constant after initialization.

func GetIQN

func GetIQN() string

func GetISCSIAccessModes

func GetISCSIAccessModes() []api.PersistentVolumeAccessMode

func GetLocalPath

func GetLocalPath(subdir string) string

func GetStorageValue

func GetStorageValue(size int) int64

GetStorageValue converts a storage size in MB to an int64.

func GetTargetPortal

func GetTargetPortal() string

func RMExportDir

func RMExportDir(dir string)

RMExportDir removes a subdirectory of $EXPORT_ROOT.

func RunKubectl

func RunKubectl(action KubeAction, file string, validate bool) error

RunKubectl performs one of the kubectl actions (defined as a KubeAction value) on the specified file. If validate is false, it uses the --validate=false parameter. If deleting, it appends the --grace-period=0 flag so that tests do not have to wait for pods to terminate gracefully.

func UpdateISCSIPV

func UpdateISCSIPV(name string, mb int, lun int) (string, error)

UpdateISCSIPV updates the ISCSI PV with the provided name to point to the provided LUN and have the specified size in MB. Note that calling this for an NFS volume is undefined and should not be done.

func UpdatePV

func UpdatePV(name string, mb int,
	accessModes []api.PersistentVolumeAccessMode) (string, error)

UpdatePV calls UpdatePVAtExport using "" as the export.

func UpdatePVAtExport

func UpdatePVAtExport(name, export string, mb int,
	accessModes []api.PersistentVolumeAccessMode) (string, error)

UpdatePVAtExport updates the PV with the provided name to point to the provided export and have the specified size in MB and access modes. As with CreatePVAtExport, export should be a subdirectory of $EXPORT_ROOT.

func UpdatePVC

func UpdatePVC(name, namespace string, mb int,
	accessModes []api.PersistentVolumeAccessMode) (string, error)

UpdatePVC updates the PVC with the specified name and namespace to have the size in MB and access modes provided. This does no validation on whether the update should be possible.

Types

type KubeAction

type KubeAction string
const (
	Create KubeAction = "create"
	Delete KubeAction = "delete"
	Apply  KubeAction = "apply"
)

Jump to

Keyboard shortcuts

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