-
Notifications
You must be signed in to change notification settings - Fork 622
Attach additional volume for postgres, #4210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Attach additional volume for postgres, #4210
Conversation
pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go
Outdated
Show resolved
Hide resolved
pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go
Outdated
Show resolved
Hide resolved
pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go
Outdated
Show resolved
Hide resolved
pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go
Show resolved
Hide resolved
internal/naming/names.go
Outdated
// volume for instance. | ||
func AdditionalVolume(cluster *v1beta1.PostgresCluster, | ||
volume *v1beta1.AdditionalVolume) metav1.ObjectMeta { | ||
// TODO: What's the name for the PVC if not given? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 The name
field, I imagine. That field should have validation that rejects weird filepath stuff (e.g. slash) and is also valid for K8s API name (subdomain?). We have a few predefined types for names.
[PersistentVolumeClaim (PVC) names are DNS subdomains](https://releases.k8s.io/v1.23.0/pkg/apis/core/validation/validation.go#L2066). |
postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1/shared_types.go
Lines 32 to 33 in 899c4a0
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?([.][a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` | |
type DNS1123Subdomain = string |
d9d4932
to
f906775
Compare
pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go
Outdated
Show resolved
Hide resolved
pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go
Outdated
Show resolved
Hide resolved
pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go
Outdated
Show resolved
Hide resolved
pkg/apis/postgres-operator.crunchydata.com/v1/postgrescluster_types.go
Outdated
Show resolved
Hide resolved
additionalVolumeRequest.ClaimName) | ||
|
||
additionalVolume := corev1.Volume{ | ||
Name: additionalVolumeMount.Name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Ah, hmm. Volume names must be unique in a pod. What happens If someone uses postgres-data
for their volume name? Maybe we should prefix with volume-
?
🤔 🤔 What other (Pod) validation happens on this name in K8s? Maybe a limit on the length?
postgres-operator/internal/postgres/reconcile.go
Lines 26 to 28 in 6a30d72
func DataVolumeMount() corev1.VolumeMount { | |
return corev1.VolumeMount{Name: "postgres-data", MountPath: dataMountPath} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the pod.spec.volumes, its says "Must be a DNS_LABEL and unique within the pod." (cite)
That's what the code comment says, at least.
+1 for a prefix that prevents other problems
ClaimName: additionalVolumeMount.Name, | ||
ReadOnly: additionalVolumeRequest.ReadOnly, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ I'm getting a little mixed up with which name is where. Should this be additionalVolumeRequest.claimName
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little confusing because I'm switching from using the derived Mount spec to our AdditionalVolume spec -- I think I can clean this up by (a) using the request name above, (b) creating the Mount spec with the ReadOnly field, and (c) sticking to the Mount spec here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, tackling this and the comment re: naming the volumes, the code is less intuitive than I wanted
|
||
// addAdditionalVolumesToSpecifiedContainers adds additional volumes to the specified | ||
// containers in the specified pod | ||
func addAdditionalVolumesToSpecifiedContainers(template *corev1.PodTemplateSpec, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 I like that this takes a template.
Co-authored-by: Chris Bandy <[email protected]>
Checklist:
Type of Changes:
What is the current behavior (link to any open issues here)?
Only can add additional volumes to database container through abuse of the tablespace volumes.
What is the new behavior (if this is a feature change)?
Ability to add PVC (either BYO or create from template) to multiple containers in the Postgres pod
Other Information:
Issues: [PGO-2556]