mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-04 15:16:58 +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
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ type VeleroOptions struct {
|
||||
BSLConfig map[string]string
|
||||
VSLConfig map[string]string
|
||||
DefaultResticMaintenanceFrequency time.Duration
|
||||
Plugins []string
|
||||
}
|
||||
|
||||
// AllResources returns a list of all resources necessary to install Velero, in the appropriate order, into a Kubernetes cluster.
|
||||
@@ -266,13 +267,16 @@ func AllResources(o *VeleroOptions) (*unstructured.UnstructuredList, error) {
|
||||
deployOpts = append(deployOpts, WithRestoreOnly())
|
||||
}
|
||||
|
||||
if len(o.Plugins) > 0 {
|
||||
deployOpts = append(deployOpts, WithPlugins(o.Plugins))
|
||||
}
|
||||
|
||||
deploy := Deployment(o.Namespace, deployOpts...)
|
||||
|
||||
appendUnstructured(resources, deploy)
|
||||
|
||||
if o.UseRestic {
|
||||
ds := DaemonSet(o.Namespace,
|
||||
|
||||
WithAnnotations(o.PodAnnotations),
|
||||
WithImage(o.Image),
|
||||
WithResources(o.ResticPodResources),
|
||||
|
||||
Reference in New Issue
Block a user