I was trying to add to a pod a list of values inside one key as a label, thing is it doesn't really work, when I try to do kubectl edit po/sektor -o yaml
(sektor is pod name) and then in labels section I edited the "abilities" label like this:
labels:
abilities:
- ability1: fire
- ability2: teleport
- ability3: rocekts
but when I try to save it shows me the following error: Invalid value: "The edited file failed validation": ValidationError(Pod.metadata.labels.abilities): invalid type for io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta.labels: got "array", expected "string"
So I see that I need to change the type of that label somehow but I can't figure out how.
If it's possible, anyone knows how?
This is not possible because of the definition of Labels
. According to the documentation Labels
are key/value pairs. What you could do there tho, would be to have something like this:
labels:
ability-fire: true
ability-teleport: true
ability-rockets: true
With this way you can easily create Selectors for your other Resources like Services
.