k8sutil

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSecret

func CreateSecret(client client.Client, secret *corev1.Secret, logger logr.Logger) error

func IsRequestRetryable

func IsRequestRetryable(err error) bool

Types

type ConfigMapController

type ConfigMapController struct {
	// contains filtered or unexported fields
}

func (*ConfigMapController) CreateConfigMap

func (s *ConfigMapController) CreateConfigMap(cm *corev1.ConfigMap) error

CreateConfigMap implement the IConfigMapControl.Interface.

func (*ConfigMapController) DeleteConfigMap

func (s *ConfigMapController) DeleteConfigMap(cm *corev1.ConfigMap) error

DeleteConfigMap implement the IConfigMapControl.Interface.

func (*ConfigMapController) GetConfigMap

func (s *ConfigMapController) GetConfigMap(namespace, name string) (*corev1.ConfigMap, error)

GetConfigMap implement the IConfigMapControl.Interface.

func (*ConfigMapController) UpdateConfigMap

func (s *ConfigMapController) UpdateConfigMap(cm *corev1.ConfigMap) error

UpdateConfigMap implement the IConfigMapControl.Interface.

type DeploymentController

type DeploymentController struct {
	// contains filtered or unexported fields
}

func (*DeploymentController) CreateDeployment

func (d *DeploymentController) CreateDeployment(deployment *appsv1.Deployment) error

CreateDeployment implement the IDeploymentControl.Interface.

func (*DeploymentController) DeleteDeployment

func (d *DeploymentController) DeleteDeployment(deployment *appsv1.Deployment) error

DeleteDeployment implement the IDeploymentControl.Interface.

func (*DeploymentController) GetDeployment

func (d *DeploymentController) GetDeployment(namespace, name string) (*appsv1.Deployment, error)

GetDeployment implement the IDeploymentControl.Interface.

func (*DeploymentController) ListDeploymentByLabels

func (d *DeploymentController) ListDeploymentByLabels(namespace string, labs client.MatchingLabels) (*appsv1.DeploymentList, error)

func (*DeploymentController) UpdateDeployment

func (d *DeploymentController) UpdateDeployment(deployment *appsv1.Deployment) error

UpdateDeployment implement the IDeploymentControl.Interface.

type IConfigMapControl

type IConfigMapControl interface {
	// CreateConfigMap creates a ConfigMap in a DistributedRedisCluster.
	CreateConfigMap(*corev1.ConfigMap) error
	// UpdateConfigMap updates a ConfigMap in a DistributedRedisCluster.
	UpdateConfigMap(*corev1.ConfigMap) error
	// DeleteConfigMap deletes a ConfigMap in a DistributedRedisCluster.
	DeleteConfigMap(*corev1.ConfigMap) error
	// GetConfigMap get ConfigMap in a DistributedRedisCluster.
	GetConfigMap(namespace, name string) (*corev1.ConfigMap, error)
}

IConfigMapControl defines the interface that uses to create, update, and delete ConfigMaps.

func NewConfigMapController

func NewConfigMapController(client client.Client) IConfigMapControl

NewRealConfigMapControl creates a concrete implementation of the IConfigMapControl.

type ICustomResource

type ICustomResource interface {
	// UpdateCRStatus update the RedisCluster status
	UpdateCRStatus(runtime.Object) error
	UpdateCR(runtime.Object) error
	GetRedisClusterBackup(namespace, name string) (*redisv1alpha1.RedisClusterBackup, error)
	GetDistributedRedisCluster(namespace, name string) (*redisv1alpha1.DistributedRedisCluster, error)
	UpdateCrdAnnotations(crd *redisv1alpha1.DistributedRedisCluster, annotationKey string, annotationvalue string) error
}

ICustomResource defines the interface that uses to update cr status

func NewCRControl

func NewCRControl(client client.Client) ICustomResource

NewCRControl creates a concrete implementation of the ICustomResource.

type IDeploymentControl

type IDeploymentControl interface {
	CreateDeployment(*appsv1.Deployment) error
	UpdateDeployment(*appsv1.Deployment) error
	DeleteDeployment(*appsv1.Deployment) error
	GetDeployment(namespace, name string) (*appsv1.Deployment, error)
	ListDeploymentByLabels(namespace string, labs client.MatchingLabels) (*appsv1.DeploymentList, error)
}

