Documentation ¶
Overview ¶
Package k8s provides functionality to orchestrate the deployment, scaling, and monitoring of Kubernetes resources as part of the k8s-autoscaler-benchmarker project.
Index ¶
- func CheckNodeGroupEmpty(clientset kubernetes.Interface, labelSelector string) (bool, error)
- func DeleteDeployment(clientset kubernetes.Interface, deploymentName, namespace string) error
- func GenerateDeployment(clientset kubernetes.Interface, ...) error
- func MonitorInstanceRegistration(clientset *kubernetes.Clientset, labelSelector string, expectedNodeCount int) (time.Duration, error)
- func MonitorNodeDeregistration(clientset *kubernetes.Clientset, nodeSelectorKey, nodeSelectorValue string, ...)
- func MonitorNodeTermination(ec2Svc *ec2.EC2, tagKey, tagValue string, termChan chan<- time.Duration, ...)
- func ScaleDeployment(clientset kubernetes.Interface, deploymentName, namespace string, replicas int) error
- func WaitForPodsReady(clientset kubernetes.Interface, deploymentName, namespace string, replicas int) (time.Duration, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNodeGroupEmpty ¶
func CheckNodeGroupEmpty(clientset kubernetes.Interface, labelSelector string) (bool, error)
CheckNodeGroupEmpty checks whether a specified node group within a Kubernetes cluster has any nodes. It returns true if the node group is empty, and false otherwise. This check is useful for ensuring that a node group can be safely manipulated without affecting any existing nodes within it.
func DeleteDeployment ¶
func DeleteDeployment(clientset kubernetes.Interface, deploymentName, namespace string) error
DeleteDeployment removes a specified deployment from a given namespace. It ensures the deployment is deleted according to the specified deletion policy and logs the deletion status.
func GenerateDeployment ¶
func GenerateDeployment(clientset kubernetes.Interface, deploymentName, namespace, containerName, containerImage, cpuRequest, tolerationKey, tolerationValue, nodeSelectorKey, nodeSelectorValue string, replicas int) error
GenerateDeployment creates a new Kubernetes deployment using specified parameters, including deployment name, namespace, and container configuration. It sets up tolerations and node selectors for the deployment and logs the creation status.
func MonitorInstanceRegistration ¶
func MonitorInstanceRegistration(clientset *kubernetes.Clientset, labelSelector string, expectedNodeCount int) (time.Duration, error)
MonitorInstanceRegistration monitors the registration of instances as nodes in the Kubernetes API. It waits until nodes with the specified tag key and value appear in the Kubernetes cluster and become ready. The function returns the duration it took for the nodes to become ready for scheduling pods.
func MonitorNodeDeregistration ¶
func MonitorNodeDeregistration(clientset *kubernetes.Clientset, nodeSelectorKey, nodeSelectorValue string, deregChan chan<- time.Duration, deregErrChan chan<- error)
MonitorNodeDeregistration observes the deregistration of nodes from the Kubernetes API based on label selectors. It continuously checks and logs the registered nodes until none are left, signaling complete deregistration.
func MonitorNodeTermination ¶
func MonitorNodeTermination(ec2Svc *ec2.EC2, tagKey, tagValue string, termChan chan<- time.Duration, termErrChan chan<- error)
MonitorNodeTermination keeps an eye on the termination process of EC2 instances, ensuring all tagged instances are terminated. It logs the status of running instances and waits until no tagged instances are left running.
func ScaleDeployment ¶
func ScaleDeployment(clientset kubernetes.Interface, deploymentName, namespace string, replicas int) error
ScaleDeployment updates the number of replicas for a specified deployment within a given namespace. It first retrieves the current deployment settings, then updates the replica count based on the input parameter. The function logs whether the deployment was scaled up, down, or remained unchanged.
func WaitForPodsReady ¶
func WaitForPodsReady(clientset kubernetes.Interface, deploymentName, namespace string, replicas int) (time.Duration, error)
WaitForPodsReady waits until all pods in a deployment reach a 'Ready' state. It periodically checks the deployment's status and logs the current count of ready pods against the total number of replicas until all pods are ready.
Types ¶
This section is empty.