Skip to content

Commit

Permalink
rename daemonset
Browse files Browse the repository at this point in the history
Signed-off-by: Lyndon-Li <[email protected]>
  • Loading branch information
Lyndon-Li committed Sep 30, 2022
1 parent c81f0db commit 9a788d4
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 4 additions & 4 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"):
Expand Down
1 change: 1 addition & 0 deletions changelogs/unreleased/5390-lyndon
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rename Velero daemonset from "restic" to "node-agent"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +43,7 @@ spec:
value: /credentials/cloud
image: velero/velero:latest
imagePullPolicy: Always
name: restic
name: node-agent
resources: {}
volumeMounts:
- mountPath: /host_pods
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
46 changes: 23 additions & 23 deletions pkg/cmd/cli/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(i.e. Restic, Kopia) that need to run in one or more nodes.")
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))
}
Expand All @@ -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,
Expand Down Expand Up @@ -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
}
Expand All @@ -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(),
Expand All @@ -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'.
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
37 changes: 37 additions & 0 deletions pkg/cmd/cli/nodeagent/node_agent.go
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package restic
package nodeagent

import (
"context"
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion pkg/cmd/cli/restic/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func NewCommand(f client.Factory) *cobra.Command {

c.AddCommand(
repo.NewRepositoryCommand(f),
NewServerCommand(f),
)

return c
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/velero/velero.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down
16 changes: 8 additions & 8 deletions pkg/install/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,33 @@ 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(),
},
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,
},
Expand All @@ -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{
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/install/daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
4 changes: 2 additions & 2 deletions pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit 9a788d4

Please sign in to comment.