Documentation
¶
Overview ¶
Package k8s provides utility functions for working with Kubernetes clusters.
Index ¶
- func Clientset() *kubernetes.Clientset
- func ConfigMapExists(namespace, name string) (bool, error)
- func CreateConfigMap(namespace, name string, labels, data map[string]string) (*v1.ConfigMap, error)
- func CreateDaemonSet(namespace, name string, labels map[string]string, ...) (*appv1.DaemonSet, error)
- func CreateNetworkPolicy(namespace, name string, ...) error
- func CreateRole(namespace, name string, labels map[string]string, ...) error
- func CreateRoleBinding(namespace, name string, labels map[string]string, role, serviceAccount string) error
- func CreateServiceAccount(namespace, name string, labels map[string]string) error
- func DaemonSetExists(namespace, name string) (bool, error)
- func DeleteConfigMap(namespace, name string) error
- func DeleteDaemonSet(namespace, name string) error
- func DeleteNetworkPolicy(namespace string, name string) error
- func DeletePersistentVolumeClaim(namespace, name string)
- func DeletePod(namespace, name string) error
- func DeletePodWithGracePeriod(namespace, name string, gracePeriodSeconds *int64) error
- func DeleteRole(namespace, name string) error
- func DeleteRoleBinding(namespace, name string) error
- func DeleteService(namespace, name string) error
- func DeleteServiceAccount(namespace, name string) error
- func DeleteStatefulSet(namespace, name string) error
- func DeleteStatefulSetWithGracePeriod(namespace, name string, gracePeriodSeconds *int64) 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 DeployStatefulSet(statefulSetConfig StatefulSetConfig, init bool) (*appv1.StatefulSet, error)
- func GetConfigMap(namespace, name string) (*v1.ConfigMap, error)
- func GetDaemonSet(namespace, name string) (*appv1.DaemonSet, error)
- func GetFirstPodFromStatefulSet(namespace, name string) (*v1.Pod, error)
- func GetNetworkPolicy(namespace string, name string) (*v1.NetworkPolicy, error)
- func GetService(namespace, name string) (*v1.Service, error)
- func GetServiceIP(namespace, name string) (string, error)
- func Initialize() error
- func IsInitialized() bool
- func IsPodRunning(namespace, name string) (bool, error)
- func IsStatefulSetRunning(namespace, name string) (bool, error)
- func Namespace() string
- func NetworkPolicyExists(namespace string, name string) bool
- func PatchService(namespace, name string, labels, selectorMap map[string]string, ...) error
- func PortForwardPod(namespace, podName string, localPort, remotePort int) error
- func ReplacePod(podConfig PodConfig) (*v1.Pod, error)
- func ReplacePodWithGracePeriod(podConfig PodConfig, gracePeriod *int64) (*v1.Pod, error)
- func ReplaceStatefulSet(statefulSetConfig StatefulSetConfig) (*appv1.StatefulSet, error)
- func ReplaceStatefulSetWithGracePeriod(statefulSetConfig StatefulSetConfig, gracePeriod *int64) (*appv1.StatefulSet, error)
- func RunCommandInPod(ctx context.Context, namespace, podName, containerName string, cmd []string) (string, error)
- func Timeout() time.Duration
- func UpdateDaemonSet(namespace, name string, labels map[string]string, ...) (*appv1.DaemonSet, error)
- type ContainerConfig
- type File
- type PodConfig
- type StatefulSetConfig
- type Volume
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigMapExists ¶ added in v0.9.0
ConfigMapExists checks if a configmap exists
func CreateConfigMap ¶ added in v0.9.0
func CreateConfigMap( namespace, name string, labels, data map[string]string, ) (*v1.ConfigMap, error)
CreateConfigMap creates a configmap
func CreateDaemonSet ¶ added in v0.7.0
func CreateDaemonSet( namespace, name string, labels map[string]string, initContainers []v1.Container, containers []v1.Container, ) (*appv1.DaemonSet, error)
CreateDaemonSet creates a new daemonset.
func CreateNetworkPolicy ¶ added in v0.7.0
func CreateNetworkPolicy( namespace, name string, selectorMap, ingressSelectorMap, egressSelectorMap map[string]string, ) error
CreateNetworkPolicy creates a new NetworkPolicy resource.
func CreateRole ¶ added in v0.8.2
func CreateRole( namespace, name string, labels map[string]string, policyRules []rbacv1.PolicyRule, ) error
CreateRole creates a role
func CreateRoleBinding ¶ added in v0.8.2
func CreateRoleBinding( namespace, name string, labels map[string]string, role, serviceAccount string, ) error
CreateRoleBinding creates a roleBinding
func CreateServiceAccount ¶ added in v0.8.2
CreateServiceAccount creates a service account
func DaemonSetExists ¶ added in v0.7.0
DaemonSetExists checks if a daemonset exists.
func DeleteConfigMap ¶ added in v0.9.0
DeleteConfigMap deletes a configmap
func DeleteDaemonSet ¶ added in v0.7.0
DeleteDaemonSet deletes an existing daemonset.
func DeleteNetworkPolicy ¶ added in v0.7.0
DeleteNetworkPolicy removes a NetworkPolicy resource.
func DeletePersistentVolumeClaim ¶
func DeletePersistentVolumeClaim(namespace, name string)
DeletePersistentVolumeClaim deletes the PersistentVolumeClaim with the specified name in the specified namespace.
func DeletePodWithGracePeriod ¶ added in v0.7.0
DeletePodWithGracePeriod deletes a pod with the given name in the specified namespace.
func DeleteRole ¶ added in v0.8.2
DeleteRole deletes a role
func DeleteRoleBinding ¶ added in v0.8.2
DeleteRoleBinding deletes a roleBinding
func DeleteService ¶
DeleteService deletes a service if it exists.
func DeleteServiceAccount ¶ added in v0.8.2
DeleteServiceAccount deletes a service account
func DeleteStatefulSet ¶ added in v0.8.2
DeleteStatefulSet deletes a statefulSet with the given name in the specified namespace.
func DeleteStatefulSetWithGracePeriod ¶ added in v0.8.2
DeleteStatefulSetWithGracePeriod deletes a statefulSet with the given name in the specified namespace.
func DeployPersistentVolumeClaim ¶
func DeployPersistentVolumeClaim(namespace, name string, labels map[string]string, size resource.Quantity)
DeployPersistentVolumeClaim creates a new PersistentVolumeClaim in the specified namespace.
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 DeployStatefulSet ¶ added in v0.8.2
func DeployStatefulSet(statefulSetConfig StatefulSetConfig, init bool) (*appv1.StatefulSet, error)
DeployStatefulSet creates a new statefulSet in the given namespace if it doesn't already exist.
func GetConfigMap ¶ added in v0.9.0
GetConfigMap retrieves a configmap
func GetDaemonSet ¶ added in v0.7.0
GetDaemonSet retrieves a daemonset.
func GetFirstPodFromStatefulSet ¶ added in v0.8.2
GetFirstPod returns the first pod of a statefulset.
func GetNetworkPolicy ¶ added in v0.9.0
func GetNetworkPolicy(namespace string, name string) (*v1.NetworkPolicy, error)
GetNetworkPolicy retrieves a NetworkPolicy resource.
func GetService ¶
GetService retrieves a service.
func GetServiceIP ¶
GetServiceIP retrieves the IP address of a service.
func Initialize ¶
func Initialize() error
Initialize sets up the Kubernetes client with the appropriate configuration.
func IsInitialized ¶ added in v0.7.0
func IsInitialized() bool
IsInitialized checks if the Kubernetes clientset has been initialized.
func IsPodRunning ¶ added in v0.7.0
IsPodRunning returns true if all containers in the pod are running.
func IsStatefulSetRunning ¶ added in v0.8.2
IsStatefulSetRunning returns true if the statefulSet is running.
func NetworkPolicyExists ¶ added in v0.9.0
NetworkPolicyExists checks if a NetworkPolicy resource exists.
func PatchService ¶
func PatchService( namespace, name string, labels, selectorMap map[string]string, portsTCP, portsUDP []int, ) error
PatchService patches an existing service.
func PortForwardPod ¶ added in v0.5.0
PortForwardPod forwards a local port to a port on a pod.
func ReplacePod ¶
ReplacePod replaces a pod in the given namespace and returns the new Pod object.
func ReplacePodWithGracePeriod ¶ added in v0.7.0
ReplacePodWithGracePeriod replaces a pod in the given namespace and returns the new Pod object with a grace period.
func ReplaceStatefulSet ¶ added in v0.8.2
func ReplaceStatefulSet(statefulSetConfig StatefulSetConfig) (*appv1.StatefulSet, error)
ReplaceStatefulSet replaces a statefulSet in the given namespace and returns the new StatefulSet object.
func ReplaceStatefulSetWithGracePeriod ¶ added in v0.8.2
func ReplaceStatefulSetWithGracePeriod(statefulSetConfig StatefulSetConfig, gracePeriod *int64) (*appv1.StatefulSet, error)
ReplaceStatefulSetWithGracePeriod replaces a statefulSet in the given namespace and returns the new statefulSet object with a grace period.
Types ¶
type ContainerConfig ¶ added in v0.9.0
type ContainerConfig struct { Name string // Name to assign to the Container Image string // Name of the container 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 []*Volume // Volumes to mount in the Pod MemoryRequest string // Memory request for the container MemoryLimit string // Memory limit for the container CPURequest string // CPU request for the container LivenessProbe *v1.Probe // Liveness probe for the container ReadinessProbe *v1.Probe // Readiness probe for the container StartupProbe *v1.Probe // Startup probe for the container Files []*File // Files to add to the Pod SecurityContext *v1.SecurityContext // Security context for the container }
ContainerConfig contains the specifications for creating a new Container object
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 ServiceAccountName string // ServiceAccount to assign to Pod FsGroup int64 // FSGroup to apply to the Pod ContainerConfig ContainerConfig // ContainerConfig for the Pod SidecarConfigs []ContainerConfig // SideCarConfigs for the Pod }
PodConfig contains the specifications for creating a new Pod object
type StatefulSetConfig ¶ added in v0.8.2
type StatefulSetConfig struct { Name string // Name of the statefulSet Namespace string // Namespace of the statefulSet Labels map[string]string // Labels to apply to the statefulSet Replicas int32 // Number of replicas PodConfig PodConfig // Pod configuration }
StatefulSetConfig contains the specifications for creating a new StatefulSet object