IDeploymentControl define the interface that used to create, update, and delete Deployments.

func NewDeploymentController

func NewDeploymentController(client client.Client) IDeploymentControl

NewRealDeploymentControl creates a concrete implementation of the IDeploymentControl.

type IJobControl

type IJobControl interface {
	CreateJob(*batchv1.Job) error
	UpdateJob(*batchv1.Job) error
	DeleteJob(*batchv1.Job) error
	GetJob(namespace, name string) (*batchv1.Job, error)
	ListJobByLabels(namespace string, labs client.MatchingLabels) (*batchv1.JobList, error)
}

IJobControl definej the interface that usej to create, update, and delete Jobs.

func NewJobController

func NewJobController(client client.Client) IJobControl

NewRealJobControl creates a concrete implementation of the IJobControl.

type INodeControl

type INodeControl interface {
	// GetNode with the node name obtained from podspec.
	GetNode(nodename string) (*corev1.Node, error)
	// Get the Zonename of the node. if not found return unknown.
	GetZoneLabel(node *corev1.Node) string
	// Check if the zone is available.
	CheckZoneAvailable(zonename string) (bool, error)
}

IPodControl defines the interface that uses to create, update, and delete Pods.

func NewNodeController

func NewNodeController(client client.Client) INodeControl

NewNodeController creates a concrete implementation of the INodeControl.

type IPodControl

type IPodControl interface {
	// CreatePod creates a Pod in a DistributedRedisCluster.
	CreatePod(*corev1.Pod) error
	// UpdatePod updates a Pod in a DistributedRedisCluster.
	UpdatePod(*corev1.Pod) error
	// DeletePod deletes a Pod in a DistributedRedisCluster.
	DeletePod(*corev1.Pod) error
	DeletePodByName(namespace, name string) error
	// GetPod get Pod in a DistributedRedisCluster.
	GetPod(namespace, name string) (*corev1.Pod, error)
	// UpdatePodLabels updates label of a pod in a DistributedRedisCluster.
	UpdatePodLabels(pod *corev1.Pod, labelKey string, labelValue string) error

	ListPodsWithLabel(namespace string, labelkey string, labelvalue string) (*corev1.PodList, error)

	UpdatePodAnnotations(pod *corev1.Pod, annotationKey string, annotationvalue string) error
}

IPodControl defines the interface that uses to create, update, and delete Pods.

func NewPodController

func NewPodController(client client.Client) IPodControl

NewPodController creates a concrete implementation of the IPodControl.

type IPodDisruptionBudgetControl

type IPodDisruptionBudgetControl interface {
	// CreatePodDisruptionBudget creates a PodDisruptionBudget in a DistributedRedisCluster.
	CreatePodDisruptionBudget(*policyv1.PodDisruptionBudget) error
	// UpdatePodDisruptionBudget updates a PodDisruptionBudget in a DistributedRedisCluster.
	UpdatePodDisruptionBudget(*policyv1.PodDisruptionBudget) error
	// DeletePodDisruptionBudget deletes a PodDisruptionBudget in a DistributedRedisCluster.
	DeletePodDisruptionBudget(*policyv1.PodDisruptionBudget) error
	DeletePodDisruptionBudgetByName(namespace, name string) error
	// GetPodDisruptionBudget get PodDisruptionBudget in a DistributedRedisCluster.
	GetPodDisruptionBudget(namespace, name string) (*policyv1.PodDisruptionBudget, error)
}

IPodDisruptionBudgetControl defines the interface that uses to create, update, and delete PodDisruptionBudgets.

func NewPodDisruptionBudgetController

func NewPodDisruptionBudgetController(client client.Client) IPodDisruptionBudgetControl

NewRealPodDisruptionBudgetControl creates a concrete implementation of the IPodDisruptionBudgetControl.

type IPvcControl

type IPvcControl interface {
	DeletePvc(claim *corev1.PersistentVolumeClaim) error
	DeletePvcByLabels(namespace string, labels map[string]string) error
	GetPvc(namespace, name string) (*corev1.PersistentVolumeClaim, error)
}

