diff --git a/api/v1alpha1/internalserviceexport_types.go b/api/v1alpha1/internalserviceexport_types.go index 6a5e967a..39993590 100644 --- a/api/v1alpha1/internalserviceexport_types.go +++ b/api/v1alpha1/internalserviceexport_types.go @@ -13,8 +13,6 @@ import ( // InternalServiceExportSpec specifies the spec of an exported Service; at this stage only the ports of an // exported Service are sync'd. type InternalServiceExportSpec struct { - // ServiceExportSpec contains the spec of the ServiceExport. - ServiceExportSpec *ServiceExportSpec `json:"serviceExportSpec,omitempty"` // A list of ports exposed by the exported Service. // +listType=atomic Ports []ServicePort `json:"ports"` diff --git a/api/v1alpha1/serviceexport_types.go b/api/v1alpha1/serviceexport_types.go index bbdda965..efe00aab 100644 --- a/api/v1alpha1/serviceexport_types.go +++ b/api/v1alpha1/serviceexport_types.go @@ -9,27 +9,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -const ( - // ExportedAnnotationsWeight is the key for the weight annotation as an exportedAnnotation on a ServiceExport. - ExportedAnnotationsWeight = "weight" -) - -// ServiceExportSpec describes an exported service extra information. -type ServiceExportSpec struct { - // exportedLabels describes the labels exported. - // +optional - ExportedLabels map[string]string `json:"exportedLabels,omitempty"` - // exportedAnnotations describes the annotations exported. - // Possible Annotations: "weight". - // "weight" specifies the proportion of requests forwarded to the cluster within a serviceImport. - // This is computed as weight/(sum of all weights in the serviceImport). - // If weight is set to 0, no traffic should be forwarded for this entry. If unspecified, weight defaults to 1. - // The value should be in the range [0, 1000]. - // - // +optional - ExportedAnnotations map[string]string `json:"exportedAnnotations,omitempty"` -} - // ServiceExportConditionType identifies a specific condition on a ServiceExport. type ServiceExportConditionType string @@ -62,14 +41,18 @@ type ServiceExportStatus struct { // +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date // ServiceExport declares that the associated service should be exported to other clusters. +// The annotation "networking.fleet.azure.com/weight" specifies the proportion of requests forwarded to the cluster +// within a serviceImport. +// The actual value is the ceiling value of a number computed as weight/(sum of all weights in the serviceImport). +// If weight is set to 0, no traffic should be forwarded for this entry. +// If unspecified, weight defaults to 1. +// The value should be in the range [0, 1000]. +// Any invalid value will default to default value. // +kubebuilder:validation:XValidation:rule="size(self.metadata.name) < 64",message="metadata.name max length is 63" type ServiceExport struct { metav1.TypeMeta `json:",inline"` // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - // spec defines the behavior of a ServiceExport. - // +optional - Spec ServiceExportSpec `json:"spec,omitempty"` // +optional Status ServiceExportStatus `json:"status,omitempty"` } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index e39c17a0..c66a0931 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -297,11 +297,6 @@ func (in *InternalServiceExportList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InternalServiceExportSpec) DeepCopyInto(out *InternalServiceExportSpec) { *out = *in - if in.ServiceExportSpec != nil { - in, out := &in.ServiceExportSpec, &out.ServiceExportSpec - *out = new(ServiceExportSpec) - (*in).DeepCopyInto(*out) - } if in.Ports != nil { in, out := &in.Ports, &out.Ports *out = make([]ServicePort, len(*in)) @@ -587,7 +582,6 @@ func (in *ServiceExport) DeepCopyInto(out *ServiceExport) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) } @@ -641,35 +635,6 @@ func (in *ServiceExportList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceExportSpec) DeepCopyInto(out *ServiceExportSpec) { - *out = *in - if in.ExportedLabels != nil { - in, out := &in.ExportedLabels, &out.ExportedLabels - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.ExportedAnnotations != nil { - in, out := &in.ExportedAnnotations, &out.ExportedAnnotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceExportSpec. -func (in *ServiceExportSpec) DeepCopy() *ServiceExportSpec { - if in == nil { - return nil - } - out := new(ServiceExportSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceExportStatus) DeepCopyInto(out *ServiceExportStatus) { *out = *in diff --git a/config/crd/bases/networking.fleet.azure.com_internalserviceexports.yaml b/config/crd/bases/networking.fleet.azure.com_internalserviceexports.yaml index 71e2a399..9123b6b6 100644 --- a/config/crd/bases/networking.fleet.azure.com_internalserviceexports.yaml +++ b/config/crd/bases/networking.fleet.azure.com_internalserviceexports.yaml @@ -115,26 +115,6 @@ spec: type: object type: array x-kubernetes-list-type: atomic - serviceExportSpec: - description: ServiceExportSpec contains the spec of the ServiceExport. - properties: - exportedAnnotations: - additionalProperties: - type: string - description: |- - exportedAnnotations describes the annotations exported. - Possible Annotations: "weight". - "weight" specifies the proportion of requests forwarded to the cluster within a serviceImport. - This is computed as weight/(sum of all weights in the serviceImport). - If weight is set to 0, no traffic should be forwarded for this entry. If unspecified, weight defaults to 1. - The value should be in the range [0, 1000]. - type: object - exportedLabels: - additionalProperties: - type: string - description: exportedLabels describes the labels exported. - type: object - type: object serviceReference: description: The reference to the source Service. properties: diff --git a/config/crd/bases/networking.fleet.azure.com_serviceexports.yaml b/config/crd/bases/networking.fleet.azure.com_serviceexports.yaml index ed29c2fd..f7404672 100644 --- a/config/crd/bases/networking.fleet.azure.com_serviceexports.yaml +++ b/config/crd/bases/networking.fleet.azure.com_serviceexports.yaml @@ -31,8 +31,15 @@ spec: name: v1alpha1 schema: openAPIV3Schema: - description: ServiceExport declares that the associated service should be - exported to other clusters. + description: |- + ServiceExport declares that the associated service should be exported to other clusters. + The annotation "networking.fleet.azure.com/weight" specifies the proportion of requests forwarded to the cluster + within a serviceImport. + The actual value is the ceiling value of a number computed as weight/(sum of all weights in the serviceImport). + If weight is set to 0, no traffic should be forwarded for this entry. + If unspecified, weight defaults to 1. + The value should be in the range [0, 1000]. + Any invalid value will default to default value. properties: apiVersion: description: |- @@ -51,26 +58,6 @@ spec: type: string metadata: type: object - spec: - description: spec defines the behavior of a ServiceExport. - properties: - exportedAnnotations: - additionalProperties: - type: string - description: |- - exportedAnnotations describes the annotations exported. - Possible Annotations: "weight". - "weight" specifies the proportion of requests forwarded to the cluster within a serviceImport. - This is computed as weight/(sum of all weights in the serviceImport). - If weight is set to 0, no traffic should be forwarded for this entry. If unspecified, weight defaults to 1. - The value should be in the range [0, 1000]. - type: object - exportedLabels: - additionalProperties: - type: string - description: exportedLabels describes the labels exported. - type: object - type: object status: description: ServiceExportStatus contains the current status of an export. properties: diff --git a/pkg/common/objectmeta/objectmeta.go b/pkg/common/objectmeta/objectmeta.go index bda56a2f..6bdbf252 100644 --- a/pkg/common/objectmeta/objectmeta.go +++ b/pkg/common/objectmeta/objectmeta.go @@ -45,6 +45,9 @@ const ( // an exported object. ExportedObjectAnnotationUniqueName = fleetNetworkingPrefix + "fleet-unique-name" + // ServiceExportAnnotationWeight is an annotation that marks the weight of the ServiceExport. + ServiceExportAnnotationWeight = fleetNetworkingPrefix + "weight" + // ServiceAnnotationAzureLoadBalancerInternal is an annotation that marks the Service as an internal load balancer by cloud-provider-azure. ServiceAnnotationAzureLoadBalancerInternal = "service.beta.kubernetes.io/azure-load-balancer-internal"