operator

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoScaler

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

func NewAutoScaler

func NewAutoScaler(es *ESResource, metricsInterval time.Duration, esClient *ESClient) *AutoScaler

func (*AutoScaler) GetScalingOperation

func (as *AutoScaler) GetScalingOperation() (*ScalingOperation, error)

TODO: check alternative approach by configuring the tags used for `index.routing.allocation` and deriving the indices from there.

type EDSResource

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

func (*EDSResource) APIVersion

func (r *EDSResource) APIVersion() string

func (*EDSResource) Drain

func (r *EDSResource) Drain(ctx context.Context, pod *v1.Pod) error

Drain drains a pod for Elasticsearch data.

func (*EDSResource) EnsureResources

func (r *EDSResource) EnsureResources() error

func (*EDSResource) Generation

func (r *EDSResource) Generation() int64

func (*EDSResource) Kind

func (r *EDSResource) Kind() string

func (*EDSResource) LabelSelector

func (r *EDSResource) LabelSelector() map[string]string

func (*EDSResource) Labels

func (r *EDSResource) Labels() map[string]string

func (*EDSResource) Name

func (r *EDSResource) Name() string

func (*EDSResource) Namespace

func (r *EDSResource) Namespace() string

func (*EDSResource) OnStableReplicasHook

func (r *EDSResource) OnStableReplicasHook(ctx context.Context) error

OnStableReplicasHook ensures that the indexReplicas is set as defined in the EDS scaling-operation annotation.

func (*EDSResource) PodTemplateSpec

func (r *EDSResource) PodTemplateSpec() *v1.PodTemplateSpec

func (*EDSResource) PreScaleDownHook

func (r *EDSResource) PreScaleDownHook(ctx context.Context) error

PreScaleDownHook ensures that the IndexReplicas is set as defined in the EDS 'scaling-operation' annotation prior to scaling down the internal StatefulSet.

func (*EDSResource) Replicas

func (r *EDSResource) Replicas() int32

func (*EDSResource) Self

func (r *EDSResource) Self() runtime.Object

func (*EDSResource) UID

func (r *EDSResource) UID() types.UID

func (*EDSResource) UpdateStatus

func (r *EDSResource) UpdateStatus(sts *appsv1.StatefulSet) error

UpdateStatus updates the status of the EDS to set the current replicas from StatefulSet and updating the observedGeneration.

func (*EDSResource) VolumeClaimTemplates

func (r *EDSResource) VolumeClaimTemplates() []v1.PersistentVolumeClaim

type ESClient

type ESClient struct {
	Endpoint *url.URL
}

ESClient is a pod drainer which can drain data from Elasticsearch pods.

func (*ESClient) Cleanup

func (c *ESClient) Cleanup(ctx context.Context) error

func (*ESClient) CreateIndex

func (c *ESClient) CreateIndex(indexName, groupName string, shards, replicas int) error

func (*ESClient) DeleteIndex

func (c *ESClient) DeleteIndex(indexName string) error

func (*ESClient) Drain

func (c *ESClient) Drain(ctx context.Context, pod *v1.Pod) error

Drain drains data from an Elasticsearch pod.

func (*ESClient) GetIndices

func (c *ESClient) GetIndices() ([]ESIndex, error)

func (*ESClient) GetNodes

func (c *ESClient) GetNodes() ([]ESNode, error)

func (*ESClient) GetShards

func (c *ESClient) GetShards() ([]ESShard, error)

func (*ESClient) UpdateIndexSettings

func (c *ESClient) UpdateIndexSettings(indices []ESIndex) error

type ESHealth

type ESHealth struct {
	Status string `json:"status"`
}

type ESIndex

type ESIndex struct {
	Index     string `json:"index"`
	Primaries int32  `json:"pri"`
	Replicas  int32  `json:"rep"`
}

ESIndex represent an index to be used in public APIs

type ESNode

type ESNode struct {
	IP              string  `json:"ip"`
	DiskUsedPercent float64 `json:"dup"`
}

ESNode represent a single Elasticsearch node to be used in public API

type ESResource

type ESResource struct {
	ElasticsearchDataSet *zv1.ElasticsearchDataSet
	StatefulSet          *appsv1.StatefulSet
	MetricSet            *zv1.ElasticsearchMetricSet
	Pods                 []v1.Pod
}

func (*ESResource) Replicas

func (es *ESResource) Replicas() int32

Replicas returns the desired node replicas of an ElasticsearchDataSet In case it was not specified, it will return '1'.

type ESSettings

type ESSettings struct {
	Transient struct {
		Cluster struct {
			Routing struct {
				Allocation struct {
					Exclude struct {
						IP string `json:"_ip"`
					} `json:"exclude"`
				} `json:"allocation"`
				Rebalance struct {
					Enable string `json:"enable"`
				} `json:"rebalance"`
			} `json:"routing"`
		} `json:"cluster"`
	} `json:"transient"`
}

ESSettings represent response from _cluster/settings

type ESShard

type ESShard struct {
	IP    string `json:"ip"`
	Index string `json:"index"`
}

ESShard represent a single shard from the response of _cat/shards

type ElasticsearchMetricsCollector

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

type ElasticsearchOperator

type ElasticsearchOperator struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewElasticsearchOperator

func NewElasticsearchOperator(
	client *clientset.Clientset,
	priorityNodeSelectors map[string]string,
	interval,
	autoscalerInterval time.Duration,
	operatorID,
	namespace,
	clusterDNSZone string,
	elasticsearchEndpoint *url.URL,
) *ElasticsearchOperator

NewElasticsearchOperator initializes a new ElasticsearchDataSet operator instance.

func (*ElasticsearchOperator) Run

Run runs the main loop of the operator.

type Operator

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

Operator is a generic operator that can manage Pods filtered by a selector.

func (*Operator) Run

func (o *Operator) Run(ctx context.Context, done chan<- struct{}, sr StatefulResource)

type ScalingDirection

type ScalingDirection int
const (
	DOWN ScalingDirection = iota
	NONE
	UP
)

func (ScalingDirection) String

func (d ScalingDirection) String() string

type ScalingOperation

type ScalingOperation struct {
	ScalingDirection ScalingDirection
	NodeReplicas     *int32
	IndexReplicas    []ESIndex
	Description      string
}

type StatefulResource

type StatefulResource interface {
	// Name returns the name of the resource.
	Name() string
	// Namespace returns the namespace where the resource is located.
	Namespace() string
	// APIVersion returns the APIVersion of the resource.
	APIVersion() string
	// Kind returns the kind of the resource.
	Kind() string
	// Generation returns the generation of the resource.
	Generation() int64
	// UID returns the uid of the resource.
	UID() types.UID
	// Labels returns the labels of the resource.
	Labels() map[string]string
	// LabelSelector returns a set of labels to be used for label selecting.
	LabelSelector() map[string]string

	// Replicas returns the desired replicas of the resource.
	Replicas() int32
	// PodTemplateSpec returns the pod template spec of the resource. This
	// is added to the underlying StatefulSet.
	PodTemplateSpec() *v1.PodTemplateSpec
	// VolumeClaimTemplates returns the volume claim templates of the
	// resource. This is added to the underlying StatefulSet.
	VolumeClaimTemplates() []v1.PersistentVolumeClaim
	Self() runtime.Object

	// EnsureResources
	EnsureResources() error

	// UpdateStatus updates the status of the StatefulResource. The
	// statefulset is parsed to provide additional information like
	// replicas to the status.
	UpdateStatus(sts *appsv1.StatefulSet) error

	// PreScaleDownHook is triggered when a scaledown is to be performed.
	// It's ensured that the hook will be triggered at least once, but it
	// may trigger multiple times e.g. if the scaledown fails at a later
	// stage and has to be retried.
	PreScaleDownHook(ctx context.Context) error

	// OnStableReplicasHook is triggered when the statefulSet is observed
	// to be stable meaning readyReplicas == desiredReplicas.
	// This hook can for instance be used to perform cleanup tasks.
	OnStableReplicasHook(ctx context.Context) error

	// Drain drains a pod for data. It's expected that the method only
	// returns after the pod has been drained.
	Drain(ctx context.Context, pod *v1.Pod) error
}

Jump to

Keyboard shortcuts

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