Add AllowExtraDnsLabels to setupKey CRD (#277)

This option was hardcoded to false.
It is now configurable in the SetupKey CRD with a default false value.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* New allowExtraDnsLabels setting for Setup Keys to control whether
peers may include extra DNS labels (disabled by default, immutable after
creation).
* **Documentation**
* API reference updated to document the new allowExtraDnsLabels field
and its default/behavior.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/netbirdio/kubernetes-operator/pull/277?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
pallieter-verhoeven-glbnxt
2026-05-27 18:45:07 +02:00
committed by GitHub
parent fef05e4569
commit dcd9dfdb4e
6 changed files with 35 additions and 1 deletions
+5
View File
@@ -16,6 +16,11 @@ type SetupKeySpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ephemeral is immutable" // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ephemeral is immutable"
Ephemeral bool `json:"ephemeral"` Ephemeral bool `json:"ephemeral"`
// AllowExtraDnsLabels decides if peers added with the key can have extra DNS labels.
// +kubebuilder:default=false
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="allowExtraDnsLabels is immutable"
AllowExtraDnsLabels bool `json:"allowExtraDnsLabels"`
// Duration sets how long the setup key is valid for. // Duration sets how long the setup key is valid for.
// +optional // +optional
// +kubebuilder:validation:Type=string // +kubebuilder:validation:Type=string
@@ -46,6 +46,14 @@ spec:
spec: spec:
description: SetupKeySpec defines the desired state of SetupKey. description: SetupKeySpec defines the desired state of SetupKey.
properties: properties:
allowExtraDnsLabels:
default: false
description: AllowExtraDnsLabels decides if peers added with the key
can have extra DNS labels.
type: boolean
x-kubernetes-validations:
- message: allowExtraDnsLabels is immutable
rule: self == oldSelf
autoGroups: autoGroups:
description: AutoGroups are groups that will be automatically assigned description: AutoGroups are groups that will be automatically assigned
to peers using setup key. to peers using setup key.
@@ -96,6 +104,7 @@ spec:
minLength: 1 minLength: 1
type: string type: string
required: required:
- allowExtraDnsLabels
- ephemeral - ephemeral
- name - name
type: object type: object
@@ -46,6 +46,14 @@ spec:
spec: spec:
description: SetupKeySpec defines the desired state of SetupKey. description: SetupKeySpec defines the desired state of SetupKey.
properties: properties:
allowExtraDnsLabels:
default: false
description: AllowExtraDnsLabels decides if peers added with the key
can have extra DNS labels.
type: boolean
x-kubernetes-validations:
- message: allowExtraDnsLabels is immutable
rule: self == oldSelf
autoGroups: autoGroups:
description: AutoGroups are groups that will be automatically assigned description: AutoGroups are groups that will be automatically assigned
to peers using setup key. to peers using setup key.
@@ -96,6 +104,7 @@ spec:
minLength: 1 minLength: 1
type: string type: string
required: required:
- allowExtraDnsLabels
- ephemeral - ephemeral
- name - name
type: object type: object
+1
View File
@@ -315,6 +315,7 @@ _Appears in:_
| --- | --- | --- | --- | | --- | --- | --- | --- |
| `name` _string_ | Name of the setup key. | | MinLength: 1 <br /> | | `name` _string_ | Name of the setup key. | | MinLength: 1 <br /> |
| `ephemeral` _boolean_ | Ephemeral decides if peers added with the key are ephemeral or not. | | | | `ephemeral` _boolean_ | Ephemeral decides if peers added with the key are ephemeral or not. | | |
| `allowExtraDnsLabels` _boolean_ | AllowExtraDnsLabels decides if peers added with the key can have extra DNS labels. | false | |
| `duration` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#duration-v1-meta)_ | Duration sets how long the setup key is valid for. | | Pattern: `^([0-9]+(\.[0-9]+)?(m\|h))+$` <br />Type: string <br />Optional: \{\} <br /> | | `duration` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#duration-v1-meta)_ | Duration sets how long the setup key is valid for. | | Pattern: `^([0-9]+(\.[0-9]+)?(m\|h))+$` <br />Type: string <br />Optional: \{\} <br /> |
| `autoGroups` _[GroupReference](#groupreference) array_ | AutoGroups are groups that will be automatically assigned to peers using setup key. | | Optional: \{\} <br /> | | `autoGroups` _[GroupReference](#groupreference) array_ | AutoGroups are groups that will be automatically assigned to peers using setup key. | | Optional: \{\} <br /> |
+1 -1
View File
@@ -125,7 +125,7 @@ func (r *SetupKeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
expiresIn = int(setupKey.Spec.Duration.Seconds()) expiresIn = int(setupKey.Spec.Duration.Seconds())
} }
setupKeyReq := api.PostApiSetupKeysJSONRequestBody{ setupKeyReq := api.PostApiSetupKeysJSONRequestBody{
AllowExtraDnsLabels: new(false), AllowExtraDnsLabels: &setupKey.Spec.AllowExtraDnsLabels,
AutoGroups: autoGroupIDs, AutoGroups: autoGroupIDs,
Ephemeral: new(setupKey.Spec.Ephemeral), Ephemeral: new(setupKey.Spec.Ephemeral),
ExpiresIn: expiresIn, ExpiresIn: expiresIn,
@@ -17,6 +17,8 @@ type SetupKeySpecApplyConfiguration struct {
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
// Ephemeral decides if peers added with the key are ephemeral or not. // Ephemeral decides if peers added with the key are ephemeral or not.
Ephemeral *bool `json:"ephemeral,omitempty"` Ephemeral *bool `json:"ephemeral,omitempty"`
// AllowExtraDnsLabels decides if peers added with the key can have extra DNS labels.
AllowExtraDnsLabels *bool `json:"allowExtraDnsLabels,omitempty"`
// Duration sets how long the setup key is valid for. // Duration sets how long the setup key is valid for.
Duration *v1.Duration `json:"duration,omitempty"` Duration *v1.Duration `json:"duration,omitempty"`
// AutoGroups are groups that will be automatically assigned to peers using setup key. // AutoGroups are groups that will be automatically assigned to peers using setup key.
@@ -45,6 +47,14 @@ func (b *SetupKeySpecApplyConfiguration) WithEphemeral(value bool) *SetupKeySpec
return b return b
} }
// WithAllowExtraDnsLabels sets the AllowExtraDnsLabels field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the AllowExtraDnsLabels field is set to the value of the last call.
func (b *SetupKeySpecApplyConfiguration) WithAllowExtraDnsLabels(value bool) *SetupKeySpecApplyConfiguration {
b.AllowExtraDnsLabels = &value
return b
}
// WithDuration sets the Duration field in the declarative configuration to the given value // WithDuration sets the Duration field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Duration field is set to the value of the last call. // If called multiple times, the Duration field is set to the value of the last call.