k8sutils

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KUBE_MAJOR_VERSION string
	KUBE_MINOR_VERSION string
)

Functions

func ApplyConfigMap added in v1.8.0

func ApplyConfigMap(ctx context.Context, k8sClient client.Client, configmap *corev1.ConfigMap) error

func ApplyDeployment added in v1.8.0

func ApplyDeployment(ctx context.Context, k8sClient client.Client, deploy *appv1.Deployment) error

func ApplyService

func ApplyService(ctx context.Context, k8sClient client.Client, expectSvc *corev1.Service, equal ServiceEqual) error

func ApplyStatefulSet

func ApplyStatefulSet(ctx context.Context, k8sClient client.Client, expect *appv1.StatefulSet,
	enableScaleTo1 bool, equal StatefulSetEqual) error

ApplyStatefulSet when the object is not exist, create object. if exist and statefulset have been updated, patch the statefulset.

func CheckVolumes added in v1.9.1

func CheckVolumes(volumes []corev1.Volume, mounts []corev1.VolumeMount) error

func CreateClientObject

func CreateClientObject(ctx context.Context, k8sClient client.Client, object client.Object) error

func DeleteAutoscaler

func DeleteAutoscaler(ctx context.Context, k8sClient client.Client, namespace, name string) error

func DeleteConfigMap added in v1.8.0

func DeleteConfigMap(ctx context.Context, k8sClient client.Client, namespace, name string) error

DeleteConfigMap delete configmap.

func DeleteDeployment added in v1.8.0

func DeleteDeployment(ctx context.Context, k8sClient client.Client, namespace, name string) error

DeleteDeployment delete deployment.

func DeleteService

func DeleteService(ctx context.Context, k8sClient client.Client, namespace, name string) error

DeleteService delete service.

func DeleteStatefulset

func DeleteStatefulset(ctx context.Context, k8sClient client.Client, namespace, name string) error

DeleteStatefulset delete statefulset.

func GetConfigMap

func GetConfigMap(ctx context.Context, k8scient client.Client, namespace, name string) (*corev1.ConfigMap, error)

GetConfigMap get the configmap name=name, namespace=namespace.

func GetEnvVarValue added in v1.9.0

func GetEnvVarValue(ctx context.Context, k8sClient client.Client, namespace string, envVar corev1.EnvVar) (string, error)

GetEnvVarValue returns the value of an environment variable. It handles both Value and ValueFrom cases. It assumes that the environment variable exists and is valid.

func GetKubernetesVersion added in v1.8.1

func GetKubernetesVersion() error

GetKubernetesVersion get kubernetes version. It should not be executed concurrently. The global variable KUBE_MAJOR_VERSION and KUBE_MINOR_VERSION will be set.

func GetValueFromConfigmap added in v1.9.0

func GetValueFromConfigmap(ctx context.Context, k8sClient client.Client, namespace string, name string, key string) (string, error)

GetValueFromConfigmap returns the runtime value of a key in a configmap. It assumes that the configmap and the key exist and are valid.

func GetValueFromSecret added in v1.9.0

func GetValueFromSecret(ctx context.Context, k8sClient client.Client, namespace string, name string, key string) (string, error)

GetValueFromSecret returns the value of a key in a secret. It assumes that the secret and the key exist and are valid.

func PodIsReady

func PodIsReady(status *corev1.PodStatus) bool

func UpdateClientObject

func UpdateClientObject(ctx context.Context, k8sClient client.Client, object client.Object) error

Types

type ServiceEqual

type ServiceEqual func(expect *corev1.Service, actual *corev1.Service) bool

ServiceEqual judges two services equal or not in some fields. developer can custom the function.

type StatefulSetEqual

type StatefulSetEqual func(expect *appv1.StatefulSet, actual *appv1.StatefulSet) bool

StatefulSetEqual judges two statefulset equal or not in some fields. developer can custom the function.

Directories

Path Synopsis
templates
pod

Jump to

Keyboard shortcuts

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