k8sutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientForTest corev1.CoreV1Interface = nil

Functions

func CheckPodReady

func CheckPodReady(name, namespace string, logger logr.Logger) bool

func CheckPolicyIsReload

func CheckPolicyIsReload(policy *GetControllerConfigPolicy) bool

func CreatePod

func CreatePod(pod *v1.Pod, logger logr.Logger) error

func DeleteConfigmap

func DeleteConfigmap(cm *corev1.ConfigMap, logger logr.Logger) error

func DeletePod

func DeletePod(name, namespace string, ctx context.Context, logger logr.Logger) error

func ExecInPod

func ExecInPod(command []string, containerName, podName, namespace string, logger logr.Logger) (string, string, error)

func ExecInPodWithTimeout

func ExecInPodWithTimeout(ctx context.Context, command []string, containerName, podName, namespace string, timeout time.Duration, logger logr.Logger) (string, string, error)

func GetClientIP

func GetClientIP(hostIP string, logger logr.Logger) (string, error)

*

  • @Description: 根据主机IP获得客户网络IP地址
  • @param hostIP
  • @param nodeClientIPList
  • @return string

func GetConfigMap

func GetConfigMap(name, namespace string, logger logr.Logger) (*corev1.ConfigMap, error)

func GetCorev1Client

func GetCorev1Client() (corev1.CoreV1Interface, error)

func GetDynamicClient

func GetDynamicClient(group, version, resource string) (dynamic.NamespaceableResourceInterface, error)

GetDynamicClient ...

func GetHostIP

func GetHostIP(clientIP string, logger logr.Logger) (string, error)

*

  • @Description: 根据ClientIP获取HostIP
  • @param hostIP
  • @param nodeClientIPList
  • @return string

func GetKubeClient

func GetKubeClient() (*kubernetes.Clientset, *rest.Config, error)

GetKubeClient ...

func GetKubeConfig

func GetKubeConfig() (*rest.Config, error)

GetKubeConfig ...

func GetNode

func GetNode(nodeName string, logger logr.Logger) (*v1.Node, error)

func GetNodeCondition

func GetNodeCondition(node *corev1.Node, conditionType corev1.NodeConditionType) *corev1.NodeCondition

func GetNodes

func GetNodes(logger logr.Logger) ([]v1.Node, error)

func GetPod

func GetPod(name, namespace string, logger logr.Logger) (*v1.Pod, error)

func GetPodContainerInfo

func GetPodContainerInfo(pod *corev1.Pod, logger logr.Logger) string

func GetPodWatchResourceVersion

func GetPodWatchResourceVersion(name string, namespace string, client corev1client.CoreV1Interface, logger logr.Logger) string

func GetPodWatcher

func GetPodWatcher(pod *corev1.Pod, client corev1client.CoreV1Interface, timeout int64, logger logr.Logger) (watch.Interface, error)

func GetPodsByLabel

func GetPodsByLabel(labelStr, namespace string, logger logr.Logger) (*v1.PodList, error)

func GetService

func GetService(name string, namespace string, logger logr.Logger) (*corev1.Service, error)

func GetServiceByLabel

func GetServiceByLabel(labelStr string, namespace string, logger logr.Logger) (*corev1.ServiceList, error)

func IsNodeReady

func IsNodeReady(node *v1.Node) bool

func IsPodSchedulerFailed

func IsPodSchedulerFailed(cond *corev1.PodCondition) bool

func SetWatchOption

func SetWatchOption(object metav1.ObjectMeta, timeout int64) *metav1.ListOptions

func StringOfCondition

func StringOfCondition(condition *corev1.NodeCondition) string

func StringOfPodCondition

func StringOfPodCondition(condition *corev1.PodCondition) string

func UpdateConfigMap

func UpdateConfigMap(configMap *corev1.ConfigMap) error

func WaitForContainerReady

func WaitForContainerReady(pod *corev1.Pod, containerName string, ctx context.Context, logger logr.Logger) (*corev1.Pod, error)

func WaitForPodDeleted

func WaitForPodDeleted(namespace, name string, ctx context.Context, logger logr.Logger) error

func WaitForPodReady

func WaitForPodReady(pod *corev1.Pod, isNewPod bool, ctx context.Context, logger logr.Logger) (*corev1.Pod, error)

Types

type ControllerConfig

type ControllerConfig struct {
	DisableSanCmd                bool
	HybridDeployment             bool
	CmHybridDeployment           bool
	CanUpdateNotChangeableParams bool // 是否可以更新不可变参数
	CowSnapshotSupport           bool
	EnableOnlinePromote          bool
	EnableVip                    bool
	EnablePodGc                  bool
	EnableCheckSum               bool
	EnableDegrade                bool
	EnableRedline                bool
	DegradeDaemonSet             []string
	DegradeDeployment            []string
	DisabledWfEvents             []string
	SshUser                      string
	SshPassword                  string
	ControllerNodeLabel          string
}

func GetControllerConfig

func GetControllerConfig(logger logr.Logger) (*ControllerConfig, error)

func GetControllerConfigWithPolicy

func GetControllerConfigWithPolicy(policy *GetControllerConfigPolicy, logger logr.Logger) (*ControllerConfig, error)

type GetControllerConfigPolicy

type GetControllerConfigPolicy struct {
	IsInited         bool
	LastQueryTime    *time.Time
	MaxQueryStepTime *time.Duration    //如果值为0表示只读一次,此值设置原则上不允许修改,否则会逻辑错乱
	LastValue        *ControllerConfig //最后一次结果暂存器
}
var ControllerConfigPolicy *GetControllerConfigPolicy

type NodeClientIP

type NodeClientIP struct {
	NodeName string
	ClientIP string
	HostIP   string
}

func GetNodeClientIPList

func GetNodeClientIPList(logger logr.Logger) ([]*NodeClientIP, error)

*

  • @Description: 获得所有节点的客户网络IP
  • @return []*NodeClientIP
  • @return error

Jump to

Keyboard shortcuts

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