Description
In metadata.labels, leave a value empty or use up to 63 characters. A nonempty value must start and end with an ASCII letter or digit. Internal characters can also include -, _ and ..
Potential impact
The API rejects malformed labels. Even a difference in case can prevent a Service or NetworkPolicy from selecting a Pod.
Remediation
Check the label key’s name and optional DNS prefix. When you change a value, check each affected selector and the Pods it actually selects.
Examples
The excerpts omit the required Pod spec. The first value contains invalid * and + characters. If you use MyApp, match that capitalization in the selector.
Before
hcl
resource "kubernetes_pod" "example" {
metadata {
name = "terraform-example"
labels = {
app = "g**dy.l+bel"
}
}
}
After
hcl
resource "kubernetes_pod" "example" {
metadata {
name = "terraform-example"
labels = {
app = "MyApp"
}
}
}