# Error: StatefulSet.apps "my-statefulset" is invalid: spec.volumeClaimTemplates[0].metadata.name: Invalid value: "my-pvc": must be a DNS label (at most 63 characters, matching regex [a-z0-9]([-a-z0-9]*[a-z0-9])?)

- **ID:** `kubernetes/statefulset-pvc-template-name`
- **Domain:** kubernetes
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 93%

## Root Cause

The volumeClaimTemplate name in a StatefulSet contains uppercase letters, underscores, or starts with a non-alphanumeric character, violating DNS label rules.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Kubernetes 1.24 | active | — | — |
| Kubernetes 1.25 | active | — | — |
| Kubernetes 1.26 | active | — | — |

## Workarounds

1. **Use only lowercase letters, numbers, and hyphens: rename 'My_PVC-1' to 'my-pvc-1' and reapply: kubectl apply -f statefulset.yaml** (95% success)
   ```
   Use only lowercase letters, numbers, and hyphens: rename 'My_PVC-1' to 'my-pvc-1' and reapply: kubectl apply -f statefulset.yaml
   ```
2. **Validate name before applying: echo 'my-pvc' | grep -E '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'** (90% success)
   ```
   Validate name before applying: echo 'my-pvc' | grep -E '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
   ```

## Dead Ends

- **Changing the PVC name in the template to include underscores or hyphens in wrong positions** — DNS 标签不允许下划线，连字符不能在开头或结尾 (85% fail)
- **Adding a random suffix like '-pvc' to the name** — 如果原名称已经无效，添加后缀不会修复根本问题 (60% fail)
- **Ignoring the error and reapplying the same YAML** — 错误是确定性的，重新应用不会改变验证逻辑 (99% fail)
