Skip to content

[velero] feat: add support for repo-maintenance-job-configmap argument to run velero server with #702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dashashutosh80
Copy link
Contributor

@dashashutosh80 dashashutosh80 commented Aug 6, 2025

Special notes for your reviewer:

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • DCO signed
  • Chart Version bumped, please refer to the chart version instruction
  • Variables are documented in the values.yaml or README.md
  • Title of the PR starts with chart name (e.g. [velero])

Based on the latest changes we've made, here's the updated PR description:


📋 Summary

This PR implements support for Velero v1.15+ per-repository maintenance job configuration through a ConfigMap, as requested in #696. This feature allows users to configure different resource limits, node affinity, and priority classes for maintenance jobs on a per-repository basis using structured YAML configuration.

🎯 What's Changed

✨ New Features

  • Per-repository ConfigMap support: Users can now provide structured YAML configuration for repository-specific maintenance job settings
  • Structured YAML configuration: Clean, validated YAML structure instead of embedded JSON strings
  • Pretty-formatted JSON output: ConfigMap data is formatted with proper indentation for readability
  • Global and repository-specific sections: Separate global and repositories configuration sections
  • Priority class restrictions: Correctly implements Velero's requirement that priorityClassName only applies globally
  • Backward compatibility: Existing deprecated parameters continue to work when new config is not provided
  • Schema validation: Comprehensive JSON schema validation for the new configuration options

📁 Files Modified

  • charts/velero/values.yaml - Added repositoryConfigData section with structured YAML configuration support
  • charts/velero/templates/repo-maintenance-configmap.yaml - New template creating properly formatted ConfigMaps with key-value pairs
  • charts/velero/templates/deployment.yaml - Updated to conditionally use new --repo-maintenance-job-configmap argument
  • charts/velero/values.schema.json - Added comprehensive schema validation with proper priority class restrictions
  • charts/velero/README.md - Updated documentation with structured YAML examples and priority class notes

🔧 How It Works

The implementation now follows the latest Velero documentation format where the ConfigMap contains direct key-value pairs:

  • Each key is either "global" or a repository identifier ("namespace-storageLocation-repositoryType")
  • Each value is a properly formatted JSON string containing the configuration for that scope

When structured configuration is provided:

  • Creates a ConfigMap with properly formatted JSON values for each repository/global section
  • Adds --repo-maintenance-job-configmap argument to Velero server
  • Does NOT use deprecated --maintenance-job-* arguments

When structured configuration is NOT provided (default):

  • Uses existing deprecated arguments: --maintenance-job-cpu-request, --maintenance-job-mem-request, --maintenance-job-cpu-limit, --maintenance-job-mem-limit, --keep-latest-maintenance-jobs
  • No ConfigMap is created
  • Maintains full backward compatibility

📖 Usage Examples

Basic Global Configuration

configuration:
  repositoryMaintenanceJob:
    repositoryConfigData:
      global:
        podResources:
          cpuRequest: "100m"
          cpuLimit: "200m"
          memoryRequest: "100Mi"
          memoryLimit: "200Mi"
        keepLatestMaintenanceJobs: 1

Per-Repository Configuration

configuration:
  repositoryMaintenanceJob:
    repositoryConfigData:
      global:
        podResources:
          cpuRequest: "100m"
          cpuLimit: "200m"
          memoryRequest: "100Mi"
          memoryLimit: "200Mi"
        priorityClassName: "low-priority"  # Only supported in global section
      repositories:
        "prod-s3-backup-kopia":
          podResources:
            cpuRequest: "500m"
            cpuLimit: "1000m"
            memoryRequest: "512Mi"
            memoryLimit: "1024Mi"
          keepLatestMaintenanceJobs: 2
          loadAffinity:
            - nodeSelector:
                matchLabels:
                  dedicated: "backup"

Generated ConfigMap Format

The above configuration generates a ConfigMap like:

apiVersion: v1
kind: ConfigMap
metadata:
  name: velero-repo-maintenance
data:
  global: |
    {
      "keepLatestMaintenanceJobs": 1,
      "podResources": {
        "cpuLimit": "200m",
        "cpuRequest": "100m",
        "memoryLimit": "200Mi",
        "memoryRequest": "100Mi"
      },
      "priorityClassName": "low-priority"
    }
  prod-s3-backup-kopia: |
    {
      "keepLatestMaintenanceJobs": 2,
      "loadAffinity": [
        {
          "nodeSelector": {
            "matchLabels": {
              "dedicated": "backup"
            }
          }
        }
      ],
      "podResources": {
        "cpuLimit": "1000m",
        "cpuRequest": "500m",
        "memoryLimit": "1024Mi",
        "memoryRequest": "512Mi"
      }
    }

🎨 Key Improvements

1. Better User Experience

  • Structured YAML: No more embedded JSON strings - users work with clean YAML
  • Validation: Helm can validate the configuration structure using JSON schema
  • Readability: Generated ConfigMaps use pretty-formatted JSON for easier debugging

2. Compliance with Velero Documentation

  • Correct ConfigMap format: Matches exactly what Velero expects (direct key-value pairs)
  • Priority class restrictions: priorityClassName only allowed in global configuration
  • Repository key format: Properly documented {namespace}-{storageLocation}-{repositoryType} format

3. Enhanced Schema Validation

  • Global configuration: Validates podResources, keepLatestMaintenanceJobs, priorityClassName, loadAffinity
  • Repository-specific: Validates same fields except priorityClassName (correctly restricted)
  • Type safety: Proper validation for all configuration values

🔄 Migration Path

Existing users: No action required - deprecated parameters continue to work
New users: Can choose between:

  1. Legacy approach (deprecated parameters) - will be removed in Velero v1.17
  2. New approach (structured YAML ConfigMap) - recommended for future compatibility

✅ Testing

  • ✅ ConfigMap creation with correct key-value pair structure
  • ✅ Pretty-formatted JSON output for readability
  • ✅ Priority class correctly restricted to global configuration only
  • ✅ Deployment arguments correctly set based on configuration
  • ✅ Backward compatibility with deprecated parameters
  • ✅ Comprehensive schema validation for new configuration options
  • ✅ Template rendering with various configuration scenarios

📚 References

  • Velero Documentation: Repository Maintenance
  • Original Issue: #696
  • Velero v1.15+ Release Notes: Introduced --repo-maintenance-job-configmap parameter

⚠️ Breaking Changes

None. This is a fully backward-compatible addition.

🔮 Future Considerations

  • The deprecated parameters (--maintenance-job-*) will be removed in Velero v1.17
  • Users are encouraged to migrate to the new structured YAML configuration approach
  • Any new Velero maintenance job features will automatically work through the YAML configuration without requiring chart updates
  • The structured approach provides better validation and user experience compared to embedded JSON strings

This PR provides a robust, user-friendly, and future-proof implementation that gives users complete control over repository maintenance job configuration while maintaining full backward compatibility with existing deployments. The implementation now perfectly matches the latest Velero documentation and provides an improved developer experience with structured YAML configuration and pretty-formatted output.

@dashashutosh80 dashashutosh80 force-pushed the feat/repo-maintenance-configmap branch from 6fcf8bf to e01eadb Compare August 6, 2025 15:34
@dashashutosh80 dashashutosh80 marked this pull request as draft August 6, 2025 15:44
…t to run velero server with

Signed-off-by: dashashutosh80 <[email protected]>
@dashashutosh80 dashashutosh80 force-pushed the feat/repo-maintenance-configmap branch from 4a1e089 to c9a081d Compare August 6, 2025 16:12
@dashashutosh80 dashashutosh80 marked this pull request as ready for review August 6, 2025 16:14
@github-actions github-actions bot requested a review from jenting August 6, 2025 16:14
Signed-off-by: dashashutosh80 <[email protected]>
…:dashashutosh80/velero-helm-charts into feat/repo-maintenance-configmap
@dashashutosh80
Copy link
Contributor Author

@blackpiglet Please feel free to review this too. TIA!

jenting
jenting previously approved these changes Aug 7, 2025
Copy link
Collaborator

@jenting jenting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…st repository config changes

Signed-off-by: dashashutosh80 <[email protected]>
@dashashutosh80
Copy link
Contributor Author

@jenting / @blackpiglet Can you please review this PR again (new changes as discussed above have been implemented) ?

jenting
jenting previously approved these changes Aug 8, 2025
@jenting
Copy link
Collaborator

jenting commented Aug 11, 2025

Please help rebase to the latest branch and bump version, thx.

@dashashutosh80
Copy link
Contributor Author

@jenting / @blackpiglet Rebased with main branch and resolved conflicts. Please review this/

@jenting jenting merged commit bb071c1 into vmware-tanzu:main Aug 11, 2025
27 of 28 checks passed
@dashashutosh80 dashashutosh80 deleted the feat/repo-maintenance-configmap branch August 11, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants