Documentation ¶
Index ¶
- Variables
- func IsStatefulSetReadyToServe(ctx context.Context, clientset kubernetes.Interface, namespace, name string, ...) error
- func StatefulSetIsRunning(ctx context.Context, clientset kubernetes.Interface, namespace string, ...) error
- func WaitUntilStatefulSetIsReadyToServe(ctx context.Context, clientset kubernetes.Interface, namespace, name string, ...) error
- func WaitUntilStatefulSetIsRunning(ctx context.Context, clientset kubernetes.Interface, namespace string, ...) error
- type ClusterScaler
- type CockroachExecutor
- type CockroachNodeDrainer
- type CockroachStatefulSet
- func (c *CockroachStatefulSet) Replicas(ctx context.Context) (uint, error)
- func (c *CockroachStatefulSet) SetReplicas(ctx context.Context, scale uint) error
- func (c *CockroachStatefulSet) WaitUntilHealthy(ctx context.Context, scale uint) error
- func (c *CockroachStatefulSet) WaitUntilRunning(ctx context.Context) error
- type Drainer
- type Executor
- type ExecutorOptions
- type PVCPruner
- type PersistentVolumePruner
- type Scaler
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDecommissioningStalled indicates that the decommissioning process of // a node has stalled due to the KV allocator being unable to relocate ranges // to another node. This could happen if no nodes have available disk space // or if ZONE CONFIGURATION constraints can not be satisfied. ErrDecommissioningStalled = errors.New("decommissioning has stalled") )
Functions ¶
func IsStatefulSetReadyToServe ¶
func IsStatefulSetReadyToServe( ctx context.Context, clientset kubernetes.Interface, namespace, name string, numReplicas int32, ) error
IsStatefulSetReadyToServe func
func StatefulSetIsRunning ¶
func StatefulSetIsRunning(ctx context.Context, clientset kubernetes.Interface, namespace string, name string) error
StatefulSetIsRunning checks if the expected number of pods for a statefulset are running but not necessarily ready nor healthy
func WaitUntilStatefulSetIsReadyToServe ¶
func WaitUntilStatefulSetIsReadyToServe( ctx context.Context, clientset kubernetes.Interface, namespace, name string, numReplicas int32) error
WaitUntilStatefulSetIsReadyToServe func
func WaitUntilStatefulSetIsRunning ¶
func WaitUntilStatefulSetIsRunning(ctx context.Context, clientset kubernetes.Interface, namespace string, name string) error
WaitUntilStatefulSetIsRunning waits until the given statefulset has all pods scheduled and running but not necessarily healthy nor ready
Types ¶
type ClusterScaler ¶
type ClusterScaler interface { Replicas(context.Context) (uint, error) SetReplicas(context.Context, uint) error WaitUntilRunning(context.Context) error WaitUntilHealthy(context.Context, uint) error }
ClusterScaler interface
type CockroachExecutor ¶
type CockroachExecutor struct { Namespace string StatefulSet string Container string Config *rest.Config ClientSet kubernetes.Interface TTY bool }
CockroachExecutor struct
type CockroachNodeDrainer ¶
type CockroachNodeDrainer struct { Secure bool Logger logr.Logger Executor *CockroachExecutor // RangeRelocationTimeout is the maximum amount of time to wait // for a range to move. If no ranges have moved from the draining // node in the given durration Decommission will fail with // ErrDecommissioningStalled RangeRelocationTimeout time.Duration }
CockroachNodeDrainer does decommissioning of nodes in the CockroachDB cluster
func (*CockroachNodeDrainer) Decommission ¶
func (d *CockroachNodeDrainer) Decommission(ctx context.Context, replica uint, gRPCPort int32) error
Decommission commands the node to start training process and watches for it to complete or fail after timeout
type CockroachStatefulSet ¶
type CockroachStatefulSet struct { Name string Namespace string ClientSet kubernetes.Interface }
CockroachStatefulSet represents the CRDB statefulset running in a kubernetes cluster
func (*CockroachStatefulSet) Replicas ¶
func (c *CockroachStatefulSet) Replicas(ctx context.Context) (uint, error)
Replicas returns the number of desired replicas for CRDB's statefulset
func (*CockroachStatefulSet) SetReplicas ¶
func (c *CockroachStatefulSet) SetReplicas(ctx context.Context, scale uint) error
SetReplicas sets the desired replicas for CRDB's statefulset without waiting for new pods to be created or to become healthy.
func (*CockroachStatefulSet) WaitUntilHealthy ¶
func (c *CockroachStatefulSet) WaitUntilHealthy(ctx context.Context, scale uint) error
WaitUntilHealthy blocks until the target stateful set has exactly `scale` healthy replicas.
func (*CockroachStatefulSet) WaitUntilRunning ¶
func (c *CockroachStatefulSet) WaitUntilRunning(ctx context.Context) error
WaitUntilRunning blocks until the target statefulset has the expected number of pods running but not necessarily ready
type ExecutorOptions ¶
type ExecutorOptions struct { Pod string Container string Cmd []string Stdin io.Reader Stdout io.Writer Stderr io.Writer TTY bool }
ExecutorOptions struct
type PersistentVolumePruner ¶
type PersistentVolumePruner struct { Namespace string StatefulSet string ClientSet kubernetes.Interface Logger logr.Logger }
PersistentVolumePruner provides a .Prune method to remove unused statefulset PVC and their underlying PVs. The underlying PVs SHOULD have their reclaim policy set to delete.
func (*PersistentVolumePruner) Prune ¶
func (p *PersistentVolumePruner) Prune(ctx context.Context) error
Prune locates and removes all PVCs that belong to a given statefulset but are not in use. Use is determined by the .Spec.Replicas field on the statefulset and the PVCs' ordinal. Prune will return an error if unexpected PVCs are encountered (conflicting labels) or the referenced statefulset's .Spec.Replicas field changes will this operation is running. The underlying PVs' reclaim policy should be set to delete, other options may result in leaking volumes which cost us money.
type Scaler ¶
type Scaler struct { Logger logr.Logger CRDB ClusterScaler Drainer Drainer PVCPruner PVCPruner }
Scaler interface
func (*Scaler) EnsureScale ¶
EnsureScale gracefully adds or removes CRDB replicas from a given stateful until it matches the given number. Removed nodes are drained of all replicas before being removed from the CRDB cluster and their matching PVCs and PVs will be removed as well. In some cases, it may not be possible to full drain a node. In such cases a ErrDecommissioningStalled will be returned and the node will be left in a decommissioning state.