Skip to content

Commit

Permalink
Merge pull request #80 from MrFreezeex/svcoperator-multipleips
Browse files Browse the repository at this point in the history
apis: increase max lengths of ips to 2
  • Loading branch information
k8s-ci-robot authored Jan 16, 2025
2 parents b858d70 + f9bf777 commit e786573
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/crd/multicluster.x-k8s.io_serviceimports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ spec:
ips:
description: ip will be used as the VIP for this service when type is ClusterSetIP.
type: array
maxItems: 1
maxItems: 2
items:
type: string
ports:
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/v1alpha1/serviceimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type ServiceImportSpec struct {
// +listType=atomic
Ports []ServicePort `json:"ports"`
// ip will be used as the VIP for this service when type is ClusterSetIP.
// +kubebuilder:validation:MaxItems:=1
// +kubebuilder:validation:MaxItems:=2
// +optional
IPs []string `json:"ips,omitempty"`
// type defines the type of this service.
Expand Down
3 changes: 2 additions & 1 deletion pkg/controllers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
return ctrl.Result{}, nil
}

svcImport.Spec.IPs = []string{service.Spec.ClusterIP}
ipsLen := min(2, len(service.Spec.ClusterIPs))
svcImport.Spec.IPs = service.Spec.ClusterIPs[:ipsLen]
if err := r.Client.Update(ctx, &svcImport); err != nil {
return ctrl.Result{}, err
}
Expand Down

0 comments on commit e786573

Please sign in to comment.