loft-sh / vcluster

vCluster - Create fully functional virtual Kubernetes clusters - Each vcluster runs inside a namespace of the underlying k8s cluster. It's cheaper than creating separate full-blown clusters and it offers better multi-tenancy and isolation than regular namespaces.
https://www.vcluster.com
Apache License 2.0
6.26k stars 398 forks source link

node-selector is not parsed correctly on 6.0.0-beta.0 #360

Closed christiaangoossens closed 2 years ago

christiaangoossens commented 2 years ago

I am using the

syncer:
  extraArgs:
  - --node-selector="dedicated=value-value"

configuration, but syncer is failing on startup with the following message:

F0206 19:44:25.300227 1 main.go:32] start controllers: instantiate controllers: register pods controller: parse node selector: couldn't parse the selector string ""dedicated=value-value"": unable to parse requirement: <nil>: Invalid value: "\"dedicated": name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')

Afaik is dedicated a matching alphanumeric string.

christiaangoossens commented 2 years ago

As an additional note, the "/" character should also be allowed, as "somehost.nl/dedicated" should be a valid label.

FabianKramm commented 2 years ago

@christiaangoossens thanks for creating this issue! The problem in your case is the " character and the error message indicates that the character \" is not allowed (but looks a little bit confusing I admit, but it does not complain about \), so you should rewrite your node selector to:

syncer:
  extraArgs:
  - --node-selector=dedicated=value-value

Internally we are using the native Kubernetes function to parse the label selector, so everything that is allowed there is also allowed in the string. I just tested with dedicated=value-value as well as somehost.nl/dedicated=value-value and both work as expected.

christiaangoossens commented 2 years ago

Hi Fabian,

Yeah, I did see the escaping character there, but I was pretty sure I followed the docs and its right there: https://www.vcluster.com/docs/architecture/scheduling, maybe update that one too to remove the quotes.

Thank you for your quick reply!

christiaangoossens commented 2 years ago

The reason I asked about / is that the error also does not include it name part must consist of alphanumeric characters, '-', '_' or '. as an option, maybe should add it there too

FabianKramm commented 2 years ago

Oh yes you are correct, its a problem in the docs actually. Regarding the error message, we would need to change that in the Kubernetes project as we are reusing their function.