Skip to content

Commit 8fc3fd6

Browse files
committed
Add a validated field for mounting an ephemeral volume
Issue: PGO-2271
1 parent 39d291d commit 8fc3fd6

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