k8s

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KubeClient added in v0.0.1

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

KubeClient implements structure for Kubernetes Client

func NewKubeClient added in v0.0.1

func NewKubeClient(logger logging.Logger, client client.Client) KubeClient

NewKubeClient initializes a new client for Kubernetes

func (KubeClient) CreateOrUpdateCronJob added in v0.0.1

func (kc KubeClient) CreateOrUpdateCronJob(
	ctx context.Context,
	cronjob *batchV1beta1.CronJob,
	mutator controllerutil.MutateFn,
) (controllerutil.OperationResult, error)

CreateOrUpdateCronJob creates or updates a cronjob in the cluster

func (KubeClient) CreateOrUpdatePersistentVolume added in v0.0.1

func (kc KubeClient) CreateOrUpdatePersistentVolume(
	ctx context.Context,
	pv *coreV1.PersistentVolume,
	mutator controllerutil.MutateFn,
) (controllerutil.OperationResult, error)

CreateOrUpdatePersistentVolume attempts to create, if not existent, or to update an existent PersistentVolumeClaim

func (KubeClient) CreateOrUpdatePersistentVolumeClaim added in v0.0.1

func (kc KubeClient) CreateOrUpdatePersistentVolumeClaim(
	ctx context.Context,
	pvc *coreV1.PersistentVolumeClaim,
	mutator controllerutil.MutateFn,
) (controllerutil.OperationResult, error)

CreateOrUpdatePersistentVolumeClaim ...

func (KubeClient) CreateOrUpdatePod added in v0.0.1

func (kc KubeClient) CreateOrUpdatePod(
	ctx context.Context,
	pod *coreV1.Pod,
	mutator controllerutil.MutateFn,
) (controllerutil.OperationResult, error)

CreateOrUpdatePod attempts to create, if not existent, or to update an existent Pod

func (KubeClient) CreateOrUpdateRole added in v0.0.1

func (kc KubeClient) CreateOrUpdateRole(
	ctx context.Context,
	role *rbacV1.Role,
	mutator controllerutil.MutateFn,
) (controllerutil.OperationResult, error)

CreateOrUpdateRole creates or updates a role in the cluster

func (KubeClient) CreateOrUpdateRoleBinding added in v0.0.1

func (kc KubeClient) CreateOrUpdateRoleBinding(
	ctx context.Context,
	rb *rbacV1.RoleBinding,
	mutator controllerutil.MutateFn,
) (controllerutil.OperationResult, error)

CreateOrUpdateRoleBinding creates or updates a role binding in the cluster

func (KubeClient) CreateOrUpdateService added in v0.0.1

func (kc KubeClient) CreateOrUpdateService(
	ctx context.Context,
	service *coreV1.Service,
	mutator controllerutil.MutateFn,
) (controllerutil.OperationResult, error)

CreateOrUpdateService creates a service in the cluster

func (KubeClient) CreateOrUpdateServiceAccount added in v0.0.1

func (kc KubeClient) CreateOrUpdateServiceAccount(
	ctx context.Context,
	sa *coreV1.ServiceAccount,
	mutator controllerutil.MutateFn,
) (controllerutil.OperationResult, error)

CreateOrUpdateServiceAccount creates or updates a service account in the cluster

func (KubeClient) DeleteCronJob added in v0.0.1

func (kc KubeClient) DeleteCronJob(ctx context.Context, cronjob *batchV1beta1.CronJob) error

DeleteCronJob deletes a cronjob on cluster

func (KubeClient) DeleteJob added in v0.0.1

func (kc KubeClient) DeleteJob(ctx context.Context, job *batchV1.Job) error

DeleteJob deletes a job on cluster

func (KubeClient) DeletePersistentVolume added in v0.0.1

func (kc KubeClient) DeletePersistentVolume(ctx context.Context, pv *coreV1.PersistentVolume) error

DeletePersistentVolume attempts to delete a given PV

func (KubeClient) DeletePersistentVolumeClaim added in v0.0.1

func (kc KubeClient) DeletePersistentVolumeClaim(ctx context.Context, pvc *coreV1.PersistentVolumeClaim) error

DeletePersistentVolumeClaim attempts to delete a given PVC

func (KubeClient) DeletePod added in v0.0.1

func (kc KubeClient) DeletePod(ctx context.Context, pod *coreV1.Pod) error

DeletePod deletes a pod on the cluster

func (KubeClient) DeleteRole added in v0.0.1

func (kc KubeClient) DeleteRole(ctx context.Context, role rbacV1.Role) error

DeleteRole deletes a role in the cluster

func (KubeClient) DeleteRoleBinding added in v0.0.1

func (kc KubeClient) DeleteRoleBinding(ctx context.Context, rb rbacV1.RoleBinding) error

DeleteRoleBinding deletes a role binding in the cluster

func (KubeClient) DeleteService added in v0.0.1

func (kc KubeClient) DeleteService(ctx context.Context, svc *coreV1.Service) error

DeleteService deletes a service in the cluster

func (KubeClient) DeleteServiceAccount added in v0.0.1

func (kc KubeClient) DeleteServiceAccount(ctx context.Context, sa *coreV1.ServiceAccount) error

DeleteServiceAccount deletes a service account in the cluster

func (KubeClient) GetCronJob added in v0.0.1

func (kc KubeClient) GetCronJob(ctx context.Context, uid string, namespace string) (batchV1beta1.CronJob, error)

GetCronJob gets a specific cronjob on cluster

func (KubeClient) GetJob added in v0.0.1

func (kc KubeClient) GetJob(ctx context.Context, uid string, namespace string) (*batchV1.Job, error)

GetJob gets a specific job on cluster

func (KubeClient) GetPersistentVolume added in v0.0.1

func (kc KubeClient) GetPersistentVolume(
	ctx context.Context,
	namespacedName types.NamespacedName,
) (coreV1.PersistentVolume, error)

GetPersistentVolume fetches a persistent volume in the cluster

func (KubeClient) GetPersistentVolumeClaim added in v0.0.1

func (kc KubeClient) GetPersistentVolumeClaim(
	ctx context.Context,
	namespacedName types.NamespacedName,
) (coreV1.PersistentVolumeClaim, error)

GetPersistentVolumeClaim fetches a persistent volume claim in the cluster

func (KubeClient) GetPod added in v0.0.1

func (kc KubeClient) GetPod(ctx context.Context, namespacedName types.NamespacedName) (coreV1.Pod, error)

GetPod fetches a pod on cluster

func (KubeClient) GetRole added in v0.0.1

func (kc KubeClient) GetRole(ctx context.Context, namespacedName types.NamespacedName) (rbacV1.Role, error)

GetRole fetches a cluster role with the provided name in the namespace

func (KubeClient) GetRoleBinding added in v0.0.1

func (kc KubeClient) GetRoleBinding(
	ctx context.Context,
	namespacedName types.NamespacedName,
) (rbacV1.RoleBinding, error)

GetRoleBinding fetches a role binding with the provided name in the namespace

func (KubeClient) GetService added in v0.0.1

func (kc KubeClient) GetService(ctx context.Context, namespacedName types.NamespacedName) (coreV1.Service, error)

GetService fetches a service in the cluster

func (KubeClient) GetServiceAccount added in v0.0.1

func (kc KubeClient) GetServiceAccount(
	ctx context.Context,
	namespacedName types.NamespacedName,
) (coreV1.ServiceAccount, error)

GetServiceAccount fetches a service account with the provided name in the namespace

func (KubeClient) UpdateJob added in v0.0.1

func (kc KubeClient) UpdateJob(ctx context.Context, job *batchV1.Job) error

UpdateJob creates a job on cluster

type KubeClientInterface added in v0.0.1

type KubeClientInterface interface {
	GetPod(ctx context.Context, namespacedName types.NamespacedName) (coreV1.Pod, error)
	DeletePod(ctx context.Context, pod *coreV1.Pod) error
	CreateOrUpdatePod(
		ctx context.Context,
		pod *coreV1.Pod,
		mutator controllerutil.MutateFn,
	) (controllerutil.OperationResult, error)

	GetService(ctx context.Context, namespacedName types.NamespacedName) (coreV1.Service, error)
	DeleteService(ctx context.Context, pod *coreV1.Service) error
	CreateOrUpdateService(
		ctx context.Context,
		service *coreV1.Service,
		mutator controllerutil.MutateFn,
	) (controllerutil.OperationResult, error)

	GetPersistentVolume(ctx context.Context, namespacedName types.NamespacedName) (coreV1.PersistentVolume, error)
	DeletePersistentVolume(ctx context.Context, pvc *coreV1.PersistentVolumeClaim) error
	CreateOrUpdatePersistentVolume(
		ctx context.Context,
		pv *coreV1.PersistentVolume,
		mutator controllerutil.MutateFn,
	) (controllerutil.OperationResult, error)

	GetPersistentVolumeClaim(
		ctx context.Context,
		namespacedName types.NamespacedName,
	) (coreV1.PersistentVolumeClaim, error)
	DeletePersistentVolumeClaim(ctx context.Context, pvc *coreV1.PersistentVolumeClaim) error
	CreateOrUpdatePersistentVolumeClaim(
		ctx context.Context,
		pvc *coreV1.PersistentVolumeClaim,
		mutator controllerutil.MutateFn,
	) (controllerutil.OperationResult, error)

	GetServiceAccount(ctx context.Context, namespacedName types.NamespacedName) (coreV1.ServiceAccount, error)
	DeleteServiceAccount(ctx context.Context, sa *coreV1.ServiceAccount) error
	CreateOrUpdateServiceAccount(
		ctx context.Context,
		sa *coreV1.ServiceAccount,
		mutator controllerutil.MutateFn,
	) (controllerutil.OperationResult, error)

	GetRole(ctx context.Context, namespacedName types.NamespacedName) (rbacV1.Role, error)
	DeleteRole(ctx context.Context, role *rbacV1.Role) error
	CreateOrUpdateRole(
		ctx context.Context,
		role *rbacV1.Role,
		mutator controllerutil.MutateFn,
	) (controllerutil.OperationResult, error)

	GetRoleBinding(ctx context.Context, namespacedName types.NamespacedName) (rbacV1.RoleBinding, error)
	DeleteRoleBinding(ctx context.Context, rb *rbacV1.RoleBinding) error
	CreateOrUpdateRoleBinding(
		ctx context.Context,
		rb *rbacV1.RoleBinding,
		mutator controllerutil.MutateFn,
	) (controllerutil.OperationResult, error)

	GetJob(ctx context.Context, uid string, namespace string) (batchV1beta1.CronJob, error)
	UpdateJob(ctx context.Context, job *batchV1.Job) error
	DeleteJob(ctx context.Context, job *batchV1.Job) error

	GetCronJob(ctx context.Context, uid string, namespace string) (batchV1beta1.CronJob, error)
	DeleteCronJob(ctx context.Context, cronjob *batchV1beta1.CronJob) error
	CreateOrUpdateCronJob(
		ctx context.Context,
		cronjob *batchV1beta1.CronJob,
		mutator controllerutil.MutateFn,
	) (controllerutil.OperationResult, error)
}

KubeClientInterface defines the interface for Kubernetes Client

type Metrics added in v0.0.1

type Metrics struct {
	Create             *prometheus.CounterVec
	FailedCreate       *prometheus.CounterVec
	Running            *prometheus.GaugeVec
	CullingCount       *prometheus.CounterVec
	FailedCullingCount *prometheus.CounterVec
	CullingTimestamp   *prometheus.GaugeVec
	// contains filtered or unexported fields
}

Metrics is a simple struct with some metric templates

func NewMetrics added in v0.0.1

func NewMetrics(client client.Client, name string) *Metrics

NewMetrics register new metrics service WARNING: you cannot call this method twice passing the same name otherwise, it can cause panic

func (*Metrics) Collect added in v0.0.1

func (m *Metrics) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*Metrics) CustomCount added in v0.0.1

func (m *Metrics) CustomCount(name string, labels []string) *prometheus.CounterVec

CustomCount now you can create your own gauge metric WARNING: you cannot call this method twice passing the same metric name otherwise, it can cause panic

func (*Metrics) CustomGauge added in v0.0.1

func (m *Metrics) CustomGauge(name string, labels []string) *prometheus.GaugeVec

CustomGauge now you can create your own gauge metric WARNING: you cannot call this method twice passing the same metric name otherwise, it can cause panic

func (*Metrics) Describe added in v0.0.1

func (m *Metrics) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

Jump to

Keyboard shortcuts

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