IPvcControl defines the interface that uses to create, update, and delete PersistentVolumeClaim.

func NewPvcController

func NewPvcController(client client.Client) IPvcControl

NewPvcController creates a concrete implementation of the IPvcControl.

type ISecretControl

type ISecretControl interface {
	// CreateSecret creates a Secret in a DistributedRedisCluster.
	CreateSecret(*corev1.Secret) error
	// UpdateSecret updates a Secret in a DistributedRedisCluster.
	UpdateSecret(*corev1.Secret) error
	// DeleteSecret deletes a Secret in a DistributedRedisCluster.
	DeleteSecret(*corev1.Secret) error
	// GetSecret get Secret in a DistributedRedisCluster.
	GetSecret(namespace, name string) (*corev1.Secret, error)
}

ISecretControl defines the interface that uses to create, update, and delete Secrets.

func NewSecretController

func NewSecretController(client client.Client) ISecretControl

NewRealSecretControl creates a concrete implementation of the ISecretControl.

type IServiceControl

type IServiceControl interface {
	// CreateService creates a Service in a DistributedRedisCluster.
	CreateService(*corev1.Service) error
	// UpdateService updates a Service in a DistributedRedisCluster.
	UpdateService(*corev1.Service) error
	// DeleteService deletes a Service in a DistributedRedisCluster.
	DeleteService(*corev1.Service) error
	DeleteServiceByName(namespace, name string) error
	// GetService get Service in a DistributedRedisCluster.
	GetService(namespace, name string) (*corev1.Service, error)
}

IServiceControl defines the interface that uses to create, update, and delete Services.

func NewServiceController

func NewServiceController(client client.Client) IServiceControl

NewRealServiceControl creates a concrete implementation of the IServiceControl.

type IStatefulSetControl

type IStatefulSetControl interface {
	// CreateStatefulSet creates a StatefulSet in a DistributedRedisCluster.
	CreateStatefulSet(*appsv1.StatefulSet) error
	// UpdateStatefulSet updates a StatefulSet in a DistributedRedisCluster.
	UpdateStatefulSet(*appsv1.StatefulSet) error
	// DeleteStatefulSet deletes a StatefulSet in a DistributedRedisCluster.
	DeleteStatefulSet(*appsv1.StatefulSet) error
	DeleteStatefulSetByName(namespace, name string) error
	// GetStatefulSet get StatefulSet in a DistributedRedisCluster.
	GetStatefulSet(namespace, name string) (*appsv1.StatefulSet, error)
	ListStatefulSetByLabels(namespace string, labels map[string]string) (*appsv1.StatefulSetList, error)
	// GetStatefulSetPods will retrieve the pods managed by a given StatefulSet.
	GetStatefulSetPods(namespace, name string) (*corev1.PodList, error)
	GetStatefulSetPodsByLabels(namespace string, labels map[string]string) (*corev1.PodList, error)
}

IStatefulSetControl defines the interface that uses to create, update, and delete StatefulSets.

func NewStatefulSetController

func NewStatefulSetController(client client.Client) IStatefulSetControl

NewRealStatefulSetControl creates a concrete implementation of the IStatefulSetControl.

type JobController

type JobController struct {
	// contains filtered or unexported fields
}

func (*JobController) CreateJob

func (j *JobController) CreateJob(job *batchv1.Job) error

CreateJob implement the IJobControl.Interface.

func (*JobController) DeleteJob

func (j *JobController) DeleteJob(job *batchv1.Job) error

DeleteJob implement the IJobControl.Interface.

func (*JobController) GetJob

func (j *JobController) GetJob(namespace, name string) (*batchv1.Job, error)

GetJob implement the IJobControl.Interface.

func (*JobController) ListJobByLabels

func (j *JobController) ListJobByLabels(namespace string, labs client.MatchingLabels) (*batchv1.JobList, error)

func (*JobController) UpdateJob

func (j *JobController) UpdateJob(job *batchv1.Job) error

UpdateJob implement the IJobControl.Interface.

type NodeController

