Skip to content

Commit

Permalink
Feat: migrate cluster management methods
Browse files Browse the repository at this point in the history
Signed-off-by: Yin Da <[email protected]>
  • Loading branch information
Somefive committed Apr 14, 2023
1 parent 8ab4e3b commit fa4bb75
Show file tree
Hide file tree
Showing 10 changed files with 800 additions and 84 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,24 @@ jobs:
if: needs.detect-noop.outputs.noop != 'true'
steps:
- name: Set up Go
uses: actions/setup-go@v1
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true
- name: Cache Go Dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-
- name: Install clusteradm
run: curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.2.0
uses: helm/kind-action@v1.5.0
- name: Prepare OCM testing environment
run: |
clusteradm init --output-join-command-file join.sh --wait
Expand Down
17 changes: 11 additions & 6 deletions cmd/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/server"
genericfilters "k8s.io/apiserver/pkg/server/filters"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog/v2"
"sigs.k8s.io/apiserver-runtime/pkg/builder"

genericfilters "k8s.io/apiserver/pkg/server/filters"

"github.com/oam-dev/cluster-gateway/pkg/config"
"github.com/oam-dev/cluster-gateway/pkg/featuregates"
"github.com/oam-dev/cluster-gateway/pkg/metrics"
"github.com/oam-dev/cluster-gateway/pkg/options"
"github.com/oam-dev/cluster-gateway/pkg/util/singleton"
Expand All @@ -41,10 +42,9 @@ func main() {
// registering metrics
metrics.Register()

cmd, err := builder.APIServer.
apiserverBuilder := builder.APIServer.
// +kubebuilder:scaffold:resource-register
WithResource(&clusterv1alpha1.ClusterGateway{}).
WithResource(&clusterv1alpha1.VirtualCluster{}).
WithLocalDebugExtension().
ExposeLoopbackMasterClientConfig().
ExposeLoopbackAuthorizer().
Expand Down Expand Up @@ -74,8 +74,13 @@ func main() {
server.Handler.FullHandlerChain = clusterv1alpha1.NewClusterGatewayProxyRequestEscaper(server.Handler.FullHandlerChain)
return server
}).
WithPostStartHook("init-master-loopback-client", singleton.InitLoopbackClient).
Build()
WithPostStartHook("init-master-loopback-client", singleton.InitLoopbackClient)

if utilfeature.DefaultMutableFeatureGate.Enabled(featuregates.VirtualCluster) {
apiserverBuilder = apiserverBuilder.WithResource(&clusterv1alpha1.VirtualCluster{})
}

cmd, err := apiserverBuilder.Build()
if err != nil {
klog.Fatal(err)
}
Expand Down
13 changes: 13 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ module github.com/oam-dev/cluster-gateway
go 1.19

require (
github.com/fatih/color v1.13.0
github.com/ghodss/yaml v1.0.0
github.com/gobuffalo/flect v0.3.0
github.com/oam-dev/cluster-register v1.0.3
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.6.1
github.com/onsi/gomega v1.24.2
Expand All @@ -12,6 +15,7 @@ require (
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.0
golang.org/x/tools v0.4.0
google.golang.org/grpc v1.49.0
k8s.io/api v0.26.3
k8s.io/apimachinery v0.26.3
Expand All @@ -33,6 +37,9 @@ require (
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -63,12 +70,17 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // 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/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // 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
Expand Down Expand Up @@ -97,6 +109,7 @@ require (
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sync v0.1.0 // indirect
Expand Down
Loading

0 comments on commit fa4bb75

Please sign in to comment.