feat: Add pvc-for-tmp install arg to use PVC for server /tmp dir

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
Scott Seago
2025-08-11 16:56:12 -04:00
parent 6a3f821606
commit c50ab4a6ea
3 changed files with 42 additions and 0 deletions

View File

@@ -90,6 +90,7 @@ type Options struct {
NodeAgentConfigMap string
ItemBlockWorkerCount int
ConcurrentBackups int
PVCForTmp string
NodeAgentDisableHostPath bool
kubeletRootDir string
ServerPriorityClassName string
@@ -191,6 +192,12 @@ func (o *Options) BindFlags(flags *pflag.FlagSet) {
o.NodeAgentConfigMap,
"The name of ConfigMap containing node-agent configurations.",
)
flags.StringVar(
&o.PVCForTmp,
"pvc-for-tmp",
o.PVCForTmp,
"The name of PVC to be used as /tmp dir of Velero server pod. Optional.",
)
flags.IntVar(
&o.ItemBlockWorkerCount,
"item-block-worker-count",
@@ -321,6 +328,7 @@ func (o *Options) AsVeleroOptions() (*install.VeleroOptions, error) {
NodeAgentConfigMap: o.NodeAgentConfigMap,
ItemBlockWorkerCount: o.ItemBlockWorkerCount,
ConcurrentBackups: o.ConcurrentBackups,
PVCForTmp: o.PVCForTmp,
KubeletRootDir: o.kubeletRootDir,
NodeAgentDisableHostPath: o.NodeAgentDisableHostPath,
ServerPriorityClassName: o.ServerPriorityClassName,

View File

@@ -60,6 +60,7 @@ type podTemplateConfig struct {
nodeAgentConfigMap string
itemBlockWorkerCount int
concurrentBackups int
pvcForTmp string
forWindows bool
kubeletRootDir string
nodeAgentDisableHostPath bool
@@ -231,6 +232,12 @@ func WithConcurrentBackups(concurrentBackups int) podTemplateOption {
}
}
func WithPVCForTmp(pvcForTmp string) podTemplateOption {
return func(c *podTemplateConfig) {
c.pvcForTmp = pvcForTmp
}
}
func WithPriorityClassName(priorityClassName string) podTemplateOption {
return func(c *podTemplateConfig) {
c.priorityClassName = priorityClassName
@@ -431,6 +438,28 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1api.Deployme
},
}
if c.pvcForTmp != "" {
deployment.Spec.Template.Spec.Volumes = append(
deployment.Spec.Template.Spec.Volumes,
corev1api.Volume{
Name: "tmp",
VolumeSource: corev1api.VolumeSource{
PersistentVolumeClaim: &corev1api.PersistentVolumeClaimVolumeSource{
ClaimName: c.pvcForTmp,
},
},
},
)
deployment.Spec.Template.Spec.Containers[0].VolumeMounts = append(
deployment.Spec.Template.Spec.Containers[0].VolumeMounts,
corev1api.VolumeMount{
Name: "tmp",
MountPath: "/tmp",
},
)
}
if c.withSecret {
deployment.Spec.Template.Spec.Volumes = append(
deployment.Spec.Template.Spec.Volumes,

View File

@@ -272,6 +272,7 @@ type VeleroOptions struct {
NodeAgentConfigMap string
ItemBlockWorkerCount int
ConcurrentBackups int
PVCForTmp string
KubeletRootDir string
NodeAgentDisableHostPath bool
ServerPriorityClassName string
@@ -366,6 +367,10 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
WithConcurrentBackups(o.ConcurrentBackups),
}
if o.PVCForTmp != "" {
deployOpts = append(deployOpts, WithPVCForTmp(o.PVCForTmp))
}
if o.ServerPriorityClassName != "" {
deployOpts = append(deployOpts, WithPriorityClassName(o.ServerPriorityClassName))
}