type NodeController struct {
	// contains filtered or unexported fields
}

func (*NodeController) CheckZoneAvailable added in v0.1.2

func (p *NodeController) CheckZoneAvailable(zonename string) (bool, error)

func (*NodeController) GetNode

func (p *NodeController) GetNode(nodename string) (*corev1.Node, error)

GetNode with the node name obtained from podspec.

func (*NodeController) GetZoneLabel

func (p *NodeController) GetZoneLabel(node *corev1.Node) string

type PodController

type PodController struct {
	// contains filtered or unexported fields
}

func (*PodController) CreatePod

func (p *PodController) CreatePod(pod *corev1.Pod) error

CreatePod implement the IPodControl.Interface.

func (*PodController) DeletePod

func (p *PodController) DeletePod(pod *corev1.Pod) error

DeletePod implement the IPodControl.Interface.

func (*PodController) DeletePodByName

func (p *PodController) DeletePodByName(namespace, name string) error

DeletePod implement the IPodControl.Interface.

func (*PodController) GetPod

func (p *PodController) GetPod(namespace, name string) (*corev1.Pod, error)

GetPod implement the IPodControl.Interface.

func (*PodController) ListPodsWithLabel added in v0.1.2

func (p *PodController) ListPodsWithLabel(namespace string, labelkey string, labelvalue string) (*corev1.PodList, error)

func (*PodController) UpdatePod

func (p *PodController) UpdatePod(pod *corev1.Pod) error

UpdatePod implement the IPodControl.Interface.

func (*PodController) UpdatePodAnnotations added in v0.1.2

func (p *PodController) UpdatePodAnnotations(pod *corev1.Pod, annotationKey string, annotationvalue string) error

func (*PodController) UpdatePodLabels

func (p *PodController) UpdatePodLabels(pod *corev1.Pod, labelKey string, labelValue string) error

type PodDisruptionBudgetController

type PodDisruptionBudgetController struct {
	// contains filtered or unexported fields
}

func (*PodDisruptionBudgetController) CreatePodDisruptionBudget

func (s *PodDisruptionBudgetController) CreatePodDisruptionBudget(pb *policyv1.PodDisruptionBudget) error

CreatePodDisruptionBudget implement the IPodDisruptionBudgetControl.Interface.

func (*PodDisruptionBudgetController) DeletePodDisruptionBudget

func (s *PodDisruptionBudgetController) DeletePodDisruptionBudget(pb *policyv1.PodDisruptionBudget) error

DeletePodDisruptionBudget implement the IPodDisruptionBudgetControl.Interface.

func (*PodDisruptionBudgetController) DeletePodDisruptionBudgetByName

func (s *PodDisruptionBudgetController) DeletePodDisruptionBudgetByName(namespace, name string) error

func (*PodDisruptionBudgetController) GetPodDisruptionBudget

func (s *PodDisruptionBudgetController) GetPodDisruptionBudget(namespace, name string) (*policyv1.PodDisruptionBudget, error)

GetPodDisruptionBudget implement the IPodDisruptionBudgetControl.Interface.

func (*PodDisruptionBudgetController) UpdatePodDisruptionBudget

func (s *PodDisruptionBudgetController) UpdatePodDisruptionBudget(pb *policyv1.PodDisruptionBudget) error

UpdatePodDisruptionBudget implement the IPodDisruptionBudgetControl.Interface.

type SecretController

type SecretController struct {
	// contains filtered or unexported fields
}

func (*SecretController) CreateSecret

func (s *SecretController) CreateSecret(cm *corev1.Secret) error

CreateSecret implement the ISecretControl.Interface.

func (*SecretController) DeleteSecret

func (s *SecretController) DeleteSecret(cm *corev1.Secret) error

DeleteSecret implement the ISecretControl.Interface.

func (*SecretController) GetSecret

func (s *SecretController) GetSecret(namespace, name string) (*corev1.Secret, error)

GetSecret implement the ISecretControl.Interface.

func (*SecretController) UpdateSecret

func (s *SecretController) UpdateSecret(cm *corev1.Secret) error

UpdateSecret implement the ISecretControl.Interface.

Jump to

Keyboard shortcuts

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