k8s

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelKeyInstance        = "app.kubernetes.io/instance"
	LabelKeyApp             = "app"
	ServicePP               = "app.karmada.io/service-pp"
	ConfigMapPP             = "app.karmada.io/configmap-pp"
	CustomConfigMapPP       = "app.karmada.io/custom-configmap-pp"
	Mongo                   = "app.fedstate.io/mongo"
	Arbiter                 = "app.arbiter.io/instance"
	Init                    = "app.mongoinit.io/instance"
	ClusterVip              = "app.mongoclustervip.io/instance"
	LabelClusterVipInstance = "app.multicloudmongodb.io/vip"
)
View Source
const (
	DefaultPort        = 27017
	DefaultServiceName = "mongo"
)

Variables

This section is empty.

Functions

func BaseLabel

func BaseLabel(additionalLabels map[string]string, name string) map[string]string

func CreateObject

func CreateObject(cli client.Client, obj interface{}) error

func DeleteObj

func DeleteObj(cli client.Client, obj client.Object) error

func DeleteObjByLabel

func DeleteObjByLabel(cli client.Client, obj client.Object, label map[string]string, namespace string) error

func DeleteSts

func DeleteSts(cli client.Client, namespace string, name string) error

删除指定statefulset

func DeleteStsByLabel

func DeleteStsByLabel(cli client.Client, namespace string, selector map[string]string) error

根据labels删除statefulset

func EnsureConfigMapUpdate

func EnsureConfigMapUpdate(cli client.Client, cr *middlewarev1alpha1.MultiCloudMongoDB, Scheme *runtime.Scheme, obj metav1.Object, found client.Object) error

func EnsureMongoWithoutSetRef

func EnsureMongoWithoutSetRef(cli client.Client, obj metav1.Object, found client.Object) error

func EnsureWithoutSetRef

func EnsureWithoutSetRef(cli client.Client, obj metav1.Object, found client.Object) error

func ExecCmd

func ExecCmd(config *rest.Config, pod *corev1.Pod, containerName string, command string) (string, string, error)

func GenerateArbiterLabel

func GenerateArbiterLabel(additionalLabels map[string]string, serviceName string) map[string]string

func GenerateArbiterService

func GenerateArbiterService(name, namespace string, labels, selector map[string]string, headless bool) *corev1.Service

func GenerateArbiterServicePPLabel

func GenerateArbiterServicePPLabel(name string) map[string]string

func GenerateClusterVIPLabel

func GenerateClusterVIPLabel(vip string) map[string]string

func GenerateClusterVipLabel

func GenerateClusterVipLabel(additionalLabels map[string]string, name string) map[string]string

func GenerateConfigMap

func GenerateConfigMap(name, namespace string, labels map[string]string, hostConf *model.HostConf) *corev1.ConfigMap

func GenerateConfigMapLabel

func GenerateConfigMapLabel(additionalLabels map[string]string, name string) map[string]string

func GenerateConfigMapPPLabel

func GenerateConfigMapPPLabel(additionalLabels map[string]string, name string) map[string]string

func GenerateCustomConfigMapPPLabel

func GenerateCustomConfigMapPPLabel(additionalLabels map[string]string, name string) map[string]string

func GenerateInitLabel

func GenerateInitLabel(additionalLabels map[string]string, name string) map[string]string

func GenerateMongo

func GenerateMongo(name, namespace string,
	labels map[string]string,
	cr *middlewarev1alpha1.MultiCloudMongoDB) *middlewarev1alpha1.MongoDB

func GenerateMongoLabel

func GenerateMongoLabel(additionalLabels map[string]string, name string) map[string]string

func GenerateService

func GenerateService(name, namespace string, labels, selector map[string]string, headless bool) *corev1.Service

func GenerateServiceLabel

func GenerateServiceLabel(additionalLabels map[string]string, name, serviceName string) map[string]string

func GenerateServicePPLabel

func GenerateServicePPLabel(additionalLabels map[string]string, name string) map[string]string

func GetConfig

func GetConfig() *rest.Config

func GetConfigMap

func GetConfigMap(cli client.Client, name, namespace string) (*corev1.ConfigMap, error)

func GetJob

func GetJob(cli client.Client, namespace, name string) (*batchv1.Job, error)

func GetMongoInstanceByName

func GetMongoInstanceByName(cli client.Client, name, namespace string) (*middlewarev1alpha1.MongoDB, error)

func GetPod

func GetPod(cli client.Client, namespace, name string) (*corev1.Pod, error)

func GetService

func GetService(cli client.Client, namespace, name string) (*corev1.Service, error)

func GetServiceByNodePort

func GetServiceByNodePort(nodePort int32, serviceList []corev1.Service) (*corev1.Service, error)

func GetSts

func GetSts(cli client.Client, stsName, namespace string) (*appsv1.StatefulSet, error)

func GetSvc

func GetSvc(cli client.Client, namespace, name string) (*corev1.Service, error)

func IsExistAndDeleted

func IsExistAndDeleted(client client.Client, name, namespace string, found client.Object) error

func IsExists

func IsExists(client client.Client, obj metav1.Object, found client.Object) (exists bool, err error)

func IsExistsByName

func IsExistsByName(client client.Client, name, namespace string, found client.Object) (exists bool, err error)

func IsSubLabel

func IsSubLabel(super, sub map[string]string) bool

sub标签在super中全部存在

func ListPod

func ListPod(cli client.Client, namespace string, selector map[string]string) ([]corev1.Pod, error)

func ListService

func ListService(cli client.Client, namespace string, selector map[string]string) ([]corev1.Service, error)

func ListSts

func ListSts(cli client.Client, namespace string, selector map[string]string) ([]appsv1.StatefulSet, error)

根据label获取statefulset

func MergeLabels

func MergeLabels(allLabels ...map[string]string) map[string]string

MergeLabels merges all the label maps received as argument into a single new label map.

func ObjIsExists

func ObjIsExists(client client.Client, found client.Object) (exists bool, err error)

func ScaleDownCleaner

func ScaleDownCleaner(cli client.Client,
	schema *runtime.Scheme,
	serviceList []corev1.Service,
	MultiCloudMongoDB *middlewarev1alpha1.MultiCloudMongoDB,
	svcPPList *karmadaPolicyv1alpha1.PropagationPolicyList,
	log *zap.SugaredLogger) error

做缩容用的,需要优化

func SetRefAndCreateObject

func SetRefAndCreateObject(owner metav1.Object, obj interface{}, scheme *runtime.Scheme, client client.Client) error

func UpdateObject

func UpdateObject(cli client.Client, obj client.Object) error

func UpdateObjectStatus

func UpdateObjectStatus(cli client.Client, obj client.Object) error

func UpsertConfigMapDeleteArbiter

func UpsertConfigMapDeleteArbiter(client client.Client, name, namespace string, found client.Object) error

func UpsertObject

func UpsertObject(cli client.Client, obj interface{}) error

func UpsertOpEnsure

func UpsertOpEnsure(cli client.Client, cr *middlewarev1alpha1.MultiCloudMongoDB, Scheme *runtime.Scheme, obj metav1.Object, found client.Object) error

func UpsertPPEnsure

func UpsertPPEnsure(cli client.Client, cr *middlewarev1alpha1.MultiCloudMongoDB, Scheme *runtime.Scheme, obj metav1.Object, found client.Object) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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