Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Mark mechanically-generated code so GitHub collapses it by default in the
# "Files changed" PR view and excludes it from diff/line-count stats.
# See https://github.blog/changelog/2019-06-24-github-is-generally-available-in-chrome-opera-and-firefox-extensions/
# and https://docs.github.com/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github
api/**/zz_generated.deepcopy.go linguist-generated=true
config/crd/bases/*.yaml linguist-generated=true
pkg/applyconfigurations/**/*.go linguist-generated=true
pkg/generated/**/*.go linguist-generated=true
pkg/generated/**/*.json linguist-generated=true
64 changes: 62 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ CONTROLLER_GEN_VER := v0.20.0
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))

CLIENT_GEN_VER := v0.34.1
CLIENT_GEN_BIN := client-gen
CLIENT_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CLIENT_GEN_BIN)-$(CLIENT_GEN_VER))

AC_GEN_VER := v0.34.1
AC_GEN_BIN := applyconfiguration-gen
AC_GEN := $(abspath $(TOOLS_BIN_DIR)/$(AC_GEN_BIN)-$(AC_GEN_VER))

OPENAPI_GEN_VER := v0.0.0-20250910181357-589584f1c912
OPENAPI_GEN_BIN := openapi-gen
OPENAPI_GEN := $(abspath $(TOOLS_BIN_DIR)/$(OPENAPI_GEN_BIN)-$(OPENAPI_GEN_VER))

STATICCHECK_VER := master
STATICCHECK_BIN := staticcheck
STATICCHECK := $(abspath $(TOOLS_BIN_DIR)/$(STATICCHECK_BIN)-$(STATICCHECK_VER))
Expand Down Expand Up @@ -84,6 +96,15 @@ $(GOLANGCI_LINT):
$(CONTROLLER_GEN):
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/controller-tools/cmd/controller-gen $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)

$(CLIENT_GEN):
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) k8s.io/code-generator/cmd/client-gen $(CLIENT_GEN_BIN) $(CLIENT_GEN_VER)

$(AC_GEN):
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) k8s.io/code-generator/cmd/applyconfiguration-gen $(AC_GEN_BIN) $(AC_GEN_VER)

$(OPENAPI_GEN):
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) k8s.io/kube-openapi/cmd/openapi-gen $(OPENAPI_GEN_BIN) $(OPENAPI_GEN_VER)

# Style checks
$(STATICCHECK):
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) honnef.co/go/tools/cmd/staticcheck $(STATICCHECK_BIN) $(STATICCHECK_VER)
Expand Down Expand Up @@ -172,9 +193,48 @@ manifests: $(CONTROLLER_GEN)
$(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases

# Generate code
generate: $(CONTROLLER_GEN)
generate: $(CONTROLLER_GEN) $(CLIENT_GEN) $(AC_GEN) $(OPENAPI_GEN)
$(CONTROLLER_GEN) \
object:headerFile="hack/boilerplate.go.txt" paths="./..."
object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
$(OPENAPI_GEN) \
--output-pkg "go.goms.io/fleet-networking/pkg/generated/openapi" \
--output-dir "pkg/generated/openapi" \
--output-file "zz_generated.openapi.go" \
--go-header-file "hack/boilerplate.go.txt" \
--report-filename "-" \
-v 5 \
"go.goms.io/fleet-networking/api/v1alpha1" \
"go.goms.io/fleet-networking/api/v1beta1" \
"k8s.io/apimachinery/pkg/apis/meta/v1" \
"k8s.io/apimachinery/pkg/runtime" \
"k8s.io/apimachinery/pkg/util/intstr" \
"k8s.io/apimachinery/pkg/api/resource" \
"k8s.io/api/core/v1" \
"k8s.io/api/discovery/v1"
go run ./hack/tools/openapi-schema-gen \
--output-file "pkg/generated/openapi/openapi_generated.json"
$(AC_GEN) \
"go.goms.io/fleet-networking/api/v1beta1" \
--output-pkg "go.goms.io/fleet-networking/pkg/applyconfigurations" \
--go-header-file "hack/boilerplate.go.txt" \
--output-dir "pkg/applyconfigurations" \
--openapi-schema "pkg/generated/openapi/openapi_generated.json" \
-v 5
$(AC_GEN) \
"go.goms.io/fleet-networking/api/v1alpha1" \
--output-pkg "go.goms.io/fleet-networking/pkg/applyconfigurations" \
--go-header-file "hack/boilerplate.go.txt" \
--output-dir "pkg/applyconfigurations" \
--openapi-schema "pkg/generated/openapi/openapi_generated.json" \
-v 5
$(CLIENT_GEN) \
--apply-configuration-package "go.goms.io/fleet-networking/pkg/applyconfigurations" \
--input-base "go.goms.io/fleet-networking/" \
--input "api/v1alpha1,api/v1beta1" \
--output-pkg "go.goms.io/fleet-networking/pkg/generated/clientset" \
--output-dir "pkg/generated/clientset" \
--go-header-file "hack/boilerplate.go.txt" \
-v 5

## --------------------------------------
## Build
Expand Down
10 changes: 10 additions & 0 deletions api/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
*/

// Package v1alpha1 contains API Schema definitions for the networking.fleet v1alpha1 API group.

// +groupName=networking.fleet.azure.com
// +k8s:openapi-gen=true
package v1alpha1
9 changes: 8 additions & 1 deletion api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ import (
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

const GroupName = "networking.fleet.azure.com"

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "networking.fleet.azure.com", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
Install = SchemeBuilder.AddToScheme

// SchemeGroupVersion is group version used to register these objects
// Deprecated: use GroupVersion instead.
SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
)
1 change: 1 addition & 0 deletions api/v1alpha1/internalserviceexport_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type InternalServiceExportStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=internalsvcexport
// +kubebuilder:subresource:status
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/internalserviceimport_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=internalsvcimport
// +kubebuilder:subresource:status
Expand Down
71 changes: 71 additions & 0 deletions api/v1alpha1/multiclusterloadbalancer_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
*/

package v1alpha1

import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=mclb
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:JSONPath=`.status.loadBalancer.ingress[0].ip`,name="External-IP",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=='Valid')].status`,name="Is-Valid",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=='Deployed')].status`,name="Is-Deployed",type=string
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date

