Documentation ¶
Index ¶
- Constants
- Variables
- func CopyInto(cluster *Cluster, clusterDefinition *v1alpha1.Cassandra)
- func NewEventRecorder(kubeClientset *kubernetes.Clientset, s *runtime.Scheme) record.EventRecorder
- type Accessor
- type ActiveReconciliation
- type Cluster
- func (c *Cluster) AddCustomConfigVolumeToStatefulSet(statefulSet *appsV1.StatefulSet, _ *v1alpha1.Rack, ...)
- func (c *Cluster) ApplicationVersion() string
- func (c *Cluster) CassandraPodSelector() string
- func (c *Cluster) CreateService() *v1.Service
- func (c *Cluster) CreateSnapshotCleanupContainer() *v1.Container
- func (c *Cluster) CreateSnapshotCleanupJob() *v1beta1.CronJob
- func (c *Cluster) CreateSnapshotContainer() *v1.Container
- func (c *Cluster) CreateSnapshotJob() *v1beta1.CronJob
- func (c *Cluster) CreateStatefulSetForRack(rack *v1alpha1.Rack, customConfigMap *v1.ConfigMap) *appsV1.StatefulSet
- func (c *Cluster) CustomConfigMapVolumeName() string
- func (c *Cluster) Definition() *v1alpha1.Cassandra
- func (c *Cluster) Name() string
- func (c *Cluster) Namespace() string
- func (c *Cluster) QualifiedName() string
- func (c *Cluster) Racks() []v1alpha1.Rack
- func (c *Cluster) RemoveCustomConfigVolumeFromStatefulSet(statefulSet *appsV1.StatefulSet, _ *v1alpha1.Rack, _ *v1.ConfigMap)
- func (c *Cluster) SetDefaults()
- func (c *Cluster) UpdateStatefulSetToDesiredState(currentStatefulSet *appsV1.StatefulSet, targetRack *v1alpha1.Rack, ...)
- type StateFinder
Constants ¶
const ( // UserID is the ID of the operating system user which the various containers provisioned by the operator should // be run as. UserID = int64(999) // GroupID is the primary group of the user which runs the containers. GroupID = UserID // ApplicationNameLabel is a recommended Kubernetes label applied to all resources created by the operator. ApplicationNameLabel = "app.kubernetes.io/name" // ApplicationInstanceLabel is a recommended Kubernetes label applied to all resources created by the operator. ApplicationInstanceLabel = "app.kubernetes.io/instance" // ApplicationVersionLabel is a recommended Kubernetes label applied to all resources created by the operator. ApplicationVersionLabel = "app.kubernetes.io/version" // ApplicationComponentLabel is a recommended Kubernetes label applied to all resources created by the operator. ApplicationComponentLabel = "app.kubernetes.io/component" // ManagedByLabel is a recommended Kubernetes label applied to all resources created by the operator. ManagedByLabel = "app.kubernetes.io/managed-by" // ManagedByCassandraOperator is the fixed value for the app.kubernetes.io/managed-by label. ManagedByCassandraOperator = "cassandra-operator" // ConfigHashAnnotation gives the name of the annotation that the operator attaches to pods when they have // an associated custom config map. ConfigHashAnnotation = "clusterConfigHash" // SnapshotCronJob is the value of app.kubernetes.io/component for snapshot cronjobs SnapshotCronJob = "snapshot" // SnapshotCleanupCronJob is the value of app.kubernetes.io/component for snapshot cleanup cronjobs SnapshotCleanupCronJob = "snapshot-cleanup" // RackLabel is a label used to identify the rack name in a cluster RackLabel = "cassandra-operator/rack" )
const ( // InvalidClusterEvent describes an event for an invalid cluster InvalidClusterEvent = "InvalidCluster" // InvalidChangeEvent describes an event for an invalid change InvalidChangeEvent = "InvalidChange" // ClusterUpdateEvent describes an event for a cluster update ClusterUpdateEvent = "ClusterUpdate" // ReconciliationInterruptedEvent describes an event where a reconciliation is interrupted ReconciliationInterruptedEvent = "ReconciliationInterrupted" // WaitingForStatefulSetChange is an event created when waiting for a stateful set change to complete WaitingForStatefulSetChange = "WaitingForStatefulSetChange" // StatefulSetChangeComplete is an event created when a stateful set change iscomplete StatefulSetChangeComplete = "StatefulSetChangeComplete" // ClusterSnapshotCreationScheduleEvent is an event triggered on creation of a scheduled snapshot ClusterSnapshotCreationScheduleEvent = "ClusterSnapshotCreationScheduleEvent" // ClusterSnapshotCreationUnscheduleEvent is an event triggered on removal of a scheduled snapshot ClusterSnapshotCreationUnscheduleEvent = "ClusterSnapshotCreationUnscheduleEvent" // ClusterSnapshotCreationModificationEvent is an event triggered when the scheduled snapshot is modified ClusterSnapshotCreationModificationEvent = "ClusterSnapshotCreationModificationEvent" // ClusterSnapshotCleanupScheduleEvent is an event triggered when scheduling a snapshot cleanup ClusterSnapshotCleanupScheduleEvent = "ClusterSnapshotCleanupScheduleEvent" // ClusterSnapshotCleanupUnscheduleEvent is an event triggered when scheduling a snapshot cleanup ClusterSnapshotCleanupUnscheduleEvent = "ClusterSnapshotCleanupUnscheduleEvent" // ClusterSnapshotCleanupModificationEvent is an event triggered when the snapshot cleanup job is modified ClusterSnapshotCleanupModificationEvent = "ClusterSnapshotCleanupModificationEvent" )
Variables ¶
var ErrReconciliationInterrupted = errors.New("reconciliation interrupted by a more recent version")
ErrReconciliationInterrupted is an error which signifies that a reconciliation was interrupted.
Functions ¶
func CopyInto ¶
CopyInto copies a Cassandra cluster definition into the internal cluster data structure supplied.
func NewEventRecorder ¶
func NewEventRecorder(kubeClientset *kubernetes.Clientset, s *runtime.Scheme) record.EventRecorder
NewEventRecorder creates an EventRecorder which can be used to record events reflecting the state of operator managed clusters. It correctly does aggregation of repeated events into a count, first timestamp and last timestamp.
Types ¶
type Accessor ¶
type Accessor interface { GetCassandraForCluster(namespace, clusterName string) (*v1alpha1.Cassandra, error) CreateServiceForCluster(c *Cluster) (*v1.Service, error) FindCustomConfigMap(namespace, clusterName string) *v1.ConfigMap UpdateCronJob(job *v1beta1.CronJob) error DeleteCronJob(job *v1beta1.CronJob) error FindCronJobForCluster(cassandra *v1alpha1.Cassandra, jobType string) (*v1beta1.CronJob, error) CreateCronJobForCluster(c *Cluster, cronJob *v1beta1.CronJob) (*v1beta1.CronJob, error) WaitUntilRackChangeApplied(cluster *Cluster, statefulSet *appsV1.StatefulSet) error UpdateStatefulSet(c *Cluster, statefulSet *appsV1.StatefulSet) (*appsV1.StatefulSet, error) GetStatefulSetForRack(c *Cluster, rack *v1alpha1.Rack) (*appsV1.StatefulSet, error) PatchStatefulSet(c *Cluster, rack *v1alpha1.Rack, patch string) (*appsV1.StatefulSet, error) CreateStatefulSetForRack(c *Cluster, rack *v1alpha1.Rack, customConfigMap *v1.ConfigMap) (*appsV1.StatefulSet, error) }
Accessor exposes operations to access various kubernetes resources belonging to a Cluster
func NewAccessor ¶
func NewAccessor(kubeClientset *kubernetes.Clientset, cassandraClientset *versioned.Clientset, eventRecorder record.EventRecorder, activeReconciliations *sync.Map) Accessor
NewAccessor creates a new Accessor
type ActiveReconciliation ¶
type ActiveReconciliation struct { CassandraRevision string ConfigMapRevision string sync.Mutex // contains filtered or unexported fields }
ActiveReconciliation is a record of a reconciliation which is currently in progress. It offers a way to mark a reconciliation as complete or interrupted.
func NewReconciliation ¶
func NewReconciliation(cassandraRevision, configMapRevision string) *ActiveReconciliation
NewReconciliation creates a new ActiveReconciliation
func (*ActiveReconciliation) Complete ¶
func (a *ActiveReconciliation) Complete()
Complete will mark a not-yet-complete reconciliation as complete, and close its interruptChannel.
func (*ActiveReconciliation) Interrupt ¶
func (a *ActiveReconciliation) Interrupt()
Interrupt will send an interrupt message down the interruptChannel, if the reconciliation isn't already complete.
func (*ActiveReconciliation) InterruptChannel ¶
func (a *ActiveReconciliation) InterruptChannel() <-chan struct{}
InterruptChannel returns a receive-only channel which should be checked for an interrupt message, which would mean the reconciliation should be interrupted.
type Cluster ¶
type Cluster struct { Online bool // contains filtered or unexported fields }
Cluster defines the properties of a Cassandra cluster which the operator should manage.
func (*Cluster) AddCustomConfigVolumeToStatefulSet ¶
func (c *Cluster) AddCustomConfigVolumeToStatefulSet(statefulSet *appsV1.StatefulSet, _ *v1alpha1.Rack, customConfigMap *v1.ConfigMap)
AddCustomConfigVolumeToStatefulSet updates the provided statefulset to mount the configmap as a volume
func (*Cluster) ApplicationVersion ¶
ApplicationVersion returns the version part of the main Cassandra image name
func (*Cluster) CassandraPodSelector ¶
CassandraPodSelector generates a label selector expression which will include all Cassandra pods belonging to a cluster, while excluding snapshot or snapshot-cleanup pods.
func (*Cluster) CreateService ¶
CreateService creates a headless service for the supplied cluster definition.
func (*Cluster) CreateSnapshotCleanupContainer ¶
CreateSnapshotCleanupContainer creates the container that will execute the snapshot cleanup command
func (*Cluster) CreateSnapshotCleanupJob ¶
CreateSnapshotCleanupJob creates a cronjob to trigger the snapshot cleanup
func (*Cluster) CreateSnapshotContainer ¶
CreateSnapshotContainer creates the container used to trigger the snapshot creation
func (*Cluster) CreateSnapshotJob ¶
CreateSnapshotJob creates a cronjob to trigger the creation of a snapshot
func (*Cluster) CreateStatefulSetForRack ¶
func (c *Cluster) CreateStatefulSetForRack(rack *v1alpha1.Rack, customConfigMap *v1.ConfigMap) *appsV1.StatefulSet
CreateStatefulSetForRack creates a StatefulSet based on the rack details
func (*Cluster) CustomConfigMapVolumeName ¶
CustomConfigMapVolumeName returns the custom config map name
func (*Cluster) Definition ¶
Definition returns a copy of the definition of the cluster. Any modifications made to this will be ignored.
func (*Cluster) QualifiedName ¶
QualifiedName is the namespace-qualified name of the cluster
func (*Cluster) RemoveCustomConfigVolumeFromStatefulSet ¶
func (c *Cluster) RemoveCustomConfigVolumeFromStatefulSet(statefulSet *appsV1.StatefulSet, _ *v1alpha1.Rack, _ *v1.ConfigMap)
RemoveCustomConfigVolumeFromStatefulSet updates the provided statefulset to unmount the configmap as a volume
func (*Cluster) SetDefaults ¶
func (c *Cluster) SetDefaults()
SetDefaults uses the helper to set defaults on the cluster
func (*Cluster) UpdateStatefulSetToDesiredState ¶
func (c *Cluster) UpdateStatefulSetToDesiredState(currentStatefulSet *appsV1.StatefulSet, targetRack *v1alpha1.Rack, customConfigMap *v1.ConfigMap)
UpdateStatefulSetToDesiredState updates the current statefulSet to the desired state based on the desired rack definition
type StateFinder ¶
type StateFinder interface { // FindCurrentStateFor returns the reconstructed Cassandra definition by looking // at the current state of all Kubernetes resources associated to it FindCurrentStateFor(desiredCassandra *v1alpha1.Cassandra) (*v1alpha1.Cassandra, error) // FindCurrentConfigHashFor returns the config hash associated to each statefulSet of the given Cassandra FindCurrentConfigHashFor(desiredCassandra *v1alpha1.Cassandra) (map[string]string, error) }
StateFinder finds the actual state of resources in the Kubernetes cluster
func NewStateFinder ¶
func NewStateFinder(client client.Client) StateFinder
NewStateFinder creates a new StateFinder