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 ¶
- func CreateISCSIPV(name string, mb int, lun int) (string, error)
- func CreatePV(name string, mb int, accessModes []api.PersistentVolumeAccessMode) (string, error)
- func CreatePVAtExport(name, export string, mb int, accessModes []api.PersistentVolumeAccessMode) (string, error)
- func CreatePVC(name, namespace string, mb int, accessModes []api.PersistentVolumeAccessMode) (string, error)
- func CreatePod(name, namespace string, containerDescs []resources.ContainerDesc) (string, error)
- func DeleteTestResources()
- func GetContainerDescs(pvcsForContainers [][]resources.VolumeMount) []resources.ContainerDesc
- func GetExportPath(subdir string) string
- func GetExportRoot() string
- func GetFSType() string
- func GetFilerIP() string
- func GetIQN() string
- func GetISCSIAccessModes() []api.PersistentVolumeAccessMode
- func GetLocalPath(subdir string) string
- func GetStorageValue(size int) int64
- func GetTargetPortal() string
- func RMExportDir(dir string)
- func RunKubectl(action KubeAction, file string, validate bool) error
- func UpdateISCSIPV(name string, mb int, lun int) (string, error)
- func UpdatePV(name string, mb int, accessModes []api.PersistentVolumeAccessMode) (string, error)
- func UpdatePVAtExport(name, export string, mb int, accessModes []api.PersistentVolumeAccessMode) (string, error)
- func UpdatePVC(name, namespace string, mb int, accessModes []api.PersistentVolumeAccessMode) (string, error)
- type KubeAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateISCSIPV ¶
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 ¶
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 GetExportRoot ¶
func GetExportRoot() string
func GetFilerIP ¶
func GetFilerIP() string
We use getters for the package variables above, since they should remain constant after initialization.
func GetISCSIAccessModes ¶
func GetISCSIAccessModes() []api.PersistentVolumeAccessMode
func GetLocalPath ¶
func GetStorageValue ¶
GetStorageValue converts a storage size in MB to an int64.
func GetTargetPortal ¶
func GetTargetPortal() string
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 ¶
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 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" )