Documentation ¶
Overview ¶
Package k8s provides utility functions for working with Kubernetes clusters.
Package k8s provides utility functions for working with Kubernetes clusters.
Index ¶
- Constants
- Variables
- func SanitizeName(name string) string
- type Client
- func (c *Client) AllPodsStatuses(ctx context.Context) ([]PodStatus, error)
- func (c *Client) Clientset() kubernetes.Interface
- func (c *Client) ConfigMapExists(ctx context.Context, name string) (bool, error)
- func (c *Client) CreateClusterRole(ctx context.Context, name string, labels map[string]string, ...) error
- func (c *Client) CreateClusterRoleBinding(ctx context.Context, name string, labels map[string]string, ...) error
- func (c *Client) CreateConfigMap(ctx context.Context, name string, labels, data map[string]string) (*v1.ConfigMap, error)
- func (c *Client) CreateCustomResource(ctx context.Context, name string, gvr *schema.GroupVersionResource, ...) error
- func (c *Client) CreateDaemonSet(ctx context.Context, name string, labels map[string]string, ...) (*appv1.DaemonSet, error)
- func (c *Client) CreateNamespace(ctx context.Context, name string) error
- func (c *Client) CreateNetworkPolicy(ctx context.Context, name string, ...) error
- func (c *Client) CreateOrUpdateConfigMap(ctx context.Context, name string, labels, data map[string]string) (*v1.ConfigMap, error)
- func (c *Client) CreatePersistentVolumeClaim(ctx context.Context, name string, labels map[string]string, ...) error
- func (c *Client) CreateReplicaSet(ctx context.Context, rsConfig ReplicaSetConfig, init bool) (*appv1.ReplicaSet, error)
- func (c *Client) CreateRole(ctx context.Context, name string, labels map[string]string, ...) error
- func (c *Client) CreateRoleBinding(ctx context.Context, name string, labels map[string]string, ...) error
- func (c *Client) CreateService(ctx context.Context, name string, labels, selectorMap map[string]string, ...) (*v1.Service, error)
- func (c *Client) CreateServiceAccount(ctx context.Context, name string, labels map[string]string) error
- func (c *Client) CustomResourceDefinitionExists(ctx context.Context, gvr *schema.GroupVersionResource) (bool, error)
- func (c *Client) DaemonSetExists(ctx context.Context, name string) (bool, error)
- func (c *Client) DeleteClusterRole(ctx context.Context, name string) error
- func (c *Client) DeleteClusterRoleBinding(ctx context.Context, name string) error
- func (c *Client) DeleteConfigMap(ctx context.Context, name string) error
- func (c *Client) DeleteDaemonSet(ctx context.Context, name string) error
- func (c *Client) DeleteNamespace(ctx context.Context, name string) error
- func (c *Client) DeleteNetworkPolicy(ctx context.Context, name string) error
- func (c *Client) DeletePersistentVolumeClaim(ctx context.Context, name string) error
- func (c *Client) DeletePod(ctx context.Context, name string) error
- func (c *Client) DeletePodWithGracePeriod(ctx context.Context, name string, gracePeriodSeconds *int64) error
- func (c *Client) DeleteReplicaSet(ctx context.Context, name string) error
- func (c *Client) DeleteReplicaSetWithGracePeriod(ctx context.Context, name string, gracePeriodSeconds *int64) error
- func (c *Client) DeleteRole(ctx context.Context, name string) error
- func (c *Client) DeleteRoleBinding(ctx context.Context, name string) error
- func (c *Client) DeleteService(ctx context.Context, name string) error
- func (c *Client) DeleteServiceAccount(ctx context.Context, name string) error
- func (c *Client) DeployPod(ctx context.Context, podConfig PodConfig, init bool) (*v1.Pod, error)
- func (c *Client) DiscoveryClient() discovery.DiscoveryInterface
- func (c *Client) DynamicClient() dynamic.Interface
- func (c *Client) GetConfigMap(ctx context.Context, name string) (*v1.ConfigMap, error)
- func (c *Client) GetDaemonSet(ctx context.Context, name string) (*appv1.DaemonSet, error)
- func (c *Client) GetFirstPodFromReplicaSet(ctx context.Context, name string) (*v1.Pod, error)
- func (c *Client) GetLogStream(ctx context.Context, replicaSetName string, containerName string) (io.ReadCloser, error)
- func (c *Client) GetNamespace(ctx context.Context, name string) (*corev1.Namespace, error)
- func (c *Client) GetNetworkPolicy(ctx context.Context, name string) (*v1.NetworkPolicy, error)
- func (c *Client) GetService(ctx context.Context, name string) (*v1.Service, error)
- func (c *Client) GetServiceEndpoint(ctx context.Context, name string) (string, error)
- func (c *Client) GetServiceIP(ctx context.Context, name string) (string, error)
- func (c *Client) IsPodRunning(ctx context.Context, name string) (bool, error)
- func (c *Client) IsReplicaSetRunning(ctx context.Context, name string) (bool, error)
- func (c *Client) Namespace() string
- func (c *Client) NamespaceExists(ctx context.Context, name string) (bool, error)
- func (c *Client) NetworkPolicyExists(ctx context.Context, name string) bool
- func (c *Client) NewFile(source, dest string) *File
- func (c *Client) NewVolume(path string, size resource.Quantity, owner int64) *Volume
- func (c *Client) PatchService(ctx context.Context, name string, labels, selectorMap map[string]string, ...) (*v1.Service, error)
- func (c *Client) PodStatus(ctx context.Context, name string) (PodStatus, error)
- func (c *Client) PortForwardPod(ctx context.Context, podName string, localPort, remotePort int) error
- func (c *Client) PrintAllPodsStatuses(ctx context.Context) error
- func (c *Client) ReplacePod(ctx context.Context, podConfig PodConfig) (*v1.Pod, error)
- func (c *Client) ReplacePodWithGracePeriod(ctx context.Context, podConfig PodConfig, gracePeriod *int64) (*v1.Pod, error)
- func (c *Client) ReplaceReplicaSet(ctx context.Context, ReplicaSetConfig ReplicaSetConfig) (*appv1.ReplicaSet, error)
- func (c *Client) ReplaceReplicaSetWithGracePeriod(ctx context.Context, ReplicaSetConfig ReplicaSetConfig, gracePeriod *int64) (*appv1.ReplicaSet, error)
- func (c *Client) ReplicaSetExists(ctx context.Context, name string) (bool, error)
- func (c *Client) RunCommandInPod(ctx context.Context, podName, containerName string, cmd []string) (string, error)
- func (c *Client) SetMaxPendingDuration(duration time.Duration)
- func (c *Client) Terminate()
- func (c *Client) UpdateConfigMap(ctx context.Context, name string, labels, data map[string]string) (*v1.ConfigMap, error)
- func (c *Client) UpdateDaemonSet(ctx context.Context, name string, labels map[string]string, ...) (*appv1.DaemonSet, error)
- func (c *Client) WaitForDeployment(ctx context.Context, name string) error
- func (c *Client) WaitForService(ctx context.Context, name string) error
- type ContainerConfig
- type Error
- type File
- type KubeManager
- type PodConfig
- type PodStatus
- type ReplicaSetConfig
- type Volume
Constants ¶
const ( // CustomQPS is the QPS to use for the Kubernetes client, DefaultQPS: 5 CustomQPS = 100 // CustomBurst is the Burst to use for the Kubernetes client, DefaultBurst: 10. CustomBurst = 200 )
Variables ¶
var ( ErrKnuuNotInitialized = errors.New("KnuuNotInitialized", "knuu is not initialized") ErrGettingConfigmap = errors.New("ErrorGettingConfigmap", "error getting configmap %s") ErrConfigmapAlreadyExists = errors.New("ConfigmapAlreadyExists", "configmap %s already exists") ErrCreatingConfigmap = errors.New("ErrorCreatingConfigmap", "error creating configmap %s") ErrConfigmapDoesNotExist = errors.New("ConfigmapDoesNotExist", "configmap %s does not exist") ErrDeletingConfigmap = errors.New("ErrorDeletingConfigmap", "error deleting configmap %s") ErrGettingDaemonset = errors.New("ErrorGettingDaemonset", "error getting daemonset %s") ErrCreatingDaemonset = errors.New("ErrorCreatingDaemonset", "error creating daemonset %s") ErrUpdatingDaemonset = errors.New("ErrorUpdatingDaemonset", "error updating daemonset %s") ErrDeletingDaemonset = errors.New("ErrorDeletingDaemonset", "error deleting daemonset %s") ErrCreatingNamespace = errors.New("ErrorCreatingNamespace", "error creating namespace %s") ErrDeletingNamespace = errors.New("ErrorDeletingNamespace", "error deleting namespace %s") ErrGettingNamespace = errors.New("ErrorGettingNamespace", "error getting namespace %s") ErrCreatingNetworkPolicy = errors.New("ErrorCreatingNetworkPolicy", "error creating network policy %s") ErrDeletingNetworkPolicy = errors.New("ErrorDeletingNetworkPolicy", "error deleting network policy %s") ErrGettingNetworkPolicy = errors.New("ErrorGettingNetworkPolicy", "error getting network policy %s") ErrGettingPod = errors.New("ErrorGettingPod", "failed to get pod %s") ErrPreparingPod = errors.New("ErrorPreparingPod", "error preparing pod") ErrCreatingPod = errors.New("ErrorCreatingPod", "failed to create pod") ErrDeletingPod = errors.New("ErrorDeletingPod", "failed to delete pod") ErrDeployingPod = errors.New("ErrorDeployingPod", "failed to deploy pod") ErrGettingK8sConfig = errors.New("ErrorGettingK8sConfig", "failed to get k8s config") ErrCreatingExecutor = errors.New("ErrorCreatingExecutor", "failed to create Executor") ErrExecutingCommand = errors.New("ErrorExecutingCommand", "failed to execute command, stdout: `%v`, stderr: `%v`") ErrCommandExecution = errors.New("ErrorCommandExecution", "error while executing command") ErrDeletingPodFailed = errors.New("ErrorDeletingPodFailed", "failed to delete pod %s") ErrParsingMemoryRequest = errors.New("ErrorParsingMemoryRequest", "failed to parse memory request quantity '%s'") ErrParsingMemoryLimit = errors.New("ErrorParsingMemoryLimit", "failed to parse memory limit quantity '%s'") ErrParsingCPURequest = errors.New("ErrorParsingCPURequest", "failed to parse CPU request quantity '%s'") ErrBuildingContainerVolumes = errors.New("ErrorBuildingContainerVolumes", "failed to build container volumes") ErrBuildingResources = errors.New("ErrorBuildingResources", "failed to build resources") ErrBuildingInitContainerVolumes = errors.New("ErrorBuildingInitContainerVolumes", "failed to build init container volumes") ErrBuildingInitContainerCommand = errors.New("ErrorBuildingInitContainerCommand", "failed to build init container command") ErrBuildingPodVolumes = errors.New("ErrorBuildingPodVolumes", "failed to build pod volumes") ErrPreparingMainContainer = errors.New("ErrorPreparingMainContainer", "failed to prepare main container") ErrPreparingInitContainer = errors.New("ErrorPreparingInitContainer", "failed to prepare init container") ErrPreparingPodVolumes = errors.New("ErrorPreparingPodVolumes", "failed to prepare pod volumes") ErrPreparingSidecarContainer = errors.New("ErrorPreparingSidecarContainer", "failed to prepare sidecar container") ErrPreparingSidecarVolumes = errors.New("ErrorPreparingSidecarVolumes", "failed to prepare sidecar volumes") ErrCreatingPodSpec = errors.New("ErrorCreatingPodSpec", "failed to create pod spec") ErrGettingClusterConfig = errors.New("ErrorGettingClusterConfig", "failed to get cluster config") ErrCreatingRoundTripper = errors.New("ErrorCreatingRoundTripper", "failed to create round tripper") ErrCreatingPortForwarder = errors.New("ErrorCreatingPortForwarder", "failed to create port forwarder") ErrPortForwarding = errors.New("ErrorPortForwarding", "failed to port forward: %v") ErrForwardingPorts = errors.New("ErrorForwardingPorts", "error forwarding ports") ErrPortForwardingTimeout = errors.New("ErrorPortForwardingTimeout", "timed out waiting for port forwarding to be ready") ErrDeletingPersistentVolumeClaim = errors.New("ErrorDeletingPersistentVolumeClaim", "error deleting PersistentVolumeClaim %s") ErrCreatingPersistentVolumeClaim = errors.New("ErrorCreatingPersistentVolumeClaim", "error creating PersistentVolumeClaim") ErrGettingReplicaSet = errors.New("ErrorGettingReplicaSet", "failed to get ReplicaSet %s") ErrCreatingReplicaSet = errors.New("ErrorCreatingReplicaSet", "failed to create ReplicaSet") ErrDeletingReplicaSet = errors.New("ErrorDeletingReplicaSet", "failed to delete ReplicaSet %s") ErrCheckingReplicaSetExists = errors.New("ErrorCheckingReplicaSetExists", "failed to check if ReplicaSet %s exists") ErrWaitingForReplicaSet = errors.New("ErrorWaitingForReplicaSet", "error waiting for ReplicaSet to delete") ErrDeployingReplicaSet = errors.New("ErrorDeployingReplicaSet", "failed to deploy ReplicaSet") ErrPreparingPodSpec = errors.New("ErrorPreparingPodSpec", "failed to prepare pod spec") ErrListingPodsForReplicaSet = errors.New("ErrorListingPodsForReplicaSet", "failed to list pods for ReplicaSet %s") ErrNoPodsForReplicaSet = errors.New("NoPodsForReplicaSet", "no pods found for ReplicaSet %s") ErrGettingService = errors.New("ErrorGettingService", "error getting service %s") ErrPreparingService = errors.New("ErrorPreparingService", "error preparing service %s") ErrCreatingService = errors.New("ErrorCreatingService", "error creating service %s") ErrPatchingService = errors.New("ErrorPatchingService", "error patching service %s") ErrDeletingService = errors.New("ErrorDeletingService", "error deleting service %s") ErrNamespaceRequired = errors.New("NamespaceRequired", "namespace is required") ErrServiceNameRequired = errors.New("ServiceNameRequired", "service name is required") ErrNoPortsSpecified = errors.New("NoPortsSpecified", "no ports specified for service %s") ErrRetrievingKubernetesConfig = errors.New("RetrievingKubernetesConfig", "retrieving the Kubernetes config") ErrCreatingClientset = errors.New("CreatingClientset", "creating clientset for Kubernetes") ErrCreatingDiscoveryClient = errors.New("CreatingDiscoveryClient", "creating discovery client for Kubernetes") ErrCreatingDynamicClient = errors.New("CreatingDynamicClient", "creating dynamic client for Kubernetes") ErrGettingResourceList = errors.New("GettingResourceList", "getting resource list for group version %s") ErrResourceDoesNotExist = errors.New("ResourceDoesNotExist", "resource %s does not exist in group version %s") ErrCreatingCustomResource = errors.New("CreatingCustomResource", "creating custom resource %s") ErrCreatingRole = errors.New("CreatingRole", "creating role %s") ErrCreatingRoleBinding = errors.New("CreatingRoleBinding", "creating role binding %s") ErrCreatingRoleBindingFailed = errors.New("CreatingRoleBindingFailed", "creating role binding %s failed") ErrNodePortNotSet = errors.New("NodePortNotSet", "node port not set") ErrExternalIPsNotSet = errors.New("ExternalIPsNotSet", "external IPs not set") ErrGettingServiceEndpoint = errors.New("GettingServiceEndpoint", "getting service endpoint %s") ErrTimeoutWaitingForServiceReady = errors.New("TimeoutWaitingForServiceReady", "timed out waiting for service %s to be ready") ErrLoadBalancerIPNotAvailable = errors.New("LoadBalancerIPNotAvailable", "load balancer IP not available") ErrGettingNodes = errors.New("GettingNodes", "getting nodes") ErrNoNodesFound = errors.New("NoNodesFound", "no nodes found") ErrFailedToConnect = errors.New("FailedToConnect", "failed to connect to %s") ErrWaitingForDeployment = errors.New("WaitingForDeployment", "waiting for deployment %s to be ready") ErrClusterRoleAlreadyExists = errors.New("ClusterRoleAlreadyExists", "cluster role %s already exists") ErrClusterRoleBindingAlreadyExists = errors.New("ClusterRoleBindingAlreadyExists", "cluster role binding %s already exists") ErrCreateEndpoint = errors.New("CreateEndpoint", "failed to create endpoint for service %s") ErrGetEndpoint = errors.New("GetEndpoint", "failed to get endpoint for service %s") ErrUpdateEndpoint = errors.New("UpdateEndpoint", "failed to update endpoint for service %s") ErrCheckingServiceReady = errors.New("CheckingServiceReady", "failed to check if service %s is ready") ErrWaitingForPodDeletion = errors.New("WaitingForPodDeletion", "waiting for pod %s to be deleted") ErrWaitingForReplicaSetDeletion = errors.New("WaitingForReplicaSetDeletion", "waiting for ReplicaSet %s to be deleted") ErrInvalidNamespaceName = errors.New("InvalidNamespaceName", "invalid namespace name %s: %v") ErrInvalidConfigMapName = errors.New("InvalidConfigMapName", "invalid config map name %s: %v") ErrInvalidLabelKey = errors.New("InvalidLabelKey", "invalid label key %s: %v") ErrInvalidLabelValue = errors.New("InvalidLabelValue", "invalid label value for key %s: %v") ErrInvalidConfigMapKey = errors.New("InvalidConfigMapKey", "invalid config map key %s: %v") ErrInvalidCustomResourceName = errors.New("InvalidCustomResourceName", "invalid custom resource name %s: %v") ErrInvalidGroupVersionResource = errors.New("InvalidGroupVersionResource", "invalid group version resource, group: %s, version: %s, resource: %s") ErrCustomResourceObjectNil = errors.New("CustomResourceObjectNil", "custom resource object cannot be nil") ErrCustomResourceObjectNoSpec = errors.New("CustomResourceObjectNoSpec", "custom resource object must have a 'spec' field") ErrInvalidDaemonSetName = errors.New("InvalidDaemonSetName", "invalid DaemonSet name %s: %v") ErrInvalidContainerName = errors.New("InvalidContainerName", "invalid container name %s: %v") ErrInvalidNetworkPolicyName = errors.New("InvalidNetworkPolicyName", "invalid network policy name %s: %v") ErrInvalidPodName = errors.New("InvalidPodName", "invalid pod name %s: %v") ErrEmptyCommand = errors.New("EmptyCommand", "command cannot be empty") ErrInvalidPort = errors.New("InvalidPort", "port number %d is out of valid range (1-65535)") ErrInvalidPodAnnotationKey = errors.New("InvalidPodAnnotationKey", "invalid annotation key %s: %v") ErrAnnotationValueTooLarge = errors.New("AnnotationValueTooLarge", "annotation value for key %s exceeds maximum size. %d must be less than 253 characters") ErrContainerImageEmpty = errors.New("ContainerImageEmpty", "container image cannot be empty for container %s") ErrVolumePathEmpty = errors.New("VolumePathEmpty", "volume path cannot be empty") ErrVolumeSizeZero = errors.New("VolumeSizeZero", "volume size must be greater than zero") ErrFileSourceDestEmpty = errors.New("FileSourceDestEmpty", "file source and destination cannot be empty") ErrInvalidPVCName = errors.New("InvalidPVCName", "invalid PVC name %s: %v") ErrPVCSizeZero = errors.New("PVCSizeZero", "PVC size must be greater than zero") ErrInvalidReplicaSetName = errors.New("InvalidReplicaSetName", "invalid ReplicaSet name %s: %v") ErrReplicaSetReplicasNegative = errors.New("ReplicaSetReplicasNegative", "number of replicas cannot be negative: %d") ErrInvalidRoleName = errors.New("InvalidRoleName", "invalid role name %s: %v") ErrPolicyRuleNoVerbs = errors.New("PolicyRuleNoVerbs", "policy rule must have at least one verb") ErrPolicyRuleVerbEmpty = errors.New("PolicyRuleVerbEmpty", "verb cannot be empty") ErrPolicyRuleNoResources = errors.New("PolicyRuleNoResources", "policy rule must specify at least one resource or non-resource URL") ErrInvalidClusterRoleName = errors.New("InvalidClusterRoleName", "invalid cluster role name %s: %v") ErrInvalidRoleBindingName = errors.New("InvalidRoleBindingName", "invalid role binding name %s: %v") ErrInvalidServiceAccountName = errors.New("InvalidServiceAccountName", "invalid service account name %s: %v") ErrInvalidClusterRoleBindingName = errors.New("InvalidClusterRoleBindingName", "invalid cluster role binding name %s: %v") ErrInvalidServiceName = errors.New("InvalidServiceName", "invalid service name %s: %v") ErrClientTerminated = errors.New("ClientTerminated", "terminated by user") ErrListingPods = errors.New("ListingPods", "failed to list pods") ErrGetPodStatus = errors.New("GetPodStatus", "failed to get pod status for pod %s") ErrUpdatingConfigmap = errors.New("UpdatingConfigmap", "failed to update configmap %s") )
Functions ¶
func SanitizeName ¶ added in v0.13.2
SanitizeName ensures compliance with Kubernetes DNS-1123 subdomain names. It:
- Converts the input string to lowercase.
- Replaces underscores and any non-DNS-1123 compliant characters with hyphens.
- Trims leading and trailing hyphens.
- Ensures the name does not exceed 63 characters, trimming excess characters if necessary and ensuring it does not end with a hyphen after trimming.
Use this function to sanitize strings to be used as Kubernetes names for resources. It will panic if the sanitized name is empty.
Types ¶
type Client ¶ added in v0.13.3
type Client struct {
// contains filtered or unexported fields
}
func NewClientCustom ¶ added in v0.15.1
func (*Client) AllPodsStatuses ¶ added in v0.15.1
AllPodsStatuses reports the status of pods in the current namespace.
func (*Client) Clientset ¶ added in v0.13.3
func (c *Client) Clientset() kubernetes.Interface
func (*Client) ConfigMapExists ¶ added in v0.13.3
func (*Client) CreateClusterRole ¶ added in v0.14.0
func (*Client) CreateClusterRoleBinding ¶ added in v0.14.0
func (*Client) CreateConfigMap ¶ added in v0.13.3
func (*Client) CreateCustomResource ¶ added in v0.13.3
func (*Client) CreateDaemonSet ¶ added in v0.13.3
func (*Client) CreateNamespace ¶ added in v0.13.3
func (*Client) CreateNetworkPolicy ¶ added in v0.13.3
func (*Client) CreateOrUpdateConfigMap ¶ added in v0.16.1
func (*Client) CreatePersistentVolumeClaim ¶ added in v0.13.3
func (c *Client) CreatePersistentVolumeClaim( ctx context.Context, name string, labels map[string]string, size resource.Quantity, ) error
CreatePersistentVolumeClaim deploys a PersistentVolumeClaim if it does not exist.
func (*Client) CreateReplicaSet ¶ added in v0.13.3
func (c *Client) CreateReplicaSet(ctx context.Context, rsConfig ReplicaSetConfig, init bool) (*appv1.ReplicaSet, error)
CreateReplicaSet creates a new replicaSet in namespace that k8s is initialized with if it doesn't already exist.
func (*Client) CreateRole ¶ added in v0.13.3
func (*Client) CreateRoleBinding ¶ added in v0.13.3
func (*Client) CreateService ¶ added in v0.13.3
func (*Client) CreateServiceAccount ¶ added in v0.13.3
func (*Client) CustomResourceDefinitionExists ¶ added in v0.13.3
func (*Client) DaemonSetExists ¶ added in v0.13.3
func (*Client) DeleteClusterRole ¶ added in v0.14.0
func (*Client) DeleteClusterRoleBinding ¶ added in v0.14.0
func (*Client) DeleteConfigMap ¶ added in v0.13.3
func (*Client) DeleteDaemonSet ¶ added in v0.13.3
func (*Client) DeleteNamespace ¶ added in v0.13.3
func (*Client) DeleteNetworkPolicy ¶ added in v0.13.3
func (*Client) DeletePersistentVolumeClaim ¶ added in v0.13.3
func (*Client) DeletePodWithGracePeriod ¶ added in v0.13.3
func (*Client) DeleteReplicaSet ¶ added in v0.13.3
func (*Client) DeleteReplicaSetWithGracePeriod ¶ added in v0.13.3
func (*Client) DeleteRole ¶ added in v0.13.3
func (*Client) DeleteRoleBinding ¶ added in v0.13.3
func (*Client) DeleteService ¶ added in v0.13.3
func (*Client) DeleteServiceAccount ¶ added in v0.13.3
func (*Client) DeployPod ¶ added in v0.13.3
DeployPod creates a new pod in the namespace that k8s client is initiate with if it doesn't already exist.
func (*Client) DiscoveryClient ¶ added in v0.15.1
func (c *Client) DiscoveryClient() discovery.DiscoveryInterface
func (*Client) DynamicClient ¶ added in v0.14.0
func (*Client) GetConfigMap ¶ added in v0.13.3
func (*Client) GetDaemonSet ¶ added in v0.13.3
func (*Client) GetFirstPodFromReplicaSet ¶ added in v0.13.3
func (*Client) GetLogStream ¶ added in v0.16.1
func (*Client) GetNamespace ¶ added in v0.13.3
func (*Client) GetNetworkPolicy ¶ added in v0.13.3
func (*Client) GetService ¶ added in v0.13.3
func (*Client) GetServiceEndpoint ¶ added in v0.14.0
func (*Client) GetServiceIP ¶ added in v0.13.3
func (*Client) IsPodRunning ¶ added in v0.13.3
IsPodRunning returns true if all containers in the pod are running.
func (*Client) IsReplicaSetRunning ¶ added in v0.13.3
func (*Client) NamespaceExists ¶ added in v0.13.3
func (*Client) NetworkPolicyExists ¶ added in v0.13.3
func (*Client) PatchService ¶ added in v0.13.3
func (*Client) PortForwardPod ¶ added in v0.13.3
func (c *Client) PortForwardPod( ctx context.Context, podName string, localPort, remotePort int, ) error
PortForwardPod forwards a local port to a port on a pod.
func (*Client) PrintAllPodsStatuses ¶ added in v0.15.1
func (*Client) ReplacePod ¶ added in v0.13.3
ReplacePod replaces a pod and returns the new Pod object.
func (*Client) ReplacePodWithGracePeriod ¶ added in v0.13.3
func (*Client) ReplaceReplicaSet ¶ added in v0.13.3
func (c *Client) ReplaceReplicaSet(ctx context.Context, ReplicaSetConfig ReplicaSetConfig) (*appv1.ReplicaSet, error)
func (*Client) ReplaceReplicaSetWithGracePeriod ¶ added in v0.13.3
func (c *Client) ReplaceReplicaSetWithGracePeriod(ctx context.Context, ReplicaSetConfig ReplicaSetConfig, gracePeriod *int64) (*appv1.ReplicaSet, error)
func (*Client) ReplicaSetExists ¶ added in v0.13.3
ReplicaSetExists checks if a ReplicaSet exists in the namespace that k8s is initialized with.
func (*Client) RunCommandInPod ¶ added in v0.13.3
func (c *Client) RunCommandInPod( ctx context.Context, podName, containerName string, cmd []string, ) (string, error)
RunCommandInPod runs a command in a container within a pod with a context.
func (*Client) SetMaxPendingDuration ¶ added in v0.15.1
func (*Client) UpdateConfigMap ¶ added in v0.16.1
func (*Client) UpdateDaemonSet ¶ added in v0.13.3
func (*Client) WaitForDeployment ¶ added in v0.14.0
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 ImagePullPolicy v1.PullPolicy // Image pull policy 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 resource.Quantity // Memory request for the container MemoryLimit resource.Quantity // Memory limit for the container CPURequest resource.Quantity // 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 }
type KubeManager ¶ added in v0.14.0
type KubeManager interface { Clientset() kubernetes.Interface CreateClusterRole(ctx context.Context, name string, labels map[string]string, policyRules []rbacv1.PolicyRule) error CreateClusterRoleBinding(ctx context.Context, name string, labels map[string]string, clusterRole, serviceAccount string) error CreateConfigMap(ctx context.Context, name string, labels, data map[string]string) (*corev1.ConfigMap, error) CreateOrUpdateConfigMap(ctx context.Context, name string, labels, data map[string]string) (*corev1.ConfigMap, error) CreateCustomResource(ctx context.Context, name string, gvr *schema.GroupVersionResource, obj *map[string]interface{}) error CreateDaemonSet(ctx context.Context, name string, labels map[string]string, initContainers []corev1.Container, containers []corev1.Container) (*appv1.DaemonSet, error) CreateNamespace(ctx context.Context, name string) error CreateNetworkPolicy(ctx context.Context, name string, selectorMap, ingressSelectorMap, egressSelectorMap map[string]string) error CreatePersistentVolumeClaim(ctx context.Context, name string, labels map[string]string, size resource.Quantity) error CreateReplicaSet(ctx context.Context, rsConfig ReplicaSetConfig, init bool) (*appv1.ReplicaSet, error) CreateRole(ctx context.Context, name string, labels map[string]string, policyRules []rbacv1.PolicyRule) error CreateRoleBinding(ctx context.Context, name string, labels map[string]string, role, serviceAccount string) error CreateService(ctx context.Context, name string, labels, selectorMap map[string]string, portsTCP, portsUDP []int) (*corev1.Service, error) CreateServiceAccount(ctx context.Context, name string, labels map[string]string) error CustomResourceDefinitionExists(ctx context.Context, gvr *schema.GroupVersionResource) (bool, error) DaemonSetExists(ctx context.Context, name string) (bool, error) DeleteConfigMap(ctx context.Context, name string) error DeleteDaemonSet(ctx context.Context, name string) error DeleteNamespace(ctx context.Context, name string) error DeleteNetworkPolicy(ctx context.Context, name string) error DeletePersistentVolumeClaim(ctx context.Context, name string) error DeletePod(ctx context.Context, name string) error DeletePodWithGracePeriod(ctx context.Context, name string, gracePeriodSeconds *int64) error DeleteReplicaSet(ctx context.Context, name string) error DeleteReplicaSetWithGracePeriod(ctx context.Context, name string, gracePeriodSeconds *int64) error DeleteRole(ctx context.Context, name string) error DeleteRoleBinding(ctx context.Context, name string) error DeleteService(ctx context.Context, name string) error DeleteServiceAccount(ctx context.Context, name string) error DeployPod(ctx context.Context, podConfig PodConfig, init bool) (*corev1.Pod, error) DiscoveryClient() discovery.DiscoveryInterface DynamicClient() dynamic.Interface GetConfigMap(ctx context.Context, name string) (*corev1.ConfigMap, error) GetDaemonSet(ctx context.Context, name string) (*appv1.DaemonSet, error) GetFirstPodFromReplicaSet(ctx context.Context, name string) (*corev1.Pod, error) GetLogStream(ctx context.Context, podName string, containerName string) (io.ReadCloser, error) GetNamespace(ctx context.Context, name string) (*corev1.Namespace, error) GetNetworkPolicy(ctx context.Context, name string) (*netv1.NetworkPolicy, error) GetService(ctx context.Context, name string) (*corev1.Service, error) GetServiceEndpoint(ctx context.Context, name string) (string, error) GetServiceIP(ctx context.Context, name string) (string, error) IsPodRunning(ctx context.Context, name string) (bool, error) IsReplicaSetRunning(ctx context.Context, name string) (bool, error) Namespace() string NamespaceExists(ctx context.Context, name string) (bool, error) NetworkPolicyExists(ctx context.Context, name string) bool NewFile(source, dest string) *File NewVolume(path string, size resource.Quantity, owner int64) *Volume PatchService(ctx context.Context, name string, labels, selectorMap map[string]string, portsTCP, portsUDP []int) (*corev1.Service, error) PortForwardPod(ctx context.Context, podName string, localPort, remotePort int) error ReplicaSetExists(ctx context.Context, name string) (bool, error) ReplacePod(ctx context.Context, podConfig PodConfig) (*corev1.Pod, error) ReplacePodWithGracePeriod(ctx context.Context, podConfig PodConfig, gracePeriod *int64) (*corev1.Pod, error) ReplaceReplicaSet(ctx context.Context, ReplicaSetConfig ReplicaSetConfig) (*appv1.ReplicaSet, error) ReplaceReplicaSetWithGracePeriod(ctx context.Context, ReplicaSetConfig ReplicaSetConfig, gracePeriod *int64) (*appv1.ReplicaSet, error) RunCommandInPod(ctx context.Context, podName, containerName string, cmd []string) (string, error) ConfigMapExists(ctx context.Context, name string) (bool, error) UpdateDaemonSet(ctx context.Context, name string, labels map[string]string, initContainers []corev1.Container, containers []corev1.Container) (*appv1.DaemonSet, error) UpdateConfigMap(ctx context.Context, name string, labels, data map[string]string) (*corev1.ConfigMap, error) WaitForDeployment(ctx context.Context, name string) error WaitForService(ctx context.Context, name string) error Terminate() AllPodsStatuses(ctx context.Context) ([]PodStatus, error) PodStatus(ctx context.Context, name string) (PodStatus, error) PrintAllPodsStatuses(ctx context.Context) error }
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 Annotations map[string]string // Annotations to apply to the Pod }
type ReplicaSetConfig ¶ added in v0.12.0
type ReplicaSetConfig struct { Name string // Name of the ReplicaSet Namespace string // Namespace of the ReplicaSet Labels map[string]string // Labels to apply to the ReplicaSet, key/value represents the name/value of the label Replicas int32 // Replicas is the number of replicas PodConfig PodConfig // PodConfig represents the pod configuration }