k8sutils

package
v0.0.0-...-afde5b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CordonAndDrainNode

func CordonAndDrainNode(ctx context.Context, clientset *kubernetes.Clientset, node *v1.Node) bool

func CordonNode

func CordonNode(ctx context.Context, clientset *kubernetes.Clientset, node *v1.Node, cordon bool) error

func DeleteNodeViaRancher

func DeleteNodeViaRancher(ctx context.Context, clientset *kubernetes.Clientset, nodeName string) bool

DeleteNodeViaRancher deletes a node from the Rancher managed cluster based on the node name.

func DrainNode

func DrainNode(ctx context.Context, clientset *kubernetes.Clientset, node *v1.Node) error

func GenerateKubeconfig

func GenerateKubeconfig(ctx context.Context, clusterID string) (string, error)

GenerateKubeconfig creates a kubeconfig for a specified cluster and returns it as a string.

func GetClusterID

func GetClusterID() (string, error)

GetClusterID fetches the cluster ID for a given cluster name from Rancher.

func GetConfig

func GetConfig(ctx context.Context) (*rest.Config, error)

GetConfig retrieves the Kubernetes configuration from Rancher

func HardRebootViaHarvester

func HardRebootViaHarvester(ctx context.Context, clientset *kubernetes.Clientset, nodeName string) bool

HardRebootViaHarvester reboots a virtual machine managed by Harvester via an API call.

func IsNewNode

func IsNewNode(node *v1.Node) bool

IsNewNode checks if a node is considered "new" based on a configurable age threshold.

func IsNodeReady

func IsNodeReady(ctx context.Context, clientset *kubernetes.Clientset, nodeName string) (bool, error)

IsNodeReady checks if the node is in a ready state.

func SshAndRebootNode

func SshAndRebootNode(ctx context.Context, clientset *kubernetes.Clientset, nodeName string) bool

SshAndRebootNode reboots a node by SSHing into it and running the reboot command.

func UncordonNode

func UncordonNode(ctx context.Context, clientset *kubernetes.Clientset, node *v1.Node) error

uncordonNode uncordons the given node.

func WaitForNodeRecovery

func WaitForNodeRecovery(ctx context.Context, clientset *kubernetes.Clientset, node *v1.Node) bool

WaitForNodeRecovery waits for a node to recover within the specified duration.

Types

type Machine

type Machine struct {
	Metadata struct {
		Name string `json:"name"`
	} `json:"metadata"`
	Spec struct {
		InfrastructureRef struct {
			Name string `json:"name"`
		} `json:"infrastructureRef"`
	} `json:"spec"`
}

Machine represents a single machine in the Rancher API response

type MachineList

type MachineList struct {
	Data []Machine `json:"data"`
}

MachineList represents the list of machines fetched from the Rancher API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