Make control plane endpoint default registration method
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
This commit is contained in:
parent
7b6bbba12a
commit
51a4233c99
|
|
@ -77,9 +77,9 @@ type RKE2ControlPlaneSpec struct {
|
|||
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
|
||||
|
||||
// RegistrationMethod is the method to use for registering nodes into the RKE2 cluster.
|
||||
// +kubebuilder:validation:Enum=internal-first;internal-only-ips;external-only-ips;address;control-plane-endpoint
|
||||
// +kubebuilder:validation:Enum=internal-first;internal-only-ips;external-only-ips;address;control-plane-endpoint;""
|
||||
// +optional
|
||||
RegistrationMethod RegistrationMethod `json:"registrationMethod"`
|
||||
RegistrationMethod RegistrationMethod `json:"registrationMethod,omitempty"`
|
||||
|
||||
// RegistrationAddress is an explicit address to use when registering a node. This is required if
|
||||
// the registration type is "address". Its for scenarios where a load-balancer or VIP is used.
|
||||
|
|
|
|||
|
|
@ -85,9 +85,10 @@ func (r *RKE2ControlPlane) ValidateUpdate(old runtime.Object) (admission.Warning
|
|||
allErrs = append(allErrs, bootstrapv1.ValidateRKE2ConfigSpec(r.Name, &r.Spec.RKE2ConfigSpec)...)
|
||||
allErrs = append(allErrs, r.validateCNI()...)
|
||||
|
||||
if r.Spec.RegistrationMethod != oldControlplane.Spec.RegistrationMethod {
|
||||
oldSet := oldControlplane.Spec.RegistrationMethod != ""
|
||||
if oldSet && r.Spec.RegistrationMethod != oldControlplane.Spec.RegistrationMethod {
|
||||
allErrs = append(allErrs,
|
||||
field.Invalid(field.NewPath("spec", "registrationMethod"), r.Spec.RegistrationMethod, "field is immutable"),
|
||||
field.Invalid(field.NewPath("spec", "registrationMethod"), r.Spec.RegistrationMethod, "field value is immutable once set"),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,9 +81,10 @@ func (r *RKE2ControlPlaneTemplate) ValidateUpdate(old runtime.Object) (admission
|
|||
allErrs = append(allErrs, bootstrapv1.ValidateRKE2ConfigSpec(r.Name, &r.Spec.Template.Spec.RKE2ConfigSpec)...)
|
||||
allErrs = append(allErrs, r.validateCNI()...)
|
||||
|
||||
if r.Spec.Template.Spec.RegistrationMethod != oldControlplane.Spec.Template.Spec.RegistrationMethod {
|
||||
oldSet := oldControlplane.Spec.Template.Spec.RegistrationMethod != ""
|
||||
if oldSet && r.Spec.Template.Spec.RegistrationMethod != oldControlplane.Spec.Template.Spec.RegistrationMethod {
|
||||
allErrs = append(allErrs,
|
||||
field.Invalid(field.NewPath("spec", "registrationMethod"), r.Spec.Template.Spec.RegistrationMethod, "field is immutable"),
|
||||
field.Invalid(field.NewPath("spec", "registrationMethod"), r.Spec.Template.Spec.RegistrationMethod, "field value is immutable once set"),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1949,6 +1949,7 @@ spec:
|
|||
- external-only-ips
|
||||
- address
|
||||
- control-plane-endpoint
|
||||
- ""
|
||||
type: string
|
||||
replicas:
|
||||
description: Replicas is the number of replicas for the Control Plane.
|
||||
|
|
|
|||
|
|
@ -782,6 +782,7 @@ spec:
|
|||
- external-only-ips
|
||||
- address
|
||||
- control-plane-endpoint
|
||||
- ""
|
||||
type: string
|
||||
replicas:
|
||||
description: Replicas is the number of replicas for the Control
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func NewRegistrationMethod(method string) (GetRegistrationAddresses, error) {
|
|||
return registrationMethodWithFilter(filterExternalOnly), nil
|
||||
case "address":
|
||||
return registrationMethodAddress, nil
|
||||
case "control-plane-endpoint":
|
||||
case "control-plane-endpoint", "":
|
||||
return registrationMethodControlPlaneEndpoint, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported registration method: %s", method)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ func TestNewRegistrationMethod(t *testing.T) {
|
|||
name: "control-plane-endpoint",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "unknownmethod",
|
||||
expectError: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue