Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for v1beta1 cluster API #157

Merged
merged 4 commits into from
Sep 6, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build-publish-mcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
# `public` indicates images to MCR wil be publicly available, and will be removed in the final MCR images
REGISTRY_REPO: public/aks/fleet

GO_VERSION: '1.18'
GO_VERSION: '1.20'

jobs:
prepare-variables:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:
contents: read

env:
GO_VERSION: '1.18'
GO_VERSION: '1.20'

jobs:
detect-noop:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

env:
# Common versions
GO_VERSION: '1.18'
GO_VERSION: '1.20'

jobs:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
REGISTRY: ghcr.io
IMAGE_VERSION: latest

GO_VERSION: '1.18'
GO_VERSION: '1.20'

jobs:
export-registry:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
MEMBER_NET_CONTROLLER_MANAGER_IMAGE_NAME: member-net-controller-manager
MCS_CONTROLLER_MANAGER_IMAGE_NAME: mcs-controller-manager

GO_VERSION: '1.18'
GO_VERSION: '1.20'

jobs:
export-registry:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ permissions:
contents: read

env:
GO_VERSION: '1.18'
GO_VERSION: '1.20'

jobs:
detect-noop:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ CONTROLLER_GEN_VER := v0.7.0
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))

STATICCHECK_VER := 2022.1
STATICCHECK_VER := 2023.1
STATICCHECK_BIN := staticcheck
STATICCHECK := $(abspath $(TOOLS_BIN_DIR)/$(STATICCHECK_BIN)-$(STATICCHECK_VER))

GOIMPORTS_VER := latest
GOIMPORTS_BIN := goimports
GOIMPORTS := $(abspath $(TOOLS_BIN_DIR)/$(GOIMPORTS_BIN)-$(GOIMPORTS_VER))

GOLANGCI_LINT_VER := v1.46.2
GOLANGCI_LINT_VER := v1.52.2
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))

Expand Down
2 changes: 2 additions & 0 deletions charts/mcs-controller-manager/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ spec:
- --tls-insecure={{ .Values.tlsClientInsecure }}
- --v={{ .Values.logVerbosity }}
- --add_dir_header
- --enable-v1alpha1-apis={{ .Values.enableV1Alpha1APIs }}
- --enable-v1beta1-apis={{ .Values.enableV1Beta1APIs }}
ports:
- containerPort: 8080
name: hubmetrics
Expand Down
3 changes: 3 additions & 0 deletions charts/mcs-controller-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ nodeSelector: {}
tolerations: []

affinity: {}

enableV1Alpha1APIs: true
enableV1Beta1APIs: false
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
- --tls-insecure={{ .Values.tlsClientInsecure }}
- --v={{ .Values.logVerbosity }}
- --add_dir_header
- --enable-v1alpha1-apis={{ .Values.enableV1Alpha1APIs }}
- --enable-v1beta1-apis={{ .Values.enableV1Beta1APIs }}
ports:
- containerPort: 8080
name: hubmetrics
Expand Down
5 changes: 4 additions & 1 deletion charts/member-net-controller-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ nodeSelector: {}

tolerations: []

affinity: {}
affinity: {}

enableV1Alpha1APIs: true
enableV1Beta1APIs: false
39 changes: 29 additions & 10 deletions cmd/mcs-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"

//+kubebuilder:scaffold:imports
clusterv1beta1 "go.goms.io/fleet/apis/cluster/v1beta1"
fleetv1alpha1 "go.goms.io/fleet/apis/v1alpha1"

fleetnetv1alpha1 "go.goms.io/fleet-networking/api/v1alpha1"
"go.goms.io/fleet-networking/pkg/common/hubconfig"
"go.goms.io/fleet-networking/pkg/controllers/member/internalmembercluster"
imcv1alpha1 "go.goms.io/fleet-networking/pkg/controllers/member/internalmembercluster/v1alpha1"
imcv1beta1 "go.goms.io/fleet-networking/pkg/controllers/member/internalmembercluster/v1beta1"
"go.goms.io/fleet-networking/pkg/controllers/multiclusterservice"
)

Expand All @@ -52,6 +54,9 @@ var (

tlsClientInsecure = flag.Bool("tls-insecure", false, "Enable TLSClientConfig.Insecure property. Enabling this will make the connection inSecure (should be 'true' for testing purpose only.)")
fleetSystemNamespace = flag.String("fleet-system-namespace", "fleet-system", "The reserved system namespace used by fleet.")

isV1Alpha1APIEnabled = flag.Bool("enable-v1alpha1-apis", true, "If set, the agents will watch for the v1alpha1 APIs.")
isV1Beta1APIEnabled = flag.Bool("enable-v1beta1-apis", false, "If set, the agents will watch for the v1beta1 APIs.")
)

func init() {
Expand Down Expand Up @@ -213,7 +218,7 @@ func prepareMemberParameters() (*rest.Config, *ctrl.Options) {
return ctrl.GetConfigOrDie(), memberOpts
}

func setupControllersWithManager(ctx context.Context, hubMgr, memberMgr manager.Manager) error {
func setupControllersWithManager(_ context.Context, hubMgr, memberMgr manager.Manager) error {
klog.V(1).InfoS("Begin to setup controllers with controller manager")
memberClient := memberMgr.GetClient()
hubClient := hubMgr.GetClient()
Expand All @@ -229,14 +234,28 @@ func setupControllersWithManager(ctx context.Context, hubMgr, memberMgr manager.
return err
}

klog.V(1).InfoS("Create internalmembercluster reconciler")
if err := (&internalmembercluster.Reconciler{
MemberClient: memberClient,
HubClient: hubClient,
AgentType: fleetv1alpha1.MultiClusterServiceAgent,
}).SetupWithManager(hubMgr); err != nil {
klog.ErrorS(err, "Unable to create internalmembercluster reconciler")
return err
if *isV1Alpha1APIEnabled {
klog.V(1).InfoS("Create internalmembercluster (v1alpha1 API) reconciler")
if err := (&imcv1alpha1.Reconciler{
MemberClient: memberClient,
HubClient: hubClient,
AgentType: fleetv1alpha1.MultiClusterServiceAgent,
}).SetupWithManager(hubMgr); err != nil {
klog.ErrorS(err, "Unable to create internalmembercluster (v1alpha1 API) reconciler")
return err
}
}

if *isV1Beta1APIEnabled {
klog.V(1).InfoS("Create internalmembercluster (v1beta1 API) reconciler")
if err := (&imcv1beta1.Reconciler{
MemberClient: memberClient,
HubClient: hubClient,
AgentType: clusterv1beta1.MultiClusterServiceAgent,
}).SetupWithManager(hubMgr); err != nil {
klog.ErrorS(err, "Unable to create internalmembercluster (v1beta1 API) reconciler")
return err
}
}

klog.V(1).InfoS("Succeeded to setup controllers with controller manager")
Expand Down
37 changes: 28 additions & 9 deletions cmd/member-net-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"

//+kubebuilder:scaffold:imports
clusterv1beta1 "go.goms.io/fleet/apis/cluster/v1beta1"
fleetv1alpha1 "go.goms.io/fleet/apis/v1alpha1"

fleetnetv1alpha1 "go.goms.io/fleet-networking/api/v1alpha1"
Expand All @@ -38,7 +39,8 @@ import (
"go.goms.io/fleet-networking/pkg/controllers/member/endpointslice"
"go.goms.io/fleet-networking/pkg/controllers/member/endpointsliceexport"
"go.goms.io/fleet-networking/pkg/controllers/member/endpointsliceimport"
"go.goms.io/fleet-networking/pkg/controllers/member/internalmembercluster"
imcv1alpha1 "go.goms.io/fleet-networking/pkg/controllers/member/internalmembercluster/v1alpha1"
imcv1beta1 "go.goms.io/fleet-networking/pkg/controllers/member/internalmembercluster/v1beta1"
"go.goms.io/fleet-networking/pkg/controllers/member/internalserviceexport"
"go.goms.io/fleet-networking/pkg/controllers/member/internalserviceimport"
"go.goms.io/fleet-networking/pkg/controllers/member/serviceexport"
Expand All @@ -58,6 +60,9 @@ var (

tlsClientInsecure = flag.Bool("tls-insecure", false, "Enable TLSClientConfig.Insecure property. Enabling this will make the connection inSecure (should be 'true' for testing purpose only.)")
fleetSystemNamespace = flag.String("fleet-system-namespace", "fleet-system", "The reserved system namespace used by fleet.")

isV1Alpha1APIEnabled = flag.Bool("enable-v1alpha1-apis", true, "If set, the agents will watch for the v1alpha1 APIs.")
isV1Beta1APIEnabled = flag.Bool("enable-v1beta1-apis", false, "If set, the agents will watch for the v1beta1 APIs.")
zhiying-lin marked this conversation as resolved.
Show resolved Hide resolved
)

func init() {
Expand Down Expand Up @@ -311,14 +316,28 @@ func setupControllersWithManager(ctx context.Context, hubMgr, memberMgr manager.
return err
}

klog.V(1).InfoS("Create internalmembercluster reconciler")
if err := (&internalmembercluster.Reconciler{
MemberClient: memberClient,
HubClient: hubClient,
AgentType: fleetv1alpha1.ServiceExportImportAgent,
}).SetupWithManager(hubMgr); err != nil {
klog.ErrorS(err, "Unable to create internalmembercluster reconciler")
return err
if *isV1Alpha1APIEnabled {
klog.V(1).InfoS("Create internalmembercluster (v1alpha1 API) reconciler")
if err := (&imcv1alpha1.Reconciler{
MemberClient: memberClient,
HubClient: hubClient,
AgentType: fleetv1alpha1.ServiceExportImportAgent,
}).SetupWithManager(hubMgr); err != nil {
klog.ErrorS(err, "Unable to create internalmembercluster (v1alpha1 API) reconciler")
return err
}
}

if *isV1Beta1APIEnabled {
klog.V(1).InfoS("Create internalmembercluster (v1beta1 API) reconciler")
if err := (&imcv1beta1.Reconciler{
MemberClient: memberClient,
HubClient: hubClient,
AgentType: clusterv1beta1.ServiceExportImportAgent,
}).SetupWithManager(hubMgr); err != nil {
klog.ErrorS(err, "Unable to create internalmembercluster (v1beta1 API) reconciler")
return err
}
}

klog.V(1).InfoS("Succeeded to setup controllers with controller manager")
Expand Down
97 changes: 45 additions & 52 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
module go.goms.io/fleet-networking

go 1.18
go 1.20

require (
github.com/google/go-cmp v0.5.8
github.com/onsi/ginkgo/v2 v2.1.6
github.com/onsi/gomega v1.20.1
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/common v0.37.0
k8s.io/api v0.25.2
k8s.io/apimachinery v0.25.2
k8s.io/client-go v0.25.2
k8s.io/klog/v2 v2.70.1
sigs.k8s.io/controller-runtime v0.12.2
github.com/google/go-cmp v0.5.9
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.7
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/common v0.44.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/klog/v2 v2.100.1
sigs.k8s.io/controller-runtime v0.14.6
)

require (
github.com/stretchr/testify v1.7.0
go.goms.io/fleet v0.6.1
github.com/stretchr/testify v1.8.1
go.goms.io/fleet v0.6.11
)

replace (
Expand All @@ -32,67 +32,60 @@ replace (
)

require (
cloud.google.com/go v0.99.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/zapr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/procfs v0.10.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.11.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.11.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.24.2 // indirect
k8s.io/component-base v0.24.2 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 // indirect
k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading
Loading