Skip to content

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

Merged

Conversation

benjaminjb
Copy link
Contributor

Checklist:

  • Have you added an explanation of what your changes do and why you'd like them to be included?
  • Have you updated or added documentation for the change, as applicable?
  • Have you tested your changes on all related environments with successful results, as applicable?
    • Have you added automated tests?

Type of Changes:

  • New feature
  • Bug fix
  • Documentation
  • Testing enhancement
  • Other

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)?

  • Breaking change (fix or feature that would cause existing functionality to change)

Ability to add PVC (either BYO or create from template) to multiple containers in the Postgres pod

Other Information:
Issues: [PGO-2556]

@benjaminjb benjaminjb force-pushed the benjb/additional-volumes-postgres branch from d9d4932 to f906775 Compare July 30, 2025 20:03
@benjaminjb benjaminjb force-pushed the benjb/additional-volumes-postgres branch from 88d226d to 955087a Compare August 4, 2025 20:32
Change the API to allow users to specify preexisting
PVCs to attach to specified containers in the postgres
instance pods.

Issues: [PGO-2556]
@benjaminjb benjaminjb force-pushed the benjb/additional-volumes-postgres branch from 955087a to 0f1cf63 Compare August 4, 2025 20:33
@benjaminjb benjaminjb force-pushed the benjb/additional-volumes-postgres branch from 22ab593 to a7ea055 Compare August 12, 2025 21:32
//
// +kubebuilder:validation:MinLength=1
// Max length is less than max 63 to allow prepending `volumes-` to name
// +kubebuilder:validation:MaxLength=55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Can this be 63 here and AdditionalVolume.Name override it with 55 there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the spec that results in name having the reqs:

                                allOf:
                                - maxLength: 63
                                - maxLength: 55

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting!

ClaimName string `json:"claimName"`

// The containers to attach this volume to.
// A blank/unset `Containers` field matches all containers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Where did we land on empty-list? Does it mean all or none?

📝 I've used the phrase "when omitted" or "when this is omitted" to explain what happens when a field is missing from the spec.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't quite understand the use-case for adding a volume that is not mounted into any containers... But I could see how a zero value (empty list) could mean "none" while leaving the field off entirely would mean "all"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is still up for debate, to wit:

  • what is the use care for attaching to none? (My squinting suggestion is: you have the volume defined in your sidecar definition and for whatever reason, it's easier to leave it there than to put it into our spec)
  • what is the best way to signal none vs. all? I agree that an explicit "[]" looks more like none than leaving the field off, but that's a real thin line.

Ah, what the heck, let's do it.

}
}

missingContainers = append(missingContainers, names.UnsortedList()...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 Using Delete to subtract from names relies on init and regular containers having unique names together. That's correct and fine, but I wonder if it is worth calling out.

🤔 Should the resulting slice be a Set?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to raise this concern myself... Is it correct though, when you take sidecars into consideration? Couldn't the user add a sidecar to Containers that has the same name as one in InitContainers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering my own question: No, the user could not add a sidecar with the same name as an init container. Ben tried it out and the Pod fails to roll out. He also found this in k8s documentation: “The name of each app and init container in a Pod must be unique; a validation error is thrown for any container sharing a name with another.”

benjaminjb and others added 4 commits August 13, 2025 08:52
@benjaminjb benjaminjb merged commit 7844fe2 into CrunchyData:main Aug 13, 2025
17 checks passed
@benjaminjb benjaminjb changed the title Attach additional volume for postgres, Attach additional volume for postgres Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants