Files
velero/site/content/docs/v1.18/namespace-glob-patterns.md
T
Joseph Antony VaikathandClaude Sonnet 4.5 43b926a58b Support all glob wildcard characters in namespace validation (#9502)
* Support all glob wildcard characters in namespace validation

Expand namespace validation to allow all valid glob pattern characters
(*, ?, {}, [], ,) by replacing them with valid characters during RFC 1123
validation. The actual glob pattern validation is handled separately by
the wildcard package.

Also add validation to reject unsupported characters (|, (), !) that are
not valid in glob patterns, and update terminology from "regex" to "glob"
for clarity since this implementation uses glob patterns, not regex.

Changes:
- Replace all glob wildcard characters in validateNamespaceName
- Add test coverage for valid glob patterns in includes/excludes
- Add test coverage for unsupported characters
- Reject exclamation mark (!) in wildcard patterns
- Clarify comments and error messages about glob vs regex

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>

* Changelog

Signed-off-by: Joseph <jvaikath@redhat.com>

* Add documentation: glob patterns are now accepted

Signed-off-by: Joseph <jvaikath@redhat.com>

* Error message fix

Signed-off-by: Joseph <jvaikath@redhat.com>

* Remove negation glob char test

Signed-off-by: Joseph <jvaikath@redhat.com>

* Add bracket pattern validation for namespace glob patterns

Extends wildcard validation to support square bracket patterns [] used in glob character classes. Validates bracket syntax including empty brackets, unclosed brackets, and unmatched brackets. Extracts ValidateNamespaceName as a public function to enable reuse in namespace validation logic.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>

* Reduce scope to *, ?, [ and ]

Signed-off-by: Joseph <jvaikath@redhat.com>

* Fix tests

Signed-off-by: Joseph <jvaikath@redhat.com>

* Add namespace glob patterns documentation page

Adds dedicated documentation explaining supported glob patterns
for namespace include/exclude filtering to help users understand
the wildcard syntax.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>

* Fix build-image Dockerfile envtest download

Replace inaccessible go.kubebuilder.io URL with setup-envtest and update envtest version to 1.33.0 to match Kubernetes v0.33.3 dependencies.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>

* kubebuilder binaries mv

Signed-off-by: Joseph <jvaikath@redhat.com>

* Reject brace patterns and update documentation

Add {, }, and , to unsupported characters list to explicitly reject
brace expansion patterns. Remove { from wildcard detection since these
patterns are not supported in the 1.18 release.

Update all documentation to show supported patterns inline (*, ?, [abc])
with clickable links to the detailed namespace-glob-patterns page.
Simplify YAML comments by removing non-clickable URLs.

Update tests to expect errors when brace patterns are used.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>

* Document brace expansion as unsupported

Add {} and , to the unsupported patterns section to clarify that
brace expansion patterns like {a,b,c} are not supported.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>

* Update tests to expect brace pattern rejection

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>

---------

Signed-off-by: Joseph <jvaikath@redhat.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 15:14:06 -05:00

1.9 KiB

title, layout
title layout
Namespace Glob Patterns docs

When using --include-namespaces and --exclude-namespaces flags with backup and restore commands, you can use glob patterns to match multiple namespaces.

Supported Patterns

Velero supports the following glob pattern characters:

  • * - Matches any sequence of characters

    velero backup create my-backup --include-namespaces "app-*"
    # Matches: app-prod, app-staging, app-dev, etc.
    
  • ? - Matches exactly one character

    velero backup create my-backup --include-namespaces "ns?"
    # Matches: ns1, ns2, nsa, but NOT ns10
    
  • [abc] - Matches any single character in the brackets

    velero backup create my-backup --include-namespaces "ns[123]"
    # Matches: ns1, ns2, ns3
    
  • [a-z] - Matches any single character in the range

    velero backup create my-backup --include-namespaces "ns[a-c]"
    # Matches: nsa, nsb, nsc
    

Unsupported Patterns

The following patterns are not supported and will cause validation errors:

  • ** - Consecutive asterisks
  • | - Alternation (regex operator)
  • () - Grouping (regex operators)
  • ! - Negation
  • {} - Brace expansion
  • , - Comma (used in brace expansion)

Special Cases

  • * alone means "all namespaces" and is not expanded
  • Empty brackets [] are invalid
  • Unmatched or unclosed brackets will cause validation errors

Examples

Combine patterns with include and exclude flags:

# Backup all production namespaces except test
velero backup create prod-backup \
  --include-namespaces "*-prod" \
  --exclude-namespaces "test-*"

# Backup specific numbered namespaces
velero backup create numbered-backup \
  --include-namespaces "app-[0-9]"

# Restore namespaces matching multiple patterns
velero restore create my-restore \
  --from-backup my-backup \
  --include-namespaces "frontend-*,backend-*"