common

package
v0.0.0-...-d4ceb64 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	S3AccessKeyName = "ACCESS_KEY"
	S3SecretKeyName = "SECRET_KEY"
)

Variables

This section is empty.

Functions

func ConvertToResourceRequirements

func ConvertToResourceRequirements(resources *sparkv1alpha1.ResourcesSpec) *corev1.ResourceRequirements

func MergeObjects

func MergeObjects(left interface{}, right interface{}, exclude []string)

MergeObjects merge right to left, if field not in left, it will be added from right, else skip. Node: If variable is a pointer, it will be modified directly.

func OverrideEnvVars

func OverrideEnvVars(origin *[]corev1.EnvVar, override map[string]string)

Types

type BaseResourceReconciler

type BaseResourceReconciler[T client.Object, G any] struct {
	Instance  T
	Scheme    *runtime.Scheme
	Client    client.Client
	GroupName string

	MergedLabels map[string]string
	MergedCfg    G
}

func NewBaseResourceReconciler

func NewBaseResourceReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G) *BaseResourceReconciler[T, G]

NewBaseResourceReconciler new a BaseResourceReconciler

func (*BaseResourceReconciler[T, G]) Apply

func (b *BaseResourceReconciler[T, G]) Apply(
	ctx context.Context,
	dep client.Object,
	timeAfter time.Duration) (ctrl.Result, error)

func (*BaseResourceReconciler[T, G]) ReconcileResource

func (b *BaseResourceReconciler[T, G]) ReconcileResource(
	ctx context.Context,
	resInstance ResourceBuilder) (ctrl.Result, error)

type BaseRoleReconciler

type BaseRoleReconciler[T client.Object, R any] struct {
	Scheme   *runtime.Scheme
	Instance T
	Client   client.Client
	Log      logr.Logger
	Labels   map[string]string
	Role     R
}

func (*BaseRoleReconciler[T, R]) GetLabels

func (r *BaseRoleReconciler[T, R]) GetLabels(role Role) map[string]string

type ClusterOperation

type ClusterOperation[T InstanceAttributes] struct {
	InstanceAttributes T
	ResourceClient     ResourceClient
}

func NewClusterOperation

func NewClusterOperation(ia InstanceAttributes, resourceClient ResourceClient) *ClusterOperation[InstanceAttributes]

func (*ClusterOperation[T]) ClusterStop

func (c *ClusterOperation[T]) ClusterStop() bool

func (*ClusterOperation[T]) ReconciliationPaused

func (c *ClusterOperation[T]) ReconciliationPaused() bool

type ConditionsGetter

type ConditionsGetter interface {
	GetConditions() *[]metav1.Condition
}

type ConfigurationOverride

type ConfigurationOverride interface {
	ConfigurationOverride(resource client.Object)
}

type ConfigurationStyleReconciler

type ConfigurationStyleReconciler[T client.Object, G any] struct {
	GeneralResourceStyleReconciler[T, G]
}

ConfigurationStyleReconciler configuration style reconciler this reconciler is used to reconcile the configuration style resources such as configMap, secret, etc. it will do the following things: 1. apply the resource Additional: 1. configuration override support

func NewConfigurationStyleReconciler

func NewConfigurationStyleReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G,
) *ConfigurationStyleReconciler[T, G]

func (*ConfigurationStyleReconciler[T, G]) DoReconcile

func (s *ConfigurationStyleReconciler[T, G]) DoReconcile(
	ctx context.Context,
	resource client.Object,
	instance ResourceHandler,
) (ctrl.Result, error)

type DeploymentStyleReconciler

type DeploymentStyleReconciler[T client.Object, G any] struct {
	BaseResourceReconciler[T, G]
	// contains filtered or unexported fields
}

DeploymentStyleReconciler deployment style reconciler this reconciler is used to reconcile the deployment style resources such as deployment, statefulSet, etc. it will do the following things: 1. apply the resource 2. check if the resource is satisfied 3. if not, return requeue 4. if satisfied, return nil Additional:

command and env override can support

func NewDeploymentStyleReconciler

func NewDeploymentStyleReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G,
	replicas int32,
) *DeploymentStyleReconciler[T, G]

func (*DeploymentStyleReconciler[T, G]) CheckPodsSatisfied

func (s *DeploymentStyleReconciler[T, G]) CheckPodsSatisfied(ctx context.Context) (bool, error)

func (*DeploymentStyleReconciler[T, G]) DoReconcile

func (s *DeploymentStyleReconciler[T, G]) DoReconcile(
	ctx context.Context,
	resource client.Object,
	instance ResourceHandler,
) (ctrl.Result, error)

type GeneralResourceStyleReconciler

type GeneralResourceStyleReconciler[T client.Object, G any] struct {
	BaseResourceReconciler[T, G]
}

GeneralResourceStyleReconciler general style resource reconcile this reconciler is used to reconcile the general style resources such as configMap, secret, svc, etc.

func NewGeneraResourceStyleReconciler

func NewGeneraResourceStyleReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G,
) *GeneralResourceStyleReconciler[T, G]

func (*GeneralResourceStyleReconciler[T, G]) DoReconcile

func (s *GeneralResourceStyleReconciler[T, G]) DoReconcile(
	ctx context.Context,
	resource client.Object,
	_ ResourceHandler,
) (ctrl.Result, error)

type IReconciler

type IReconciler interface {
	ReconcileResource(ctx context.Context, groupName string, do ResourceHandler) (ctrl.Result, error)
}

type InstanceAttributes

type InstanceAttributes interface {
	GetClusterConfig() *sparkv1alpha1.ClusterConfigSpec
	GetClusterOperation() *sparkv1alpha1.ClusterOperationSpec
}

type ListenerInfo

type ListenerInfo[T InstanceAttributes] struct {
	InstanceAttributes T
	ResourceClient     ResourceClient
}

func NewListenerInfo

func NewListenerInfo(ia InstanceAttributes, resourceClient ResourceClient) *ListenerInfo[InstanceAttributes]

func (*ListenerInfo[T]) GetListenerClassName

func (l *ListenerInfo[T]) GetListenerClassName() sparkv1alpha1.ListenerClass

func (*ListenerInfo[T]) GetServiceType

func (l *ListenerInfo[T]) GetServiceType() corev1.ServiceType

TODO: move ListenerClass mapping to ServiceType logic to listener project Finnaly, we should use it from operator-go project

type PDBReconciler

type PDBReconciler[T client.Object] struct {
	BaseResourceReconciler[T, any]
	// contains filtered or unexported fields
}

func NewReconcilePDB

func NewReconcilePDB[T client.Object](
	client client.Client,
	schema *runtime.Scheme,
	cr T,
	labels map[string]string,
	name string,
	pdb *sparkv1alpha1.PodDisruptionBudgetSpec,
) *PDBReconciler[T]

func (*PDBReconciler[T]) Build

func (r *PDBReconciler[T]) Build(_ context.Context) (client.Object, error)

type ResourceBuilder

type ResourceBuilder interface {
	Build(ctx context.Context) (client.Object, error)
}

type ResourceClient

type ResourceClient struct {
	Ctx       context.Context
	Client    client.Client
	Namespace string
}

func (*ResourceClient) Get

func (r *ResourceClient) Get(obj client.Object) error

type ResourceHandler

type ResourceHandler interface {
	DoReconcile(ctx context.Context, resource client.Object, instance ResourceHandler) (ctrl.Result, error)
}

type ResourceNameGenerator

type ResourceNameGenerator struct {
	InstanceName string
	RoleName     string
	GroupName    string
}

func NewResourceNameGenerator

func NewResourceNameGenerator(instanceName, roleName, groupName string) *ResourceNameGenerator

NewResourceNameGenerator new a ResourceNameGenerator

func (*ResourceNameGenerator) GenerateResourceName

func (r *ResourceNameGenerator) GenerateResourceName(extraSuffix string) string

GenerateResourceName generate resource Name

type Role

type Role string
const (
	HistoryServer Role = "spark-history-server"
)

type RoleGroupRecociler

type RoleGroupRecociler interface {
	ReconcileGroup(ctx context.Context) (ctrl.Result, error)
	MergeLabels(mergedGroupCfg any) map[string]string
	MergeGroupConfigSpec() any
}

RoleGroupRecociler RoleReconcile role reconciler interface all role reconciler should implement this interface

type RoleLabels

type RoleLabels[T client.Object] struct {
	Cr   T
	Name string
}

func (*RoleLabels[T]) GetLabels

func (r *RoleLabels[T]) GetLabels() map[string]string

type RoleReconciler

type RoleReconciler interface {
	RoleName() Role
	MergeLabels() map[string]string
	ReconcileRole(ctx context.Context) (ctrl.Result, error)
}

type S3Configuration

type S3Configuration[T InstanceAttributes] struct {
	InstanceAttributes T
	ResourceClient     ResourceClient
}

func NewS3Configuration

func NewS3Configuration(ia InstanceAttributes, resourceClient ResourceClient) *S3Configuration[InstanceAttributes]

func (*S3Configuration[T]) Enabled

func (s *S3Configuration[T]) Enabled() bool

func (*S3Configuration[T]) ExistingS3Bucket

func (s *S3Configuration[T]) ExistingS3Bucket() bool

func (*S3Configuration[T]) GetCredential

func (s *S3Configuration[T]) GetCredential(name string) (*S3Credential, error)

func (*S3Configuration[T]) GetRefBucket

func (s *S3Configuration[T]) GetRefBucket() (*commonsv1alpha1.S3Bucket, error)

func (*S3Configuration[T]) GetRefBucketName

func (s *S3Configuration[T]) GetRefBucketName() string

func (*S3Configuration[T]) GetRefConnection

func (s *S3Configuration[T]) GetRefConnection(name string) (*commonsv1alpha1.S3Connection, error)

func (*S3Configuration[T]) GetS3ParamsFromInline

func (s *S3Configuration[T]) GetS3ParamsFromInline() (*S3Params, error)

func (*S3Configuration[T]) GetS3ParamsFromResource

func (s *S3Configuration[T]) GetS3ParamsFromResource() (*S3Params, error)

type S3Credential

type S3Credential struct {
	AccessKey string `json:"ACCESS_KEY"`
	SecretKey string `json:"SECRET_KEY"`
}

type S3Params

type S3Params struct {
	AccessKey string
	SecretKey string
	Endpoint  string
	Bucket    string
	Region    string
	SSL       bool
	PathStyle bool
}

type WorkloadOverride

type WorkloadOverride interface {
	CommandOverride(resource client.Object)
	EnvOverride(resource client.Object)
	LogOverride(resource client.Object)
}

Jump to

Keyboard shortcuts

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