forked from yunify/qingcloud-cloud-controller-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactore the Load Balancer Controller
Remove useless controllers , such as zone, node,etc. The api is introduced to describe the objects in the load balancer, for example eip, lb, listener, backend etc. Fix some issues, such as yunify#101, yunify#98, yunify#81, yunify#63 Fix incorrect vip display when there are multiple private ip's. Signed-off-by: Duan Jiong <[email protected]>
- Loading branch information
Showing
3,388 changed files
with
3,059 additions
and
1,134,431 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
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
This file was deleted.
Oops, something went wrong.
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,73 +1,48 @@ | ||
# tab space is 4 | ||
# GitHub viewer defaults to 8, change with ?ts=4 in URL | ||
|
||
# Vars describing project | ||
NAME= qingcloud-cloud-controller-manager | ||
GIT_REPOSITORY= github.com/yunify/qingcloud-cloud-controller-manager | ||
IMG?= kubespheredev/cloud-controller-manager:v1.4.2 | ||
IMG?= kubespheredev/cloud-controller-manager:latest | ||
#Debug level: 0, 1, 2 (1 true, 2 use bash) | ||
DEBUG?= 0 | ||
DOCKERFILE?= deploy/Dockerfile | ||
TARGET?= default | ||
DEPLOY?= deploy/kube-cloud-controller-manager.yaml | ||
|
||
# Generate vars to be included from external script | ||
# Allows using bash to generate complex vars, such as project versions | ||
GENERATE_VERSION_INFO_SCRIPT = ./generate_version.sh | ||
GENERATE_VERSION_INFO_OUTPUT = version_info | ||
|
||
# Define newline needed for subsitution to allow evaluating multiline script output | ||
define newline | ||
|
||
|
||
endef | ||
|
||
# Call the version_info script with keyvalue option and evaluate the output | ||
# Will import the keyvalue pairs and make available as Makefile variables | ||
# Use dummy variable to only have execute once | ||
$(eval $(subst #,$(newline),$(shell $(GENERATE_VERSION_INFO_SCRIPT) keyvalue | tr '\n' '#'))) | ||
# Call the verson_info script with json option and store result into output file and variable | ||
# Will only execute once due to ':=' | ||
#GENERATE_VERSION_INFO := $(shell $(GENERATE_VERSION_INFO_SCRIPT) json | tee $(GENERATE_VERSION_INFO_OUTPUT)) | ||
|
||
# Set defaults for needed vars in case version_info script did not set | ||
# Revision set to number of commits ahead | ||
VERSION ?= 0.0 | ||
COMMITS ?= 0 | ||
REVISION ?= $(COMMITS) | ||
BUILD_LABEL ?= unknown_build | ||
BUILD_DATE ?= $(shell date -u +%Y%m%d.%H%M%S) | ||
GIT_SHA1 ?= unknown_sha1 | ||
|
||
IMAGE_LABLE ?= $(BUILD_LABEL) | ||
ifneq ($(DEBUG), 0) | ||
DOCKERFILE = deploy/Dockerfile.debug | ||
TARGET = dev | ||
endif | ||
|
||
# default just build binary | ||
default : go-build | ||
|
||
# target for debugging / printing variables | ||
print-% : | ||
@echo '$*=$($*)' | ||
default: build | ||
|
||
# perform go build on project | ||
go-build : bin/qingcloud-cloud-controller-manager | ||
|
||
bin/qingcloud-cloud-controller-manager : | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w" -o bin/manager ./cmd/main.go | ||
|
||
bin/.docker-images-build-timestamp : bin/qingcloud-cloud-controller-manager Makefile Dockerfile | ||
docker build -q -t $(DOCKER_IMAGE_NAME):$(IMAGE_LABLE) -t dockerhub.qingcloud.com/$(DOCKER_IMAGE_NAME):$(IMAGE_LABLE) . > bin/.docker-images-build-timestamp | ||
|
||
publish : test go-build | ||
docker build -t ${IMG} -f deploy/Dockerfile bin/ | ||
docker push ${IMG} | ||
clean : | ||
rm -rf bin/ && if -f bin/.docker-images-build-timestamp then docker rmi `cat bin/.docker-images-build-timestamp` | ||
test : fmt vet | ||
go test -v -cover -mod=vendor ./pkg/... | ||
fmt : | ||
go fmt ./pkg/... ./cmd/... ./test/pkg/... | ||
build: bin/qingcloud-cloud-controller-manager | ||
|
||
bin/qingcloud-cloud-controller-manager: | ||
ifeq ($(DEBUG), 0) | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w" -o bin/manager ./cmd/main.go | ||
else | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags "all=-N -l" -o bin/manager ./cmd/main.go | ||
endif | ||
|
||
publish: test build | ||
docker build -t ${IMG} -f ${DOCKERFILE} bin/ | ||
@echo "updating kustomize image patch file for manager resource" | ||
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' config/${TARGET}/manager_image_patch.yaml | ||
docker push ${IMG} | ||
kustomize build config/${TARGET} > ${DEPLOY} | ||
|
||
clean: | ||
rm -rf bin/ | ||
|
||
test: fmt vet | ||
go test -v -cover ./pkg/... | ||
fmt: | ||
go fmt ./pkg/... ./cmd/... | ||
vet: | ||
go vet ./pkg/... ./cmd/... ./test/pkg/... | ||
|
||
debug: | ||
./hack/debug.sh | ||
|
||
.PHONY : default all go-build clean install-docker test | ||
go vet ./pkg/... ./cmd/... | ||
|
||
e2e: | ||
./hack/e2e.sh | ||
.PHONY : clean |
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,39 +1,51 @@ | ||
// Copyright 2017 Yunify Inc. All rights reserved. | ||
// Use of this source code is governed by a Apache license | ||
// that can be found in the LICENSE file. | ||
/* | ||
Copyright 2016 The Kubernetes 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. | ||
*/ | ||
|
||
// The external controller manager is responsible for running controller loops that | ||
// are cloud provider dependent. It uses the API to listen to new events on resources. | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"math/rand" | ||
"os" | ||
"time" | ||
|
||
_ "github.com/yunify/qingcloud-cloud-controller-manager/pkg/qingcloud" | ||
"k8s.io/component-base/logs" | ||
"k8s.io/kubernetes/cmd/cloud-controller-manager/app" | ||
_ "k8s.io/kubernetes/pkg/util/prometheusclientgo" // load all the prometheus client-go plugins | ||
_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration | ||
|
||
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugins | ||
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration | ||
|
||
_ "github.com/yunify/qingcloud-cloud-controller-manager/pkg/qingcloud" | ||
) | ||
|
||
func init() { | ||
_ = flag.String("cloud-provider-gce-lb-src-cidrs", "", "flag of bug") | ||
} | ||
func main() { | ||
rand.Seed(time.Now().UnixNano()) | ||
|
||
command := app.NewCloudControllerManagerCommand() | ||
|
||
// TODO: once we switch everything over to Cobra commands, we can go back to calling | ||
// utilflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the | ||
// normalize func and add the go flag set by hand. | ||
|
||
// utilflag.InitFlags() | ||
logs.InitLogs() | ||
defer logs.FlushLogs() | ||
|
||
if err := command.Execute(); err != nil { | ||
_, _ = fmt.Fprintf(os.Stderr, "error: %v\n", err) | ||
os.Exit(1) | ||
} | ||
} |
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,12 @@ | ||
resources: | ||
- ../crd | ||
- ../rbac | ||
- ../manager | ||
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in | ||
# crd/kustomization.yaml | ||
- ../webhook | ||
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required. | ||
- ../certmanager | ||
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. | ||
#- ../prometheus | ||
|
File renamed without changes.
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,3 @@ | ||
resources: | ||
- lbconfig.yaml | ||
- qcsecret.yaml |
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,15 @@ | ||
apiVersion: v1 | ||
data: | ||
qingcloud.yaml: |- | ||
zone: ap2a | ||
defaultVxNetForLB: vxnet-cfn58ev | ||
clusterID: mycluster | ||
instanceIDs: | ||
- i-7iisycou | ||
- i-egd3s6ug | ||
tagIDs: | ||
- tag-3exuweah | ||
kind: ConfigMap | ||
metadata: | ||
name: lbconfig | ||
|
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,11 @@ | ||
apiVersion: v1 | ||
data: | ||
config.yaml: |- | ||
qy_access_key_id: 'xxx' | ||
qy_secret_access_key: 'xxxx' | ||
# your instance zone | ||
zone: "ap2a" | ||
kind: Secret | ||
metadata: | ||
name: qcsecret | ||
type: Opaque |
File renamed without changes.
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,13 @@ | ||
# Adds namespace to all resources. | ||
namespace: kube-system | ||
|
||
# Labels to add to all resources and selectors. | ||
#commonLabels: | ||
# someName: someValue | ||
|
||
resources: | ||
- ../base | ||
|
||
patchesStrategicMerge: | ||
- manager_image_patch.yaml | ||
|
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,12 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: cloud-controller-manager | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
# Change the value of image field below to your controller image URL | ||
- image: kubesphere/cloud-controller-manager:latest | ||
name: qingcloud-cloud-controller-manager | ||
imagePullPolicy: IfNotPresent |
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,16 @@ | ||
# Adds namespace to all resources. | ||
namespace: kube-system | ||
|
||
# Labels to add to all resources and selectors. | ||
#commonLabels: | ||
# someName: someValue | ||
|
||
resources: | ||
- ../base | ||
- ../configmaps | ||
|
||
|
||
patchesStrategicMerge: | ||
- manager_image_patch.yaml | ||
# - nfs_patch.yaml | ||
|
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,15 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: cloud-controller-manager | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
# Change the value of image field below to your controller image URL | ||
- image: kubespheredev/cloud-controller-manager:latest | ||
name: qingcloud-cloud-controller-manager | ||
imagePullPolicy: Always | ||
tty: true | ||
command: | ||
- /bin/sh |
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,17 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: cloud-controller-manager | ||
spec: | ||
template: | ||
spec: | ||
volumes: | ||
- name: nfs-test | ||
nfs: | ||
path: /mnt/sharedfolder/ | ||
server: 172.22.0.2 | ||
containers: | ||
- name: qingcloud-cloud-controller-manager | ||
volumeMounts: | ||
- mountPath: /mnt/ | ||
name: nfs-test |
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,2 @@ | ||
resources: | ||
- manager.yaml |
Oops, something went wrong.