Skip to content

Commit

Permalink
Add the ConfigMap-specified parameters into velero install CLI.
Browse files Browse the repository at this point in the history
Rename backup-repository-config to backup-repository-configmap.
Rename repo-maintenance-job-config to repo-maintenance-job-configmap.
Rename node-agent-config to node-agent-configmap.
Add those three parameters to `velero install` CLI.
Modify the design and the site documents.

Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
  • Loading branch information
blackpiglet committed Sep 11, 2024
1 parent 46801a0 commit e359e7b
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 87 deletions.
10 changes: 5 additions & 5 deletions design/Implemented/node-agent-affinity.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ Therefore, in order to improve the compatibility, it is worthy to configure the

## Solution

We will use the ```node-agent-config``` configMap to host the node affinity configurations.
We will use the ConfigMap specified by `velero node-agent` CLI's parameter `--node-agent-configmap` to host the node affinity configurations.
This configMap is not created by Velero, users should create it manually on demand. The configMap should be in the same namespace where Velero is installed. If multiple Velero instances are installed in different namespaces, there should be one configMap in each namespace which applies to node-agent in that namespace only.
Node-agent server checks these configurations at startup time and use it to initiate the related VGDP modules. Therefore, users could edit this configMap any time, but in order to make the changes effective, node-agent server needs to be restarted.
Inside ```node-agent-config``` configMap we will add one new kind of configuration as the data in the configMap, the name is ```loadAffinity```.
Inside the ConfigMap we will add one new kind of configuration as the data in the configMap, the name is ```loadAffinity```.
Users may want to set different LoadAffinity configurations according to different conditions (i.e., for different storages represented by StorageClass, CSI driver, etc.), so we define ```loadAffinity``` as an array. This is for extensibility consideration, at present, we don't implement multiple configurations support, so if there are multiple configurations, we always take the first one in the array.

The data structure for ```node-agent-config``` is as below:
The data structure is as below:
```go
type Configs struct {
// LoadConcurrency is the config for load concurrency per node.
Expand All @@ -63,7 +63,7 @@ Anti-affinity configuration means preventing VGDP instances running in the nodes
- It could be defined by `MatchExpressions` of `metav1.LabelSelector`. The labels are defined in `Key` and `Values` of `MatchExpressions` and the `Operator` should be defined as `LabelSelectorOpNotIn` or `LabelSelectorOpDoesNotExist`.

### Sample
A sample of the ```node-agent-config``` configMap is as below:
A sample of the ConfigMap is as below:
```json
{
"loadAffinity": [
Expand Down Expand Up @@ -101,7 +101,7 @@ This sample showcases one anti-affinity configuration:

To create the configMap, users need to save something like the above sample to a json file and then run below command:
```
kubectl create cm node-agent-config -n velero --from-file=<json file name>
kubectl create cm <ConfigMap name> -n velero --from-file=<json file name>
```

### Implementation
Expand Down
10 changes: 5 additions & 5 deletions design/Implemented/node-agent-concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Therefore, in order to gain the optimized performance with the limited resources

## Solution

We introduce a configMap named ```node-agent-config``` for users to specify the node-agent related configurations. This configMap is not created by Velero, users should create it manually on demand. The configMap should be in the same namespace where Velero is installed. If multiple Velero instances are installed in different namespaces, there should be one configMap in each namespace which applies to node-agent in that namespace only.
We introduce a ConfigMap specified by `velero node-agent` CLI's parameter `--node-agent-configmap` for users to specify the node-agent related configurations. This configMap is not created by Velero, users should create it manually on demand. The configMap should be in the same namespace where Velero is installed. If multiple Velero instances are installed in different namespaces, there should be one configMap in each namespace which applies to node-agent in that namespace only.
Node-agent server checks these configurations at startup time and use it to initiate the related VGDP modules. Therefore, users could edit this configMap any time, but in order to make the changes effective, node-agent server needs to be restarted.
The ```node-agent-config``` configMap may be used for other purpose of configuring node-agent in future, at present, there is only one kind of configuration as the data in the configMap, the name is ```loadConcurrency```.
The ConfigMap may be used for other purpose of configuring node-agent in future, at present, there is only one kind of configuration as the data in the configMap, the name is ```loadConcurrency```.

The data structure for ```node-agent-config``` is as below:
The data structure is as below:
```go
type Configs struct {
// LoadConcurrency is the config for load concurrency per node.
Expand Down Expand Up @@ -82,7 +82,7 @@ At least one node is expected to have a label with the specified ```RuledConfigs
If one node falls into more than one rules, e.g., if node1 also has the label ```beta.kubernetes.io/instance-type=Standard_B4ms```, the smallest number (3) will be used.

### Sample
A sample of the ```node-agent-config``` configMap is as below:
A sample of the ConfigMap is as below:
```json
{
"loadConcurrency": {
Expand Down Expand Up @@ -110,7 +110,7 @@ A sample of the ```node-agent-config``` configMap is as below:
```
To create the configMap, users need to save something like the above sample to a json file and then run below command:
```
kubectl create cm node-agent-config -n velero --from-file=<json file name>
kubectl create cm <ConfigMap name> -n velero --from-file=<json file name>
```

### Global data path manager
Expand Down
10 changes: 5 additions & 5 deletions design/backup-pvc-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ In some scenarios, users may need to configure some advanced settings of the bac

## Solution

We will use the ```node-agent-config``` configMap to host the backupPVC configurations.
We will use the ConfigMap specified by `velero node-agent` CLI's parameter `--node-agent-configmap` to host the backupPVC configurations.
This configMap is not created by Velero, users should create it manually on demand. The configMap should be in the same namespace where Velero is installed. If multiple Velero instances are installed in different namespaces, there should be one configMap in each namespace which applies to node-agent in that namespace only.
Node-agent server checks these configurations at startup time and use it to initiate the related Exposer modules. Therefore, users could edit this configMap any time, but in order to make the changes effective, node-agent server needs to be restarted.
Inside ```node-agent-config``` configMap we will add one new kind of configuration as the data in the configMap, the name is ```backupPVC```.
Inside the ConfigMap we will add one new kind of configuration as the data in the configMap, the name is ```backupPVC```.
Users may want to set different backupPVC configurations for different volumes, therefore, we define the configurations as a map and allow users to specific configurations by storage class. Specifically, the key of the map element is the storage class name used by the sourcePVC and the value is the set of configurations for the backupPVC created for the sourcePVC.

The data structure for ```node-agent-config``` is as below:
The data structure is as below:
```go
type Configs struct {
// LoadConcurrency is the config for data path load concurrency per node.
Expand All @@ -56,7 +56,7 @@ type BackupPVC struct {
```

### Sample
A sample of the ```node-agent-config``` configMap is as below:
A sample of the ConfigMap is as below:
```json
{
"backupPVC": {
Expand All @@ -76,7 +76,7 @@ A sample of the ```node-agent-config``` configMap is as below:

To create the configMap, users need to save something like the above sample to a json file and then run below command:
```
kubectl create cm node-agent-config -n velero --from-file=<json file name>
kubectl create cm <ConfigMap name> -n velero --from-file=<json file name>
```

### Implementation
Expand Down
2 changes: 1 addition & 1 deletion design/backup-repo-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Therefore, a BackupRepository configMap is introduced as a template of the confi
When the backup repository CR is created by the BackupRepository controller, the configurations in the configMap are copied to the ```repositoryConfig``` field.
For an existing BackupRepository CR, the configMap is never visited, if users want to modify the configuration value, they should directly edit the BackupRepository CR.

The BackupRepository configMap is created by users in velero installation namespace. The configMap name must be specified in the velero server parameter ```--backup-repository-config```, otherwise, it won't effect.
The BackupRepository configMap is created by users in velero installation namespace. The configMap name must be specified in the velero server parameter ```--backup-repository-configmap```, otherwise, it won't effect.
If the configMap name is specified but the configMap doesn't exist by the time of a backup repository is created, the configMap name is ignored.
For any reason, if the configMap doesn't effect, nothing is specified to the backup repository CR, so the Unified Repo modules use the hard-coded values to configure the backup repository.

Expand Down
49 changes: 32 additions & 17 deletions design/repo_maintenance_job_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ This design reuses the data structure introduced by design [node-agent affinity
## Compatibility
v1.14 uses the `velero server` CLI's parameter to pass the repository maintenance job configuration.
In v1.15, those parameters are still kept, including `--maintenance-job-cpu-request`, `--maintenance-job-mem-request`, `--maintenance-job-cpu-limit`, `--maintenance-job-mem-limit`, and `--keep-latest-maintenance-jobs`.
But the parameters read from the ConfigMap specified by `velero server` CLI parameter `--repo-maintenance-job-config` introduced by this design have a higher priority.
But the parameters read from the ConfigMap specified by `velero server` CLI parameter `--repo-maintenance-job-configmap` introduced by this design have a higher priority.

If there `--repo-maintenance-job-config` is not specified, then the `velero server` parameters are used if provided.
If there `--repo-maintenance-job-configmap` is not specified, then the `velero server` parameters are used if provided.

If the `velero server` parameters are not specified too, then the default values are used.
* `--keep-latest-maintenance-jobs` default value is 3.
Expand All @@ -41,19 +41,19 @@ If the `velero server` parameters are not specified too, then the default values
## Deprecation
Propose to deprecate the `velero server` parameters `--maintenance-job-cpu-request`, `--maintenance-job-mem-request`, `--maintenance-job-cpu-limit`, `--maintenance-job-mem-limit`, and `--keep-latest-maintenance-jobs` in release-1.15.
That means those parameters will be deleted in release-1.17.
After deletion, those resources-related parameters are replaced by the ConfigMap specified by `velero server` CLI's parameter `--repo-maintenance-job-config`.
After deletion, those resources-related parameters are replaced by the ConfigMap specified by `velero server` CLI's parameter `--repo-maintenance-job-configmap`.
`--keep-latest-maintenance-jobs` is deleted from `velero server` CLI. It turns into a non-configurable internal parameter, and its value is 3.
Please check [issue 7923](https://github.com/vmware-tanzu/velero/issues/7923) for more information why deleting this parameter.

## Design
This design introduces a new ConfigMap specified by `velero server` CLI parameter `--repo-maintenance-job-config` as the source of the repository maintenance job configuration. The specified ConfigMap is read from the namespace where Velero is installed.
This design introduces a new ConfigMap specified by `velero server` CLI parameter `--repo-maintenance-job-configmap` as the source of the repository maintenance job configuration. The specified ConfigMap is read from the namespace where Velero is installed.
If the ConfigMap doesn't exist, the internal default values are used.

Example of using the parameter `--repo-maintenance-job-config`:
Example of using the parameter `--repo-maintenance-job-configmap`:
```
velero server \
...
--repo-maintenance-job-config repo-job-config
--repo-maintenance-job-configmap repo-job-config
...
```

Expand All @@ -62,7 +62,7 @@ velero server \
* Velero reads this ConfigMap content at starting a new repository maintenance job, so the ConfigMap change will not take affect until the next created job.

### Structure
The data structure for ```repo-maintenance-job-config``` is as below:
The data structure is as below:
```go
type Configs struct {
// LoadAffinity is the config for data path load affinity.
Expand Down Expand Up @@ -124,7 +124,7 @@ For example, the user want to let the nodes is in a specified machine type or th
This can be done by adding multiple entries in the `LoadAffinity` array.

### Affinity Example
A sample of the ```repo-maintenance-job-config``` ConfigMap is as below:
A sample of the ConfigMap is as below:
``` bash
cat <<EOF > repo-maintenance-job-config.json
{
Expand Down Expand Up @@ -277,17 +277,32 @@ config := Configs {

### Implementation
During the Velero repository controller starts to maintain a repository, it will call the repository manager's `PruneRepo` function to build the maintenance Job.
The ConfigMap specified by `velero server` CLI parameter `--repo-maintenance-job-config` is get to reinitialize the repository `MaintenanceConfig` setting.
The ConfigMap specified by `velero server` CLI parameter `--repo-maintenance-job-configmap` is get to reinitialize the repository `MaintenanceConfig` setting.

``` go
config, err := GetConfigs(context.Background(), namespace, crClient)
if err == nil {
if len(config.LoadAffinity) > 0 {
mgr.maintenanceCfg.Affinity = toSystemAffinity((*nodeagent.LoadAffinity)(config.LoadAffinity[0]))
}
......
} else {
log.Info("Cannot find the repo-maintenance-job-config ConfigMap: %s", err.Error())
jobConfig, err := getMaintenanceJobConfig(
context.Background(),
m.client,
m.log,
m.namespace,
m.repoMaintenanceJobConfig,
repo,
)
if err != nil {
log.Infof("Cannot find the ConfigMap %s with error: %s. Use default value.",
m.namespace+"/"+m.repoMaintenanceJobConfig,
err.Error(),
)
}
log.Info("Start to maintenance repo")
maintenanceJob, err := m.buildMaintenanceJob(
jobConfig,
param,
)
if err != nil {
return errors.Wrap(err, "error to build maintenance job")
}
```

Expand Down
2 changes: 1 addition & 1 deletion design/vgdp-micro-service/vgdp-micro-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ This log redirecting mechanism is thread safe since the hook acquires the write

### Resource Control
The CPU/memory resource of backupPod/restorePod is configurable, which means users are allowed to configure resources per volume backup/restore.
By default, the [Best Effort policy][5] is used, and users are allowed to change it through the ```node-agent-config``` configMap. Specifically, we add below structures to the configMap:
By default, the [Best Effort policy][5] is used, and users are allowed to change it through the ConfigMap specified by `velero node-agent` CLI's parameter `--node-agent-configmap`. Specifically, we add below structures to the ConfigMap:
```
type Configs struct {
// PodResources is the resource config for various types of pods launched by node-agent, i.e., data mover pods.
Expand Down
24 changes: 24 additions & 0 deletions pkg/cmd/cli/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ type Options struct {
ScheduleSkipImmediately bool
PodResources kubeutil.PodResources
KeepLatestMaintenanceJobs int
BackupRepoConfig string
RepoMaintenanceJobConfig string
NodeAgentConfigMap string
}

// BindFlags adds command line values to the options struct.
Expand Down Expand Up @@ -161,6 +164,24 @@ func (o *Options) BindFlags(flags *pflag.FlagSet) {
o.PodResources.MemoryLimit,
"Memory limit for maintenance jobs. Default is no limit.",
)
flags.StringVar(
&o.BackupRepoConfig,
"backup-repository-configmap",
o.BackupRepoConfig,
"The name of configMap containing backup repository configurations.",
)
flags.StringVar(
&o.RepoMaintenanceJobConfig,
"repo-maintenance-job-configmap",
o.RepoMaintenanceJobConfig,
"The name of ConfigMap containing repository maintenance Job configurations.",
)
flags.StringVar(
&o.NodeAgentConfigMap,
"node-agent-configmap",
o.NodeAgentConfigMap,
"The name of ConfigMap containing node-agent configurations.",
)

Check warning on line 184 in pkg/cmd/cli/install/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/cli/install/install.go#L167-L184

Added lines #L167 - L184 were not covered by tests
}

// NewInstallOptions instantiates a new, default InstallOptions struct.
Expand Down Expand Up @@ -259,6 +280,9 @@ func (o *Options) AsVeleroOptions() (*install.VeleroOptions, error) {
ScheduleSkipImmediately: o.ScheduleSkipImmediately,
PodResources: o.PodResources,
KeepLatestMaintenanceJobs: o.KeepLatestMaintenanceJobs,
BackupRepoConfig: o.BackupRepoConfig,
RepoMaintenanceJobConfig: o.RepoMaintenanceJobConfig,
NodeAgentConfigMap: o.NodeAgentConfigMap,

Check warning on line 285 in pkg/cmd/cli/install/install.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/cli/install/install.go#L283-L285

Added lines #L283 - L285 were not covered by tests
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/nodeagent/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewServerCommand(f client.Factory) *cobra.Command {
command.Flags().DurationVar(&config.resourceTimeout, "resource-timeout", config.resourceTimeout, "How long to wait for resource processes which are not covered by other specific timeout parameters. Default is 10 minutes.")
command.Flags().DurationVar(&config.dataMoverPrepareTimeout, "data-mover-prepare-timeout", config.dataMoverPrepareTimeout, "How long to wait for preparing a DataUpload/DataDownload. Default is 30 minutes.")
command.Flags().StringVar(&config.metricsAddress, "metrics-address", config.metricsAddress, "The address to expose prometheus metrics")
command.Flags().StringVar(&config.nodeAgentConfig, "node-agent-config", config.nodeAgentConfig, "The name of configMap containing node-agent configurations.")
command.Flags().StringVar(&config.nodeAgentConfig, "node-agent-configmap", config.nodeAgentConfig, "The name of ConfigMap containing node-agent configurations.")

Check warning on line 128 in pkg/cmd/cli/nodeagent/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/cli/nodeagent/server.go#L128

Added line #L128 was not covered by tests

return command
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ func (c *Config) BindFlags(flags *pflag.FlagSet) {
)
flags.StringVar(
&c.BackupRepoConfig,
"backup-repository-config",
"backup-repository-configmap",
c.BackupRepoConfig,
"The name of configMap containing backup repository configurations.",
"The name of ConfigMap containing backup repository configurations.",
)
flags.StringVar(
&c.RepoMaintenanceJobConfig,
"repo-maintenance-job-config",
"repo-maintenance-job-configmap",
c.RepoMaintenanceJobConfig,
"The name of ConfigMap containing repository maintenance Job configurations.",
)
Expand Down
4 changes: 4 additions & 0 deletions pkg/install/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.DaemonSet {
daemonSetArgs = append(daemonSetArgs, fmt.Sprintf("--features=%s", strings.Join(c.features, ",")))
}

if len(c.nodeAgentConfigMap) > 0 {
daemonSetArgs = append(daemonSetArgs, fmt.Sprintf("--node-agent-configmap=%s", c.nodeAgentConfigMap))
}

userID := int64(0)
mountPropagationMode := corev1.MountPropagationHostToContainer

Expand Down
4 changes: 4 additions & 0 deletions pkg/install/daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func TestDaemonSet(t *testing.T) {
assert.Len(t, ds.Spec.Template.Spec.Containers[0].Args, 3)
assert.Equal(t, "--features=foo,bar,baz", ds.Spec.Template.Spec.Containers[0].Args[2])

ds = DaemonSet("velero", WithNodeAgentConfigMap("node-agent-config-map"))
assert.Len(t, ds.Spec.Template.Spec.Containers[0].Args, 3)
assert.Equal(t, "--node-agent-configmap=node-agent-config-map", ds.Spec.Template.Spec.Containers[0].Args[2])

ds = DaemonSet("velero", WithServiceAccountName("test-sa"))
assert.Equal(t, "test-sa", ds.Spec.Template.Spec.ServiceAccountName)
}
Loading

0 comments on commit e359e7b

Please sign in to comment.