From 74da9aa3c478180876724748f7c5b3d523f0d7b2 Mon Sep 17 00:00:00 2001 From: Lyndon-Li Date: Fri, 23 Sep 2022 10:09:26 +0800 Subject: [PATCH] rename daemonset Signed-off-by: Lyndon-Li --- .gitignore | 2 +- Tiltfile | 8 ++-- .../plugins/{restic.yaml => node-agent.yaml} | 10 ++-- pkg/cmd/cli/debug/debug.go | 2 +- pkg/cmd/cli/install/install.go | 46 +++++++++---------- pkg/cmd/cli/nodeagent/node_agent.go | 37 +++++++++++++++ pkg/cmd/cli/{restic => nodeagent}/server.go | 8 ++-- .../cli/{restic => nodeagent}/server_test.go | 2 +- pkg/cmd/cli/restic/restic.go | 1 - pkg/cmd/velero/velero.go | 3 ++ pkg/install/daemonset.go | 16 +++---- pkg/install/daemonset_test.go | 2 +- pkg/install/install.go | 4 +- pkg/install/resources.go | 26 +++++------ pkg/nodeagent/node_agent.go | 2 +- test/e2e/util/velero/install.go | 28 +++++------ .../examples/{restic.yaml => node-agent.yaml} | 10 ++-- 17 files changed, 123 insertions(+), 84 deletions(-) rename design/CLI/PoC/overlays/plugins/{restic.yaml => node-agent.yaml} (93%) create mode 100644 pkg/cmd/cli/nodeagent/node_agent.go rename pkg/cmd/cli/{restic => nodeagent}/server.go (98%) rename pkg/cmd/cli/{restic => nodeagent}/server_test.go (99%) rename tilt-resources/examples/{restic.yaml => node-agent.yaml} (93%) diff --git a/.gitignore b/.gitignore index 18482277e2..a741e968b8 100644 --- a/.gitignore +++ b/.gitignore @@ -46,7 +46,7 @@ _tiltbuild tilt-resources/tilt-settings.json tilt-resources/velero_v1_backupstoragelocation.yaml tilt-resources/deployment.yaml -tilt-resources/restic.yaml +tilt-resources/node-agent.yaml tilt-resources/cloud test/e2e/report.xml diff --git a/Tiltfile b/Tiltfile index 0d9a642632..2a7d97eb41 100644 --- a/Tiltfile +++ b/Tiltfile @@ -17,7 +17,7 @@ k8s_yaml([ # default values settings = { "default_registry": "docker.io/velero", - "enable_restic": False, + "use_node_agent": False, "enable_debug": False, "debug_continue_on_start": True, # Continue the velero process by default when in debug mode "create_backup_locations": False, @@ -34,9 +34,9 @@ k8s_yaml(kustomize('tilt-resources')) k8s_yaml('tilt-resources/deployment.yaml') if settings.get("enable_debug"): k8s_resource('velero', port_forwards = '2345') - # TODO: Need to figure out how to apply port forwards for all restic pods -if settings.get("enable_restic"): - k8s_yaml('tilt-resources/restic.yaml') + # TODO: Need to figure out how to apply port forwards for all node-agent pods +if settings.get("use_node_agent"): + k8s_yaml('tilt-resources/node-agent.yaml') if settings.get("create_backup_locations"): k8s_yaml('tilt-resources/velero_v1_backupstoragelocation.yaml') if settings.get("setup-minio"): diff --git a/design/CLI/PoC/overlays/plugins/restic.yaml b/design/CLI/PoC/overlays/plugins/node-agent.yaml similarity index 93% rename from design/CLI/PoC/overlays/plugins/restic.yaml rename to design/CLI/PoC/overlays/plugins/node-agent.yaml index 576ea2ff50..dbb4ce18db 100644 --- a/design/CLI/PoC/overlays/plugins/restic.yaml +++ b/design/CLI/PoC/overlays/plugins/node-agent.yaml @@ -5,22 +5,22 @@ metadata: creationTimestamp: null labels: component: velero - name: restic + name: node-agent namespace: velero spec: selector: matchLabels: - name: restic + name: node-agent template: metadata: creationTimestamp: null labels: component: velero - name: restic + name: node-agent spec: containers: - args: - - restic + - node-agent - server command: - /velero @@ -43,7 +43,7 @@ spec: value: /credentials/cloud image: velero/velero:latest imagePullPolicy: Always - name: restic + name: node-agent resources: {} volumeMounts: - mountPath: /host_pods diff --git a/pkg/cmd/cli/debug/debug.go b/pkg/cmd/cli/debug/debug.go index e324f26312..fba0a1af35 100644 --- a/pkg/cmd/cli/debug/debug.go +++ b/pkg/cmd/cli/debug/debug.go @@ -152,7 +152,7 @@ func NewCommand(f client.Factory) *cobra.Command { c := &cobra.Command{ Use: "debug", Short: "Generate debug bundle", - Long: `Generate a tarball containing the logs of velero deployment, plugin logs, restic DaemonSet, + Long: `Generate a tarball containing the logs of velero deployment, plugin logs, node-agent DaemonSet, specs of resources created by velero server, and optionally the logs of backup and restore.`, Run: func(c *cobra.Command, args []string) { flags := c.Flags() diff --git a/pkg/cmd/cli/install/install.go b/pkg/cmd/cli/install/install.go index fe4bebea30..0a4ba4c168 100644 --- a/pkg/cmd/cli/install/install.go +++ b/pkg/cmd/cli/install/install.go @@ -55,17 +55,17 @@ type InstallOptions struct { VeleroPodMemRequest string VeleroPodCPULimit string VeleroPodMemLimit string - ResticPodCPURequest string - ResticPodMemRequest string - ResticPodCPULimit string - ResticPodMemLimit string + NodeAgentPodCPURequest string + NodeAgentPodMemRequest string + NodeAgentPodCPULimit string + NodeAgentPodMemLimit string RestoreOnly bool SecretFile string NoSecret bool DryRun bool BackupStorageConfig flag.Map VolumeSnapshotConfig flag.Map - UseRestic bool + UseNodeAgent bool Wait bool UseVolumeSnapshots bool DefaultRepoMaintenanceFrequency time.Duration @@ -95,23 +95,23 @@ func (o *InstallOptions) BindFlags(flags *pflag.FlagSet) { flags.StringVar(&o.VeleroPodMemRequest, "velero-pod-mem-request", o.VeleroPodMemRequest, `Memory request for Velero pod. A value of "0" is treated as unbounded. Optional.`) flags.StringVar(&o.VeleroPodCPULimit, "velero-pod-cpu-limit", o.VeleroPodCPULimit, `CPU limit for Velero pod. A value of "0" is treated as unbounded. Optional.`) flags.StringVar(&o.VeleroPodMemLimit, "velero-pod-mem-limit", o.VeleroPodMemLimit, `Memory limit for Velero pod. A value of "0" is treated as unbounded. Optional.`) - flags.StringVar(&o.ResticPodCPURequest, "restic-pod-cpu-request", o.ResticPodCPURequest, `CPU request for restic pod. A value of "0" is treated as unbounded. Optional.`) - flags.StringVar(&o.ResticPodMemRequest, "restic-pod-mem-request", o.ResticPodMemRequest, `Memory request for restic pod. A value of "0" is treated as unbounded. Optional.`) - flags.StringVar(&o.ResticPodCPULimit, "restic-pod-cpu-limit", o.ResticPodCPULimit, `CPU limit for restic pod. A value of "0" is treated as unbounded. Optional.`) - flags.StringVar(&o.ResticPodMemLimit, "restic-pod-mem-limit", o.ResticPodMemLimit, `Memory limit for restic pod. A value of "0" is treated as unbounded. Optional.`) + flags.StringVar(&o.NodeAgentPodCPURequest, "node-agent-pod-cpu-request", o.NodeAgentPodCPURequest, `CPU request for node-agent pod. A value of "0" is treated as unbounded. Optional.`) + flags.StringVar(&o.NodeAgentPodMemRequest, "node-agent-pod-mem-request", o.NodeAgentPodMemRequest, `Memory request for node-agent pod. A value of "0" is treated as unbounded. Optional.`) + flags.StringVar(&o.NodeAgentPodCPULimit, "node-agent-pod-cpu-limit", o.NodeAgentPodCPULimit, `CPU limit for node-agent pod. A value of "0" is treated as unbounded. Optional.`) + flags.StringVar(&o.NodeAgentPodMemLimit, "node-agent-pod-mem-limit", o.NodeAgentPodMemLimit, `Memory limit for node-agent pod. A value of "0" is treated as unbounded. Optional.`) flags.Var(&o.BackupStorageConfig, "backup-location-config", "Configuration to use for the backup storage location. Format is key1=value1,key2=value2") flags.Var(&o.VolumeSnapshotConfig, "snapshot-location-config", "Configuration to use for the volume snapshot location. Format is key1=value1,key2=value2") flags.BoolVar(&o.UseVolumeSnapshots, "use-volume-snapshots", o.UseVolumeSnapshots, "Whether or not to create snapshot location automatically. Set to false if you do not plan to create volume snapshots via a storage provider.") flags.BoolVar(&o.RestoreOnly, "restore-only", o.RestoreOnly, "Run the server in restore-only mode. Optional.") flags.BoolVar(&o.DryRun, "dry-run", o.DryRun, "Generate resources, but don't send them to the cluster. Use with -o. Optional.") - flags.BoolVar(&o.UseRestic, "use-restic", o.UseRestic, "Create restic daemonset. Optional.") + flags.BoolVar(&o.UseNodeAgent, "use-node-agent", o.UseNodeAgent, "Create node-agent daemonset. Optional.") flags.BoolVar(&o.Wait, "wait", o.Wait, "Wait for Velero deployment to be ready. Optional.") flags.DurationVar(&o.DefaultRepoMaintenanceFrequency, "default-repo-maintain-frequency", o.DefaultRepoMaintenanceFrequency, "How often 'maintain' is run for backup repositories by default. Optional.") flags.DurationVar(&o.GarbageCollectionFrequency, "garbage-collection-frequency", o.GarbageCollectionFrequency, "How often the garbage collection runs for expired backups.(default 1h)") flags.Var(&o.Plugins, "plugins", "Plugin container images to install into the Velero Deployment") flags.BoolVar(&o.CRDsOnly, "crds-only", o.CRDsOnly, "Only generate CustomResourceDefinition resources. Useful for updating CRDs for an existing Velero install.") flags.StringVar(&o.CACertFile, "cacert", o.CACertFile, "File containing a certificate bundle to use when verifying TLS connections to the object store. Optional.") - flags.StringVar(&o.Features, "features", o.Features, "Comma separated list of Velero feature flags to be set on the Velero deployment and the restic daemonset, if restic is enabled") + flags.StringVar(&o.Features, "features", o.Features, "Comma separated list of Velero feature flags to be set on the Velero deployment and the node-agent daemonset, if node-agent is enabled") flags.BoolVar(&o.DefaultVolumesToFsBackup, "default-volumes-to-fs-backup", o.DefaultVolumesToFsBackup, "Bool flag to configure Velero server to use pod volume file system backup by default for all volumes on all backups. Optional.") flags.StringVar(&o.UploaderType, "uploader-type", o.UploaderType, fmt.Sprintf("The type of uploader to transfer the data of pod volumes, the supported values are '%s', '%s'", uploader.ResticType, uploader.KopiaType)) } @@ -130,10 +130,10 @@ func NewInstallOptions() *InstallOptions { VeleroPodMemRequest: install.DefaultVeleroPodMemRequest, VeleroPodCPULimit: install.DefaultVeleroPodCPULimit, VeleroPodMemLimit: install.DefaultVeleroPodMemLimit, - ResticPodCPURequest: install.DefaultResticPodCPURequest, - ResticPodMemRequest: install.DefaultResticPodMemRequest, - ResticPodCPULimit: install.DefaultResticPodCPULimit, - ResticPodMemLimit: install.DefaultResticPodMemLimit, + NodeAgentPodCPURequest: install.DefaultNodeAgentPodCPURequest, + NodeAgentPodMemRequest: install.DefaultNodeAgentPodMemRequest, + NodeAgentPodCPULimit: install.DefaultNodeAgentPodCPULimit, + NodeAgentPodMemLimit: install.DefaultNodeAgentPodMemLimit, // Default to creating a VSL unless we're told otherwise UseVolumeSnapshots: true, NoDefaultBackupLocation: false, @@ -171,7 +171,7 @@ func (o *InstallOptions) AsVeleroOptions() (*install.VeleroOptions, error) { if err != nil { return nil, err } - resticPodResources, err := kubeutil.ParseResourceRequirements(o.ResticPodCPURequest, o.ResticPodMemRequest, o.ResticPodCPULimit, o.ResticPodMemLimit) + nodeAgentPodResources, err := kubeutil.ParseResourceRequirements(o.NodeAgentPodCPURequest, o.NodeAgentPodMemRequest, o.NodeAgentPodCPULimit, o.NodeAgentPodMemLimit) if err != nil { return nil, err } @@ -186,10 +186,10 @@ func (o *InstallOptions) AsVeleroOptions() (*install.VeleroOptions, error) { PodLabels: o.PodLabels.Data(), ServiceAccountAnnotations: o.ServiceAccountAnnotations.Data(), VeleroPodResources: veleroPodResources, - ResticPodResources: resticPodResources, + NodeAgentPodResources: nodeAgentPodResources, SecretData: secretData, RestoreOnly: o.RestoreOnly, - UseRestic: o.UseRestic, + UseNodeAgent: o.UseNodeAgent, UseVolumeSnapshots: o.UseVolumeSnapshots, BSLConfig: o.BackupStorageConfig.Data(), VSLConfig: o.VolumeSnapshotConfig.Data(), @@ -216,7 +216,7 @@ A prefix within the bucket and configuration for the backup store location may a Additionally, volume snapshot information for the same provider may be supplied. All required CustomResourceDefinitions will be installed to the server, as well as the -Velero Deployment and associated Restic DaemonSet. +Velero Deployment and associated node-agent DaemonSet. The provided secret data will be created in a Secret named 'cloud-credentials'. @@ -302,8 +302,8 @@ func (o *InstallOptions) Run(c *cobra.Command, f client.Factory) error { return errors.Wrap(err, errorMsg) } - if o.UseRestic { - fmt.Println("Waiting for Velero restic daemonset to be ready.") + if o.UseNodeAgent { + fmt.Println("Waiting for node-agent daemonset to be ready.") if _, err = install.DaemonSetIsReady(dynamicFactory, o.Namespace); err != nil { return errors.Wrap(err, errorMsg) } @@ -393,8 +393,8 @@ func (o *InstallOptions) Validate(c *cobra.Command, args []string, f client.Fact } } - if o.DefaultVolumesToFsBackup && !o.UseRestic { - return errors.New("--use-restic is required when using --default-volumes-to-fs-backup") + if o.DefaultVolumesToFsBackup && !o.UseNodeAgent { + return errors.New("--use-node-agent is required when using --default-volumes-to-fs-backup") } switch { diff --git a/pkg/cmd/cli/nodeagent/node_agent.go b/pkg/cmd/cli/nodeagent/node_agent.go new file mode 100644 index 0000000000..7b0b6ebf0b --- /dev/null +++ b/pkg/cmd/cli/nodeagent/node_agent.go @@ -0,0 +1,37 @@ +/* +Copyright The Velero Contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package nodeagent + +import ( + "github.com/spf13/cobra" + + "github.com/vmware-tanzu/velero/pkg/client" +) + +func NewCommand(f client.Factory) *cobra.Command { + c := &cobra.Command{ + Use: "node-agent", + Short: "Work with node-agent", + Long: "Work with node-agent", + } + + c.AddCommand( + NewServerCommand(f), + ) + + return c +} diff --git a/pkg/cmd/cli/restic/server.go b/pkg/cmd/cli/nodeagent/server.go similarity index 98% rename from pkg/cmd/cli/restic/server.go rename to pkg/cmd/cli/nodeagent/server.go index e7b133ac69..fed76d1fa8 100644 --- a/pkg/cmd/cli/restic/server.go +++ b/pkg/cmd/cli/nodeagent/server.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package restic +package nodeagent import ( "context" @@ -74,15 +74,15 @@ func NewServerCommand(f client.Factory) *cobra.Command { command := &cobra.Command{ Use: "server", - Short: "Run the velero restic server", - Long: "Run the velero restic server", + Short: "Run the velero node-agent server", + Long: "Run the velero node-agent server", Hidden: true, Run: func(c *cobra.Command, args []string) { logLevel := logLevelFlag.Parse() logrus.Infof("Setting log-level to %s", strings.ToUpper(logLevel.String())) logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Infof("Starting Velero restic server %s (%s)", buildinfo.Version, buildinfo.FormattedGitSHA()) + logger.Infof("Starting Velero node-agent server %s (%s)", buildinfo.Version, buildinfo.FormattedGitSHA()) f.SetBasename(fmt.Sprintf("%s-%s", c.Parent().Name(), c.Name())) s, err := newResticServer(logger, f, defaultMetricsAddress) diff --git a/pkg/cmd/cli/restic/server_test.go b/pkg/cmd/cli/nodeagent/server_test.go similarity index 99% rename from pkg/cmd/cli/restic/server_test.go rename to pkg/cmd/cli/nodeagent/server_test.go index ff222e996f..469d5b8005 100644 --- a/pkg/cmd/cli/restic/server_test.go +++ b/pkg/cmd/cli/nodeagent/server_test.go @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package restic +package nodeagent import ( "context" diff --git a/pkg/cmd/cli/restic/restic.go b/pkg/cmd/cli/restic/restic.go index 39909c23c5..744cdbd5fa 100644 --- a/pkg/cmd/cli/restic/restic.go +++ b/pkg/cmd/cli/restic/restic.go @@ -32,7 +32,6 @@ func NewCommand(f client.Factory) *cobra.Command { c.AddCommand( repo.NewRepositoryCommand(f), - NewServerCommand(f), ) return c diff --git a/pkg/cmd/velero/velero.go b/pkg/cmd/velero/velero.go index 8775f69cd0..2ce8950698 100644 --- a/pkg/cmd/velero/velero.go +++ b/pkg/cmd/velero/velero.go @@ -49,6 +49,8 @@ import ( runplugin "github.com/vmware-tanzu/velero/pkg/cmd/server/plugin" veleroflag "github.com/vmware-tanzu/velero/pkg/cmd/util/flag" "github.com/vmware-tanzu/velero/pkg/features" + + "github.com/vmware-tanzu/velero/pkg/cmd/cli/nodeagent" ) func NewCommand(name string) *cobra.Command { @@ -103,6 +105,7 @@ operations can also be performed as 'velero backup get' and 'velero schedule cre schedule.NewCommand(f), restore.NewCommand(f), server.NewCommand(f), + nodeagent.NewCommand(f), version.NewCommand(f), get.NewCommand(f), install.NewCommand(f), diff --git a/pkg/install/daemonset.go b/pkg/install/daemonset.go index fb88647632..7aca8c66db 100644 --- a/pkg/install/daemonset.go +++ b/pkg/install/daemonset.go @@ -43,19 +43,19 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.DaemonSet { } - resticArgs := []string{ - "restic", + daemonSetArgs := []string{ + "node-agent", "server", } if len(c.features) > 0 { - resticArgs = append(resticArgs, fmt.Sprintf("--features=%s", strings.Join(c.features, ","))) + daemonSetArgs = append(daemonSetArgs, fmt.Sprintf("--features=%s", strings.Join(c.features, ","))) } userID := int64(0) mountPropagationMode := corev1.MountPropagationHostToContainer daemonSet := &appsv1.DaemonSet{ - ObjectMeta: objectMeta(namespace, "restic"), + ObjectMeta: objectMeta(namespace, "node-agent"), TypeMeta: metav1.TypeMeta{ Kind: "DaemonSet", APIVersion: appsv1.SchemeGroupVersion.String(), @@ -63,13 +63,13 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.DaemonSet { Spec: appsv1.DaemonSetSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ - "name": "restic", + "name": "node-agent", }, }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: podLabels(c.labels, map[string]string{ - "name": "restic", + "name": "node-agent", }), Annotations: c.annotations, }, @@ -96,13 +96,13 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.DaemonSet { }, Containers: []corev1.Container{ { - Name: "restic", + Name: "node-agent", Image: c.image, ImagePullPolicy: pullPolicy, Command: []string{ "/velero", }, - Args: resticArgs, + Args: daemonSetArgs, VolumeMounts: []corev1.VolumeMount{ { diff --git a/pkg/install/daemonset_test.go b/pkg/install/daemonset_test.go index db9976fe56..4a3d9f9aa6 100644 --- a/pkg/install/daemonset_test.go +++ b/pkg/install/daemonset_test.go @@ -26,7 +26,7 @@ import ( func TestDaemonSet(t *testing.T) { ds := DaemonSet("velero") - assert.Equal(t, "restic", ds.Spec.Template.Spec.Containers[0].Name) + assert.Equal(t, "node-agent", ds.Spec.Template.Spec.Containers[0].Name) assert.Equal(t, "velero", ds.ObjectMeta.Namespace) ds = DaemonSet("velero", WithImage("velero/velero:v0.11")) diff --git a/pkg/install/install.go b/pkg/install/install.go index e163be95ef..d378716ed5 100644 --- a/pkg/install/install.go +++ b/pkg/install/install.go @@ -207,7 +207,7 @@ func DeploymentIsReady(factory client.DynamicFactory, namespace string) (bool, e return isReady, err } -// DaemonSetIsReady will poll the kubernetes API server to ensure the restic daemonset is ready, i.e. that +// DaemonSetIsReady will poll the kubernetes API server to ensure the node-agent daemonset is ready, i.e. that // pods are scheduled and available on all of the desired nodes. func DaemonSetIsReady(factory client.DynamicFactory, namespace string) (bool, error) { gvk := schema.FromAPIVersionAndKind(appsv1.SchemeGroupVersion.String(), "DaemonSet") @@ -226,7 +226,7 @@ func DaemonSetIsReady(factory client.DynamicFactory, namespace string) (bool, er var readyObservations int32 err = wait.PollImmediate(time.Second, time.Minute, func() (bool, error) { - unstructuredDaemonSet, err := c.Get("restic", metav1.GetOptions{}) + unstructuredDaemonSet, err := c.Get("node-agent", metav1.GetOptions{}) if apierrors.IsNotFound(err) { return false, nil } else if err != nil { diff --git a/pkg/install/resources.go b/pkg/install/resources.go index aa9b5f237e..ddcce46684 100644 --- a/pkg/install/resources.go +++ b/pkg/install/resources.go @@ -31,15 +31,15 @@ import ( ) var ( - DefaultVeleroPodCPURequest = "500m" - DefaultVeleroPodMemRequest = "128Mi" - DefaultVeleroPodCPULimit = "1000m" - DefaultVeleroPodMemLimit = "512Mi" - DefaultResticPodCPURequest = "500m" - DefaultResticPodMemRequest = "512Mi" - DefaultResticPodCPULimit = "1000m" - DefaultResticPodMemLimit = "1Gi" - DefaultVeleroNamespace = "velero" + DefaultVeleroPodCPURequest = "500m" + DefaultVeleroPodMemRequest = "128Mi" + DefaultVeleroPodCPULimit = "1000m" + DefaultVeleroPodMemLimit = "512Mi" + DefaultNodeAgentPodCPURequest = "500m" + DefaultNodeAgentPodMemRequest = "512Mi" + DefaultNodeAgentPodCPULimit = "1000m" + DefaultNodeAgentPodMemLimit = "1Gi" + DefaultVeleroNamespace = "velero" ) func Labels() map[string]string { @@ -218,10 +218,10 @@ type VeleroOptions struct { PodLabels map[string]string ServiceAccountAnnotations map[string]string VeleroPodResources corev1.ResourceRequirements - ResticPodResources corev1.ResourceRequirements + NodeAgentPodResources corev1.ResourceRequirements SecretData []byte RestoreOnly bool - UseRestic bool + UseNodeAgent bool UseVolumeSnapshots bool BSLConfig map[string]string VSLConfig map[string]string @@ -311,12 +311,12 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList { appendUnstructured(resources, deploy) - if o.UseRestic { + if o.UseNodeAgent { dsOpts := []podTemplateOption{ WithAnnotations(o.PodAnnotations), WithLabels(o.PodLabels), WithImage(o.Image), - WithResources(o.ResticPodResources), + WithResources(o.NodeAgentPodResources), WithSecret(secretPresent), } if len(o.Features) > 0 { diff --git a/pkg/nodeagent/node_agent.go b/pkg/nodeagent/node_agent.go index fcfd10931f..cf1d32fbb5 100644 --- a/pkg/nodeagent/node_agent.go +++ b/pkg/nodeagent/node_agent.go @@ -32,7 +32,7 @@ import ( const ( // daemonSet is the name of the Velero node agent daemonset. - daemonSet = "restic" + daemonSet = "node-agent" ) var ( diff --git a/test/e2e/util/velero/install.go b/test/e2e/util/velero/install.go index 0b3e5962ba..8717e60c09 100644 --- a/test/e2e/util/velero/install.go +++ b/test/e2e/util/velero/install.go @@ -87,7 +87,7 @@ func VeleroInstall(ctx context.Context, veleroCfg *VerleroConfig, useVolumeSnaps return errors.WithMessagef(err, "Failed to get Velero InstallOptions for plugin provider %s", veleroCfg.ObjectStoreProvider) } veleroInstallOptions.UseVolumeSnapshots = useVolumeSnapshots - veleroInstallOptions.UseRestic = !useVolumeSnapshots + veleroInstallOptions.UseNodeAgent = !useVolumeSnapshots veleroInstallOptions.Image = veleroCfg.VeleroImage veleroInstallOptions.Namespace = veleroCfg.VeleroNamespace GCFrequency, _ := time.ParseDuration(veleroCfg.GCFrequency) @@ -171,8 +171,8 @@ func installVeleroServer(ctx context.Context, cli string, options *installOption if len(options.Image) > 0 { args = append(args, "--image", options.Image) } - if options.UseRestic { - args = append(args, "--use-restic") + if options.UseNodeAgent { + args = append(args, "--use-node-agent") } if options.UseVolumeSnapshots { args = append(args, "--use-volume-snapshots") @@ -217,7 +217,7 @@ func installVeleroServer(ctx context.Context, cli string, options *installOption return err } - return waitVeleroReady(ctx, namespace, options.UseRestic) + return waitVeleroReady(ctx, namespace, options.UseNodeAgent) } func createVelereResources(ctx context.Context, cli, namespace string, args []string, registryCredentialFile, resticHelperImage string) error { @@ -371,7 +371,7 @@ func toUnstructured(res interface{}) (unstructured.Unstructured, error) { return un, err } -func waitVeleroReady(ctx context.Context, namespace string, useRestic bool) error { +func waitVeleroReady(ctx context.Context, namespace string, useNodeAgent bool) error { fmt.Println("Waiting for Velero deployment to be ready.") // when doing upgrade by the "kubectl apply" the command "kubectl wait --for=condition=available deployment/velero -n velero --timeout=600s" returns directly // use "rollout status" instead to avoid this. For more detail information, refer to https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#complete-deployment @@ -381,25 +381,25 @@ func waitVeleroReady(ctx context.Context, namespace string, useRestic bool) erro return errors.Wrapf(err, "fail to wait for the velero deployment ready, stdout=%s, stderr=%s", stdout, stderr) } - if useRestic { - fmt.Println("Waiting for Velero restic daemonset to be ready.") + if useNodeAgent { + fmt.Println("Waiting for node-agent daemonset to be ready.") err := wait.PollImmediate(5*time.Second, 1*time.Minute, func() (bool, error) { - stdout, stderr, err := velerexec.RunCommand(exec.CommandContext(ctx, "kubectl", "get", "daemonset/restic", + stdout, stderr, err := velerexec.RunCommand(exec.CommandContext(ctx, "kubectl", "get", "daemonset/node-agent", "-o", "json", "-n", namespace)) if err != nil { - return false, errors.Wrapf(err, "failed to get the restic daemonset, stdout=%s, stderr=%s", stdout, stderr) + return false, errors.Wrapf(err, "failed to get the node-agent daemonset, stdout=%s, stderr=%s", stdout, stderr) } - restic := &apps.DaemonSet{} - if err = json.Unmarshal([]byte(stdout), restic); err != nil { - return false, errors.Wrapf(err, "failed to unmarshal the restic daemonset") + daemonset := &apps.DaemonSet{} + if err = json.Unmarshal([]byte(stdout), daemonset); err != nil { + return false, errors.Wrapf(err, "failed to unmarshal the node-agent daemonset") } - if restic.Status.DesiredNumberScheduled == restic.Status.NumberAvailable { + if daemonset.Status.DesiredNumberScheduled == daemonset.Status.NumberAvailable { return true, nil } return false, nil }) if err != nil { - return errors.Wrap(err, "fail to wait for the velero restic ready") + return errors.Wrap(err, "fail to wait for the node-agent ready") } } diff --git a/tilt-resources/examples/restic.yaml b/tilt-resources/examples/node-agent.yaml similarity index 93% rename from tilt-resources/examples/restic.yaml rename to tilt-resources/examples/node-agent.yaml index 86d8a6f06c..d5c10fc47e 100644 --- a/tilt-resources/examples/restic.yaml +++ b/tilt-resources/examples/node-agent.yaml @@ -5,22 +5,22 @@ metadata: creationTimestamp: null labels: component: velero - name: restic + name: node-agent namespace: velero spec: selector: matchLabels: - name: restic + name: node-agent template: metadata: creationTimestamp: null labels: component: velero - name: restic + name: node-agent spec: containers: - args: - - restic + - node-agent - server command: - /velero @@ -43,7 +43,7 @@ spec: value: /credentials/cloud image: velero/velero:latest imagePullPolicy: Always - name: restic + name: node-agent resources: {} volumeMounts: - mountPath: /host_pods