mirror of
https://github.com/vmware-tanzu/velero.git
synced 2025-12-23 06:15:21 +00:00
rename daemonset (#5390)
Signed-off-by: Lyndon-Li <lyonghui@vmware.com> Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -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
|
||||
|
||||
8
Tiltfile
8
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"):
|
||||
|
||||
1
changelogs/unreleased/5390-lyndon
Normal file
1
changelogs/unreleased/5390-lyndon
Normal file
@@ -0,0 +1 @@
|
||||
Rename Velero daemonset from "restic" to "node-agent"
|
||||
@@ -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
|
||||
@@ -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()
|
||||
|
||||
@@ -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 Velero node-agent daemonset. Optional. Velero node-agent hosts Velero modules that need to run in one or more nodes(i.e. Restic, Kopia).")
|
||||
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 {
|
||||
|
||||
37
pkg/cmd/cli/nodeagent/node_agent.go
Normal file
37
pkg/cmd/cli/nodeagent/node_agent.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
@@ -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"
|
||||
@@ -32,7 +32,6 @@ func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
c.AddCommand(
|
||||
repo.NewRepositoryCommand(f),
|
||||
NewServerCommand(f),
|
||||
)
|
||||
|
||||
return c
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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{
|
||||
{
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
|
||||
const (
|
||||
// daemonSet is the name of the Velero node agent daemonset.
|
||||
daemonSet = "restic"
|
||||
daemonSet = "node-agent"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -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
|
||||
veleroInstallOptions.UploaderType = veleroCfg.UploaderType
|
||||
@@ -172,8 +172,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")
|
||||
@@ -222,7 +222,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 {
|
||||
@@ -376,7 +376,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
|
||||
@@ -386,25 +386,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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user