-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
705 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,8 @@ jobs: | |
${{ runner.os }}-go- | ||
- name: Test and update codecov | ||
run: | | ||
go test -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
make bin/envtest | ||
export KUBEBUILDER_ASSETS=$(pwd)/bin/envtest && go test -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
- uses: codecov/[email protected] | ||
with: | ||
file: ./coverage.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# IDE and editor files | ||
.idea | ||
.vscode | ||
bin | ||
/bin | ||
/kubebuilder | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ CRD_YAML_DIR=charts/hybridnet/crds | |
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false" | ||
|
||
.PHONY: build-dev-images release | ||
.PHONY: build-dev-images release code-gen generate crd-yamls test | ||
|
||
build-dev-images: | ||
@for arch in ${ARCHS} ; do \ | ||
|
@@ -25,21 +25,31 @@ release: | |
code-gen: | ||
cd hack && chmod u+x ./update-codegen.sh && ./update-codegen.sh | ||
|
||
crd-yamls: controller-gen ## Generate CustomResourceDefinition objects. | ||
crd-yamls: bin/controller-gen ## Generate CustomResourceDefinition objects. | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=hybridnet webhook paths="./pkg/apis/..." output:crd:artifacts:config=${CRD_YAML_DIR} && rm -rf ./config | ||
|
||
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. | ||
generate: bin/controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. | ||
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/apis/..." | ||
|
||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
controller-gen: ## Download controller-gen locally if necessary. | ||
bin/controller-gen: ## Download controller-gen locally if necessary. | ||
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected]) | ||
|
||
# use command of "./bin/kubebuilder create api --group multicluster --kind RemoteXXX --version v1 --namespaced=false" to generate crd types | ||
KUBEBUILDER_BIN = $(shell pwd)/bin/kubebuilder | ||
kubebuilder: ## Download kubebuilder binary locally if necessary. | ||
bin/kubebuilder: ## Download kubebuilder binary locally if necessary. | ||
$(call curl-get-tool,$(KUBEBUILDER_BIN),https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.1.0/kubebuilder_${GOOS}_${GOARCH}) | ||
|
||
ENVTEST_BINS = $(shell pwd)/bin/envtest | ||
bin/envtest: ## download envtest binaries | ||
curl -sSLo envtest-bins.tar.gz "https://go.kubebuilder.io/test-tools/1.20.2/$(GOOS)/$(GOARCH)" | ||
if [ ! -d bin ]; then mkdir bin; fi | ||
tar -zvxf envtest-bins.tar.gz && cp -r kubebuilder/bin $(ENVTEST_BINS) | ||
rm -rf kubebuilder && rm envtest-bins.tar.gz | ||
|
||
test: bin/envtest | ||
export KUBEBUILDER_ASSETS=$(shell pwd)/bin/envtest && go test -v ./... | ||
|
||
# go-get-tool will 'go get' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
define go-get-tool | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright 2021 The Hybridnet Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package multicluster | ||
|
||
import ( | ||
"fmt" | ||
|
||
ctrl "sigs.k8s.io/controller-runtime" | ||
|
||
"github.com/alibaba/hybridnet/pkg/controllers/multicluster/clusterchecker" | ||
"github.com/alibaba/hybridnet/pkg/controllers/utils" | ||
) | ||
|
||
func InitClusterStatusChecker(mgr ctrl.Manager) (clusterchecker.Checker, error) { | ||
clusterUUID, err := utils.GetClusterUUID(mgr.GetClient()) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to get cluster UUID: %v", err) | ||
} | ||
|
||
checker := clusterchecker.NewChecker() | ||
|
||
if err = checker.Register(clusterchecker.HealthzCheckName, &clusterchecker.Healthz{}); err != nil { | ||
return nil, err | ||
} | ||
if err = checker.Register(clusterchecker.BidirectionCheckName, &clusterchecker.Bidirection{LocalUUID: clusterUUID}); err != nil { | ||
return nil, err | ||
} | ||
if err = checker.Register(clusterchecker.OverlayNetIDCheckName, &clusterchecker.OverlayNetID{LocalClient: mgr.GetClient()}); err != nil { | ||
return nil, err | ||
} | ||
if err = checker.Register(clusterchecker.SubnetCheckName, &clusterchecker.Subnet{LocalClient: mgr.GetClient()}); err != nil { | ||
return nil, err | ||
} | ||
return checker, nil | ||
} |
Oops, something went wrong.