// MultiClusterService is the Schema for creating north-south L4 load balancer to consume services across clusters.
// +kubebuilder:validation:XValidation:rule="size(self.metadata.name) < 64",message="metadata.name max length is 63"
type MultiClusterLoadBalancer struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec defines the desired state of MultiClusterLoadBalancer
// Spec MultiClusterLoadBalancerSpec `json:"spec,omitempty"`
// Status represents the current status of MultiClusterLoadBalancer
// +optional
Status MultiClusterLoadBalancerStatus `json:"status,omitempty"`
}

// MultiClusterLoadBalancerStatus contains the current status of an export.
type MultiClusterLoadBalancerStatus struct {
// LoadBalancer contains the current status of the load-balancer,
// if one is present.
// +optional
LoadBalancer v1.LoadBalancerStatus `json:"loadBalancer,omitempty" protobuf:"bytes,1,opt,name=loadBalancer"`
// +optional
// +patchStrategy=merge
// +patchMergeKey=type
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}

// LoadBalancerConditionType identifies a specific condition on a MultiClusterLoadBalancer.
type LoadBalancerConditionType string

const (
// LoadBalancerValid means that the service referenced by this service export has been recognized as valid.
// This will be false if the service is found to be unexportable (e.g. ExternalName, not found).
LoadBalancerValid LoadBalancerConditionType = "Valid"
)

// +kubebuilder:object:root=true

// MultiClusterLoadBalancerList contains a list of MultiClusterLoadBalancer.
type MultiClusterLoadBalancerList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// +listType=set
Items []MultiClusterLoadBalancer `json:"items"`
}

func init() {
SchemeBuilder.Register(&MultiClusterLoadBalancer{}, &MultiClusterLoadBalancerList{})
}
1 change: 1 addition & 0 deletions api/v1alpha1/serviceexport_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ServiceExportStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=svcexport
// +kubebuilder:subresource:status
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha1/serviceimport_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=svcimport
// +kubebuilder:subresource:status
Expand Down Expand Up @@ -118,7 +119,7 @@ type ServiceImportStatus struct {
// +patchMergeKey=cluster
// +listType=map
// +listMapKey=cluster
Clusters []ClusterStatus `json:"clusters,omitempty"`
Clusters []ClusterStatus `json:"clusters,omitempty" patchStrategy:"merge" patchMergeKey:"cluster"`
}

// ClusterStatus contains service configuration mapped to a specific source cluster.
Expand Down
83 changes: 82 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/v1beta1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Licensed under the MIT license.

// +kubebuilder:object:generate=true
// +k8s:deepcopy-gen=package,register
// +k8s:openapi-gen=true
// +groupName=networking.fleet.azure.com

// Package v1beta1 contains API Schema definitions for the fleet networking v1beta1 API group.
Expand Down
8 changes: 7 additions & 1 deletion api/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ import (
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

const GroupName = "networking.fleet.azure.com"

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "networking.fleet.azure.com", Version: "v1beta1"}
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme

// SchemeGroupVersion is group version used to register these objects
// Deprecated: use GroupVersion instead.
SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}
)
1 change: 1 addition & 0 deletions api/v1beta1/serviceexport_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ServiceExportStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=svcexport
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading