Documentation ¶
Overview ¶
Package k8s provides utility functions for working with Kubernetes clusters.
Package k8s provides utility functions for working with Kubernetes pods.
Index ¶
- Variables
- func DeletePersistentVolumeClaim(namespace, name string)
- func DeletePod(namespace, name string) error
- func DeleteService(namespace, name string) error
- func DeployPersistentVolumeClaim(namespace, name string, labels map[string]string, size resource.Quantity, ...)
- func DeployPod(podConfig PodConfig, init bool) (*v1.Pod, error)
- func DeployService(namespace, name string, labels, selectorMap map[string]string, ...) (*v1.Service, error)
- func GetCurrentNamespace() string
- func GetService(namespace, name string) (*v1.Service, error)
- func GetServiceIP(namespace, name string) (string, error)
- func Initialize()
- func PatchService(namespace, name string, labels, selectorMap map[string]string, ...) error
- func PersistentVolumeClaimExists(namespace, name string) bool
- func ReplacePod(podConfig PodConfig) (*v1.Pod, error)
- func RunCommandInPod(namespace, podName, containerName string, cmd []string) (string, error)
- func WaitPodIsRunning(namespace, name string) error
- type PodConfig
Constants ¶
This section is empty.
Variables ¶
var Clientset *kubernetes.Clientset
Clientset is a global variable that holds a kubernetes clientset.
var Namespace = "default"
Namespace is the current namespace in use by the Kubernetes client.
Functions ¶
func DeletePersistentVolumeClaim ¶
func DeletePersistentVolumeClaim(namespace, name string)
DeletePersistentVolumeClaim deletes a PersistentVolumeClaim if it exists.
func DeleteService ¶
DeleteService deletes a service if it exists.
func DeployPersistentVolumeClaim ¶
func DeployPersistentVolumeClaim(namespace, name string, labels map[string]string, size resource.Quantity, accessModes []string)
DeployPersistentVolumeClaim deploys a PersistentVolumeClaim if it does not exist.
func DeployService ¶
func DeployService(namespace, name string, labels, selectorMap map[string]string, portsTCP, portsUDP []int) (*v1.Service, error)
DeployService deploys a service if it does not exist.
func GetCurrentNamespace ¶
func GetCurrentNamespace() string
GetCurrentNamespace returns the current namespace in use.
func GetService ¶
GetService retrieves a service.
func GetServiceIP ¶
GetServiceIP retrieves the IP address of a service.
func Initialize ¶
func Initialize()
Initialize sets up the Kubernetes client with the appropriate configuration.
func PatchService ¶
func PatchService(namespace, name string, labels, selectorMap map[string]string, portsTCP, portsUDP []int) error
PatchService patches an existing service.
func PersistentVolumeClaimExists ¶
PersistentVolumeClaimExists checks if a PersistentVolumeClaim exists.
func ReplacePod ¶
ReplacePod replaces a pod in the given namespace and returns the new Pod object.
func RunCommandInPod ¶
RunCommandInPod runs a command in a container within a pod.
func WaitPodIsRunning ¶
WaitPodIsRunning waits until a pod in the given namespace is running.
Types ¶
type PodConfig ¶
type PodConfig struct { Namespace string // Kubernetes namespace of the Pod Name string // Name to assign to the Pod Labels map[string]string // Labels to apply to the Pod Image string // Name of the Docker image to use for the container Command []string // Command to run in the container Args []string // Arguments to pass to the command in the container Env map[string]string // Environment variables to set in the container Volumes map[string]string // Volumes to mount in the Pod }
PodConfig contains the specifications for creating a new Pod object