mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-26 09:54:23 +00:00
Add --plugins flag to velero install (#1930)
* Add plugins flag to install Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
committed by
KubeKween
parent
db59d8d4bc
commit
f009fe9bd1
@@ -24,6 +24,8 @@ import (
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/vmware-tanzu/velero/pkg/builder"
|
||||
)
|
||||
|
||||
type podTemplateOption func(*podTemplateConfig)
|
||||
@@ -36,6 +38,7 @@ type podTemplateConfig struct {
|
||||
resources corev1.ResourceRequirements
|
||||
withSecret bool
|
||||
defaultResticMaintenanceFrequency time.Duration
|
||||
plugins []string
|
||||
}
|
||||
|
||||
func WithImage(image string) podTemplateOption {
|
||||
@@ -91,6 +94,12 @@ func WithDefaultResticMaintenanceFrequency(val time.Duration) podTemplateOption
|
||||
}
|
||||
}
|
||||
|
||||
func WithPlugins(plugins []string) podTemplateOption {
|
||||
return func(c *podTemplateConfig) {
|
||||
c.plugins = plugins
|
||||
}
|
||||
}
|
||||
|
||||
func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment {
|
||||
// TODO: Add support for server args
|
||||
c := &podTemplateConfig{
|
||||
@@ -236,5 +245,13 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment
|
||||
deployment.Spec.Template.Spec.Containers[0].Args = append(deployment.Spec.Template.Spec.Containers[0].Args, fmt.Sprintf("--default-restic-prune-frequency=%v", c.defaultResticMaintenanceFrequency))
|
||||
}
|
||||
|
||||
if len(c.plugins) > 0 {
|
||||
for _, image := range c.plugins {
|
||||
container := *builder.ForPluginContainer(image, pullPolicy).Result()
|
||||
deployment.Spec.Template.Spec.InitContainers = append(deployment.Spec.Template.Spec.InitContainers, container)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return deployment
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user