Skip to content

Commit

Permalink
Additional storage volumes for sidecars or types of cassandra files (#…
Browse files Browse the repository at this point in the history
…330)

* Add AdditionalVolumes to StorageConfig

* Update generated files

* Use a named type instead

* Use capitals otherwise deepcopy generation is skipped

* Enrich Statefulsets and PodTemplateSpec with additional volumes

* Fix addVolumes

* Test storage classes used in VolumeClaimTemplates

* Remove namespace from Pattern of PVC name

* Update Pattern of PVC name

* Test mount of additional volume in init container

* Fix case of AdditionalVolumes in CRD

* Add integ test for additional volumes

* No need to use a pointer as PVCSpec is required

* Increase dcReady timeout

* Add packge name fix back

* Fix test by reordering list
  • Loading branch information
cscetbon authored Dec 23, 2020
1 parent 879074d commit 8553579
Show file tree
Hide file tree
Showing 10 changed files with 665 additions and 43 deletions.
142 changes: 142 additions & 0 deletions charts/cass-operator-chart/templates/customresourcedefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6055,6 +6055,148 @@ spec:
description: Describes the persistent storage request of each server
node
properties:
additionalVolumes:
items:
description: StorageConfig defines additional storage configurations
properties:
mountPath:
description: Mount path into cassandra container
type: string
name:
description: Name of the pvc
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?'
type: string
pvcSpec:
description: Persistent volume claim spec
properties:
accessModes:
description: 'AccessModes contains the desired access
modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1'
items:
type: string
type: array
dataSource:
description: This field requires the VolumeSnapshotDataSource
alpha feature gate to be enabled and currently VolumeSnapshot
is the only supported data source. If the provisioner
can support VolumeSnapshot data source, it will create
a new volume and data will be restored to the volume
at the same time. If the provisioner does not support
VolumeSnapshot data source, volume will not be created
and the failure will be reported as an event. In the
future, we plan to support more data source types and
the behavior of the provisioner may change.
properties:
apiGroup:
description: APIGroup is the group for the resource
being referenced. If APIGroup is not specified,
the specified Kind must be in the core API group.
For any other third-party types, APIGroup is required.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
required:
- kind
- name
type: object
resources:
description: 'Resources represents the minimum resources
the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources'
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount
of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount
of compute resources required. If Requests is omitted
for a container, it defaults to Limits if that is
explicitly specified, otherwise to an implementation-defined
value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
selector:
description: A label query over volumes to consider for
binding.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In,
NotIn, Exists and DoesNotExist.
type: string
values:
description: values is an array of string values.
If the operator is In or NotIn, the values
array must be non-empty. If the operator is
Exists or DoesNotExist, the values array must
be empty. This array is replaced during a
strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs.
A single {key,value} in the matchLabels map is equivalent
to an element of matchExpressions, whose key field
is "key", the operator is "In", and the values array
contains only "value". The requirements are ANDed.
type: object
type: object
storageClassName:
description: 'Name of the StorageClass required by the
claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1'
type: string
volumeMode:
description: volumeMode defines what type of volume is
required by the claim. Value of Filesystem is implied
when not included in claim spec. This is a beta feature.
type: string
volumeName:
description: VolumeName is the binding reference to the
PersistentVolume backing this claim.
type: string
type: object
required:
- mountPath
- name
- pvcSpec
type: object
type: array
cassandraDataVolumeClaimSpec:
description: PersistentVolumeClaimSpec describes the common attributes
of storage devices and allows a Source for provider-specific attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6067,6 +6067,148 @@ spec:
description: Describes the persistent storage request of each server
node
properties:
additionalVolumes:
items:
description: StorageConfig defines additional storage configurations
properties:
mountPath:
description: Mount path into cassandra container
type: string
name:
description: Name of the pvc
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?'
type: string
pvcSpec:
description: Persistent volume claim spec
properties:
accessModes:
description: 'AccessModes contains the desired access
modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1'
items:
type: string
type: array
dataSource:
description: This field requires the VolumeSnapshotDataSource
alpha feature gate to be enabled and currently VolumeSnapshot
is the only supported data source. If the provisioner
can support VolumeSnapshot data source, it will create
a new volume and data will be restored to the volume
at the same time. If the provisioner does not support
VolumeSnapshot data source, volume will not be created
and the failure will be reported as an event. In the
future, we plan to support more data source types and
the behavior of the provisioner may change.
properties:
apiGroup:
description: APIGroup is the group for the resource
being referenced. If APIGroup is not specified,
the specified Kind must be in the core API group.
For any other third-party types, APIGroup is required.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
required:
- kind
- name
type: object
resources:
description: 'Resources represents the minimum resources
the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources'
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount
of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount
of compute resources required. If Requests is omitted
for a container, it defaults to Limits if that is
explicitly specified, otherwise to an implementation-defined
value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
selector:
description: A label query over volumes to consider for
binding.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In,
NotIn, Exists and DoesNotExist.
type: string
values:
description: values is an array of string values.
If the operator is In or NotIn, the values
array must be non-empty. If the operator is
Exists or DoesNotExist, the values array must
be empty. This array is replaced during a
strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs.
A single {key,value} in the matchLabels map is equivalent
to an element of matchExpressions, whose key field
is "key", the operator is "In", and the values array
contains only "value". The requirements are ANDed.
type: object
type: object
storageClassName:
description: 'Name of the StorageClass required by the
claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1'
type: string
volumeMode:
description: volumeMode defines what type of volume is
required by the claim. Value of Filesystem is implied
when not included in claim spec. This is a beta feature.
type: string
volumeName:
description: VolumeName is the binding reference to the
PersistentVolume backing this claim.
type: string
type: object
required:
- mountPath
- name
- pvcSpec
type: object
type: array
cassandraDataVolumeClaimSpec:
description: PersistentVolumeClaimSpec describes the common attributes
of storage devices and allows a Source for provider-specific attributes
Expand Down
14 changes: 14 additions & 0 deletions operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,22 @@ type DseWorkloads struct {
SearchEnabled bool `json:"searchEnabled,omitempty"`
}

// StorageConfig defines additional storage configurations
type AdditionalVolumes struct {
// Mount path into cassandra container
MountPath string `json:"mountPath"`
// Name of the pvc
// +kubebuilder:validation:Pattern=[a-z0-9]([-a-z0-9]*[a-z0-9])?
Name string `json:"name"`
// Persistent volume claim spec
PVCSpec corev1.PersistentVolumeClaimSpec `json:"pvcSpec"`
}

type AdditionalVolumesSlice []AdditionalVolumes

type StorageConfig struct {
CassandraDataVolumeClaimSpec *corev1.PersistentVolumeClaimSpec `json:"cassandraDataVolumeClaimSpec,omitempty"`
AdditionalVolumes AdditionalVolumesSlice `json:"additionalVolumes,omitempty"`
}

// GetRacks is a getter for the Rack slice in the spec
Expand Down
Loading

0 comments on commit 8553579

Please sign in to comment.