-
Notifications
You must be signed in to change notification settings - Fork 832
feat: Add volumeClaimTemplate to advanced DaemonSet #2115
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
Open
chengjoey
wants to merge
1
commit into
openkruise:master
Choose a base branch
from
chengjoey:feat/ads-volumeTemplate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| --- | ||
| title: volumeClaimTemplate for Advanced DaemonSet | ||
| authors: | ||
|
|
||
| - "@chengjoey" | ||
|
|
||
| reviewers: | ||
|
|
||
| - "@ChristianCiach" | ||
|
|
||
| - "@furykerry" | ||
|
|
||
| - "@ABNER-1" | ||
|
|
||
| creation-date: 2025-07-22 | ||
| last-updated: 2025-07-22 | ||
| status: implementable | ||
| --- | ||
|
|
||
| # volumeClaimTemplate for Advanced DaemonSet | ||
| Add volumeClaimTemplate to Advanced DaemonSet | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| - [volumeClaimTemplate for Advanced DaemonSet](#volumeClaimTemplate-for-Advanced-DaemonSet) | ||
| - [Table of Contents](#table-of-contents) | ||
| - [Motivation](#motivation) | ||
| - [Proposal](#proposal) | ||
| - [User Stories](#user-stories) | ||
| - [Story 1](#story-1) | ||
| - [Implementation Details/Notes/Constraints](#implementation-detailsnotesconstraints) | ||
| - [Implementation History](#implementation-history) | ||
|
|
||
| ## Motivation | ||
|
|
||
| Now, Most of the daemon set specs I have seen so far use hostpath volumes for storage. I would like to use local persistent volumes (= LPV) | ||
| instead of hostpath volumes. The problem is that you need a PVC to get a LPV. | ||
| Daemon sets do not allow you to dynamically create a PVC that claims a LPV by using a dedicated storage class like | ||
| stateful sets do (using volumeClaimTemplates). | ||
|
|
||
| We hope to add volumeClaimTemplate to Advanced DaemonSet like stateful sets do. | ||
|
|
||
| ## Proposal | ||
|
|
||
| add volumeClaimTemplate to Advanced DaemonSet like stateful sets do. | ||
|
|
||
| ### API Definition | ||
|
|
||
| ``` | ||
| // DaemonSetSpec defines the desired state of DaemonSet | ||
| type DaemonSetSpec struct { | ||
| // volumeClaimTemplates is a list of claims that pods are allowed to reference. | ||
| // The DaemonSet controller is responsible for mapping network identities to | ||
| // claims in a way that maintains the identity of a pod. Every claim in | ||
| // this list must have at least one matching (by name) volumeMount in one | ||
| // container in the template. A claim in this list takes precedence over | ||
| // any volumes in the template, with the same name. | ||
| // TODO: Define the behavior if a claim already exists with the same name. | ||
| // +optional | ||
| // +kubebuilder:pruning:PreserveUnknownFields | ||
| // +kubebuilder:validation:Schemaless | ||
| VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` | ||
| } | ||
| ``` | ||
|
|
||
| ``` | ||
| apiVersion: apps.kruise.io/v1alpha1 | ||
| kind: DaemonSet | ||
| metadata: | ||
| name: app-ds | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: app-ds | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: app-ds | ||
| spec: | ||
| containers: | ||
| - name: nginx | ||
| image: nginx:latest | ||
| imagePullPolicy: IfNotPresent | ||
| volumeMounts: | ||
| - mountPath: /var/lib/nginx | ||
| name: nginx-data | ||
| volumeClaimTemplates: | ||
| - apiVersion: v1 | ||
| kind: PersistentVolumeClaim | ||
| metadata: | ||
| name: nginx-data | ||
| spec: | ||
| accessModes: | ||
| - ReadWriteOnce | ||
| resources: | ||
| requests: | ||
| storage: 5Gi | ||
| volumeMode: Filesystem | ||
| ``` | ||
|
|
||
| ### User Stories | ||
|
|
||
| #### Story 1 | ||
|
|
||
| there are many people are looking for a DaemonSet-like Workload type that supports defining a PVC per Pod. | ||
|
|
||
| [Feature Request : volumeClaimTemplates available for Daemon Sets](https://github.com/kubernetes/kubernetes/issues/78902) | ||
|
|
||
| [feature request: Add volumeClaimTemplate to advanced DaemonSet](https://github.com/openkruise/kruise/issues/2112) | ||
|
|
||
| ### Implementation Details/Notes/Constraints | ||
|
|
||
| We should consider whether to delete the PVC when a node is deleted, and whether to delete the PVC when the ads is deleted. | ||
| We can add a `PersistentVolumeClaimRetentionPolicy`, with optional values of `Retain` and `Delete`, the default being `Retain`. | ||
|
|
||
| ## Implementation History | ||
|
|
||
| - [ ] 07/22/2025: Proposal submission, implement VolumeClaimTemplates create | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think the default policy should be delete, since there is no easy way to reuse the pvc if the node is deleted.
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.
in addition, we have to introduce a label to match pod and related pvc. In cloneset, pod and pvc with the same
apps.kruise.io/cloneset-instance-idwill be mounted.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.
can we have a discussion in the community call this week ?