kubernetes

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRbac added in v1.10.0

func CreateRbac(kubeClient *kubeclient.Clientset, namespace, name string, rbacRules []rbacv1.PolicyRule) error

CreateRbac creates a new ServiceAccount, ClusterRole, and ClusterRoleBinding. If creation fails, it attempts to clean up any partially created resources before returning the error.

func DeleteRbac added in v1.10.0

func DeleteRbac(kubeClient *kubeclient.Clientset, namespace, name string) error

DeleteRbac deletes ServiceAccount, ClusterRole, and ClusterRoleBinding

func GetDaemonSetPodCollections

func GetDaemonSetPodCollections(kubeClient *kubeclient.Clientset, daemonSet *appsv1.DaemonSet, containerName string, addPrefix, onlyFailed bool, tailLines *int64) (*types.PodCollections, error)

GetDaemonSetPodCollections retrieves the logs of the specified container within the given DaemonSet. Optionally, it can: - add prefixes to the log lines - only retrieve logs of failed containers - retrieve the last N lines of the logs

func GetHugePagesCapacity added in v1.10.0

func GetHugePagesCapacity(kubeClient *kubeclient.Clientset) (*resource.Quantity, error)

GetHugePagesCapacity returns hugepages-2Mi capacity of current node

func GetKubeConfigFromPath added in v1.12.0

func GetKubeConfigFromPath(kubeconfigPath string) (*rest.Config, error)

func MonitorDaemonSetContainer

func MonitorDaemonSetContainer(kubeClient *kubeclient.Clientset, daemonSet *appsv1.DaemonSet, containerName string, conditionFunc monitorDaemonSetContainerConditionFunc, maxConditionToleration *int) error

MonitorDaemonSetContainer monitors the specified container within the given DaemonSet until a certain condition is met. The condition is defined by the monitorDaemonSetContainerConditionFunc. Returns nil on success, or an error if the condition check fails or the timeout is reached.

func NewKubeClient added in v1.10.0

func NewKubeClient(masterUrl string, kubeconfigPath string) (kubeClient *kubeclient.Clientset, err error)

func PrepareDaemonSet added in v1.10.0

func PrepareDaemonSet(daemonSet *appsv1.DaemonSet, kubeClient *kubeclient.Clientset, nodeSelectorRaw, imagePullSecretRaw, tolerationsRaw string) (*appsv1.DaemonSet, error)

PrepareDaemonSet takes DaemonSet object and populates common fields such as NodeSelector, ImagePullSecrets and Tolerations

func WaitForDaemonSetContainersExit

func WaitForDaemonSetContainersExit(ctx context.Context, logger *logrus.Entry, kubeClient *kubeclient.Clientset, daemonSet *appsv1.DaemonSet, containerName string, maxConditionToleration *int) error

WaitForDaemonSetContainersExit waits for the containers in the given DaemonSet to exit.

func WaitForDaemonSetContainersReady

func WaitForDaemonSetContainersReady(ctx context.Context, logger *logrus.Entry, kubeClient *kubeclient.Clientset, daemonSet *appsv1.DaemonSet, containerName string, maxConditionToleration *int) error

WaitForDaemonSetContainersReady waits for the containers in the given DaemonSet to be ready.

Types

type Workload

type Workload struct {
	KubeClient *kubeclient.Clientset

	Kind      string
	Namespace string
	Name      string

	// Selector is used to filter pods.
	// For example, to filter pod with label app=foo, use the selector "app=foo".
	// For multiple selectors, use "app=foo,app=bar".
	LabelSelectors string
	// contains filtered or unexported fields
}

Workload provide functions for workloads.

func NewWorkload

func NewWorkload(kubeClient *kubeclient.Clientset, obj interface{}, kind, labelSelector string) (*Workload, error)

NewWorkload returns a new Workload.

func (*Workload) GetPodsLogByContainer

func (obj *Workload) GetPodsLogByContainer(ctx context.Context, logger *logrus.Entry, containerName string, addPrefix, onlyFailed bool, tailLines *int64) (*types.PodCollections, error)

GetPodsLogByContainer retrieves logs of the specified container. within the given pods. Optionally, it can: - add prefixes to the log lines - only retrieve logs of failed containers - retrieve the last N lines of the logs

func (*Workload) WaitForPodContainerRunning

func (obj *Workload) WaitForPodContainerRunning(ctx context.Context, containerName string) error

WaitForPodContainerRunning waits for a pod container to be running.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL