Skip to content

Commit d1c228d

Browse files
committed
Add a validated field for mounting an ephemeral volume
Issue: PGO-2271
1 parent 35ecfcb commit d1c228d

File tree

7 files changed

+378
-44
lines changed

7 files changed

+378
-44
lines changed

config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11041,6 +11041,218 @@ spec:
1104111041
- whenUnsatisfiable
1104211042
type: object
1104311043
type: array
11044+
volumes:
11045+
properties:
11046+
temp:
11047+
description: |-
11048+
An ephemeral volume for temporary files.
11049+
More info: https://kubernetes.io/docs/concepts/storage/ephemeral-volumes
11050+
properties:
11051+
accessModes:
11052+
description: |-
11053+
accessModes contains the desired access modes the volume should have.
11054+
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1
11055+
items:
11056+
type: string
11057+
type: array
11058+
x-kubernetes-list-type: atomic
11059+
dataSource:
11060+
description: |-
11061+
dataSource field can be used to specify either:
11062+
* An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot)
11063+
* An existing PVC (PersistentVolumeClaim)
11064+
If the provisioner or an external controller can support the specified data source,
11065+
it will create a new volume based on the contents of the specified data source.
11066+
When the AnyVolumeDataSource feature gate is enabled, dataSource contents will be copied to dataSourceRef,
11067+
and dataSourceRef contents will be copied to dataSource when dataSourceRef.namespace is not specified.
11068+
If the namespace is specified, then dataSourceRef will not be copied to dataSource.
11069+
properties:
11070+
apiGroup:
11071+
description: |-
11072+
APIGroup is the group for the resource being referenced.
11073+
If APIGroup is not specified, the specified Kind must be in the core API group.
11074+
For any other third-party types, APIGroup is required.
11075+
type: string
11076+
kind:
11077+
description: Kind is the type of resource being
11078+
referenced
11079+
type: string
11080+
name:
11081+
description: Name is the name of resource being
11082+
referenced
11083+
type: string
11084+
required:
11085+
- kind
11086+
- name
11087+
type: object
11088+
x-kubernetes-map-type: atomic
11089+
dataSourceRef:
11090+
description: |-
11091+
dataSourceRef specifies the object from which to populate the volume with data, if a non-empty
11092+
volume is desired. This may be any object from a non-empty API group (non
11093+
core object) or a PersistentVolumeClaim object.
11094+
When this field is specified, volume binding will only succeed if the type of
11095+
the specified object matches some installed volume populator or dynamic
11096+
provisioner.
11097+
This field will replace the functionality of the dataSource field and as such
11098+
if both fields are non-empty, they must have the same value. For backwards
11099+
compatibility, when namespace isn't specified in dataSourceRef,
11100+
both fields (dataSource and dataSourceRef) will be set to the same
11101+
value automatically if one of them is empty and the other is non-empty.
11102+
When namespace is specified in dataSourceRef,
11103+
dataSource isn't set to the same value and must be empty.
11104+
There are three important differences between dataSource and dataSourceRef:
11105+
* While dataSource only allows two specific types of objects, dataSourceRef
11106+
allows any non-core object, as well as PersistentVolumeClaim objects.
11107+
* While dataSource ignores disallowed values (dropping them), dataSourceRef
11108+
preserves all values, and generates an error if a disallowed value is
11109+
specified.
11110+
* While dataSource only allows local objects, dataSourceRef allows objects
11111+
in any namespaces.
11112+
(Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled.
11113+
(Alpha) Using the namespace field of dataSourceRef requires the CrossNamespaceVolumeDataSource feature gate to be enabled.
11114+
properties:
11115+
apiGroup:
11116+
description: |-
11117+
APIGroup is the group for the resource being referenced.
11118+
If APIGroup is not specified, the specified Kind must be in the core API group.
11119+
For any other third-party types, APIGroup is required.
11120+
type: string
11121+
kind:
11122+
description: Kind is the type of resource being
11123+
referenced
11124+
type: string
11125+
name:
11126+
description: Name is the name of resource being
11127+
referenced
11128+
type: string
11129+
namespace:
11130+
description: |-
11131+
Namespace is the namespace of resource being referenced
11132+
Note that when a namespace is specified, a gateway.networking.k8s.io/ReferenceGrant object is required in the referent namespace to allow that namespace's owner to accept the reference. See the ReferenceGrant documentation for details.
11133+
(Alpha) This field requires the CrossNamespaceVolumeDataSource feature gate to be enabled.
11134+
type: string
11135+
required:
11136+
- kind
11137+
- name
11138+
type: object
11139+
resources:
11140+
description: |-
11141+
resources represents the minimum resources the volume should have.
11142+
If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements
11143+
that are lower than previous value but must still be higher than capacity recorded in the
11144+
status field of the claim.
11145+
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources
11146+
properties:
11147+
limits:
11148+
additionalProperties:
11149+
anyOf:
11150+
- type: integer
11151+
- type: string
11152+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
11153+
x-kubernetes-int-or-string: true
11154+
description: |-
11155+
Limits describes the maximum amount of compute resources allowed.
11156+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
11157+
type: object
11158+
requests:
11159+
additionalProperties:
11160+
anyOf:
11161+
- type: integer
11162+
- type: string
11163+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
11164+
x-kubernetes-int-or-string: true
11165+
description: |-
11166+
Requests describes the minimum amount of compute resources required.
11167+
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
11168+
otherwise to an implementation-defined value. Requests cannot exceed Limits.
11169+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
11170+
type: object
11171+
type: object
11172+
selector:
11173+
description: selector is a label query over volumes
11174+
to consider for binding.
11175+
properties:
11176+
matchExpressions:
11177+
description: matchExpressions is a list of label
11178+
selector requirements. The requirements are ANDed.
11179+
items:
11180+
description: |-
11181+
A label selector requirement is a selector that contains values, a key, and an operator that
11182+
relates the key and values.
11183+
properties:
11184+
key:
11185+
description: key is the label key that the
11186+
selector applies to.
11187+
type: string
11188+
operator:
11189+
description: |-
11190+
operator represents a key's relationship to a set of values.
11191+
Valid operators are In, NotIn, Exists and DoesNotExist.
11192+
type: string
11193+
values:
11194+
description: |-
11195+
values is an array of string values. If the operator is In or NotIn,
11196+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
11197+
the values array must be empty. This array is replaced during a strategic
11198+
merge patch.
11199+
items:
11200+
type: string
11201+
type: array
11202+
x-kubernetes-list-type: atomic
11203+
required:
11204+
- key
11205+
- operator
11206+
type: object
11207+
type: array
11208+
x-kubernetes-list-type: atomic
11209+
matchLabels:
11210+
additionalProperties:
11211+
type: string
11212+
description: |-
11213+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
11214+
map is equivalent to an element of matchExpressions, whose key field is "key", the
11215+
operator is "In", and the values array contains only "value". The requirements are ANDed.
11216+
type: object
11217+
type: object
11218+
x-kubernetes-map-type: atomic
11219+
storageClassName:
11220+
description: |-
11221+
storageClassName is the name of the StorageClass required by the claim.
11222+
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1
11223+
type: string
11224+
volumeAttributesClassName:
11225+
description: |-
11226+
volumeAttributesClassName may be used to set the VolumeAttributesClass used by this claim.
11227+
If specified, the CSI driver will create or update the volume with the attributes defined
11228+
in the corresponding VolumeAttributesClass. This has a different purpose than storageClassName,
11229+
it can be changed after the claim is created. An empty string value means that no VolumeAttributesClass
11230+
will be applied to the claim but it's not allowed to reset this field to empty string once it is set.
11231+
If unspecified and the PersistentVolumeClaim is unbound, the default VolumeAttributesClass
11232+
will be set by the persistentvolume controller if it exists.
11233+
If the resource referred to by volumeAttributesClass does not exist, this PersistentVolumeClaim will be
11234+
set to a Pending state, as reflected by the modifyVolumeStatus field, until such as a resource
11235+
exists.
11236+
More info: https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/
11237+
(Beta) Using this field requires the VolumeAttributesClass feature gate to be enabled (off by default).
11238+
type: string
11239+
volumeMode:
11240+
description: |-
11241+
volumeMode defines what type of volume is required by the claim.
11242+
Value of Filesystem is implied when not included in claim spec.
11243+
type: string
11244+
volumeName:
11245+
description: volumeName is the binding reference to
11246+
the PersistentVolume backing this claim.
11247+
type: string
11248+
type: object
11249+
x-kubernetes-map-type: atomic
11250+
x-kubernetes-validations:
11251+
- message: missing accessModes
11252+
rule: 0 < size(self.accessModes)
11253+
- message: missing storage request
11254+
rule: has(self.resources.requests.storage)
11255+
type: object
1104411256
walVolumeClaimSpec:
1104511257
description: |-
1104611258
Defines a separate PersistentVolumeClaim for PostgreSQL's write-ahead log.

internal/controller/postgrescluster/instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ func (r *Reconciler) reconcileInstance(
11881188
ctx, cluster, spec,
11891189
primaryCertificate, replicationCertSecretProjection(clusterReplicationSecret),
11901190
postgresDataVolume, postgresWALVolume, tablespaceVolumes,
1191-
&instance.Spec.Template.Spec)
1191+
&instance.Spec.Template)
11921192

11931193
if backupsSpecFound {
11941194
addPGBackRestToInstancePodSpec(

internal/postgres/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ safelink() (
5858
// dataMountPath is where to mount the main data volume.
5959
tablespaceMountPath = "/tablespaces"
6060

61+
// tmpMountPath is where to mount the optional ephemeral volume.
62+
tmpMountPath = "/pgtmp"
63+
6164
// walMountPath is where to mount the optional WAL volume.
6265
walMountPath = "/pgwal"
6366

0 commit comments

Comments
 (0)