Skip to content

Commit

Permalink
Update go.mod and image version to v1.4.8 (#118)
Browse files Browse the repository at this point in the history
Signed-off-by: jacksontong <[email protected]>

Co-authored-by: jacksontong <[email protected]>
  • Loading branch information
cumirror and jacksontong authored Aug 23, 2021
1 parent 4d5409f commit eb4e273
Show file tree
Hide file tree
Showing 8 changed files with 469 additions and 556 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# GitHub viewer defaults to 8, change with ?ts=4 in URL

GIT_REPOSITORY= github.com/yunify/qingcloud-cloud-controller-manager
IMG?= kubespheredev/cloud-controller-manager:latest
IMG?= qingcloud/cloud-controller-manager:latest
#Debug level: 0, 1, 2 (1 true, 2 use bash)
DEBUG?= 0
DOCKERFILE?= deploy/Dockerfile
Expand Down
52 changes: 45 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016 The Kubernetes Authors.
Copyright 2020 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.
Expand All @@ -14,8 +14,9 @@ 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.
// This file should be written by each cloud provider.
// For an minimal working example, please refer to k8s.io/cloud-provider/sample/basic_main.go
// For more details, please refer to k8s.io/kubernetes/cmd/cloud-controller-manager/main.go

package main

Expand All @@ -24,23 +25,38 @@ import (
"os"
"time"

"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/cloud-provider"
"k8s.io/cloud-provider/app"
"k8s.io/cloud-provider/app/config"
"k8s.io/cloud-provider/options"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
"k8s.io/kubernetes/cmd/cloud-controller-manager/app"

_ "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

"k8s.io/klog/v2"
// For existing cloud providers, the option to import legacy providers is still available.
// e.g. _"k8s.io/legacy-cloud-providers/<provider>"
_ "github.com/yunify/qingcloud-cloud-controller-manager/pkg/qingcloud"
)

func main() {
rand.Seed(time.Now().UnixNano())

command := app.NewCloudControllerManagerCommand()
ccmOptions, err := options.NewCloudControllerManagerOptions()
if err != nil {
klog.Fatalf("unable to initialize command options: %v", err)
}

fss := cliflag.NamedFlagSets{}
command := app.NewCloudControllerManagerCommand(ccmOptions, cloudInitializer, app.DefaultInitFuncConstructors, fss, wait.NeverStop)

// 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.
// Here is an sample
pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
// utilflag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
Expand All @@ -49,3 +65,25 @@ func main() {
os.Exit(1)
}
}

func cloudInitializer(config *config.CompletedConfig) cloudprovider.Interface {
cloudConfig := config.ComponentConfig.KubeCloudShared.CloudProvider

// initialize cloud provider with the cloud provider name and config file provided
cloud, err := cloudprovider.InitCloudProvider(cloudConfig.Name, cloudConfig.CloudConfigFile)
if err != nil {
klog.Fatalf("Cloud provider could not be initialized: %v", err)
}
if cloud == nil {
klog.Fatalf("Cloud provider is nil")
}

if !cloud.HasClusterID() {
if config.ComponentConfig.KubeCloudShared.AllowUntaggedCloud {
klog.Warning("detected a cluster without a ClusterID. A ClusterID will be required in the future. Please tag your cluster to avoid any future issues")
} else {
klog.Fatalf("no ClusterID found. A ClusterID is required for the cloud provider to function properly. This check can be bypassed by setting the allow-untagged-cloud option")
}
}
return cloud
}
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ spec:
spec:
containers:
# Change the value of image field below to your controller image URL
- image: kubesphere/cloud-controller-manager:v1.4.7
- image: qingcloud/cloud-controller-manager:v1.4.8
name: qingcloud-cloud-controller-manager
imagePullPolicy: IfNotPresent
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml-e
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ spec:
spec:
containers:
# Change the value of image field below to your controller image URL
- image: kubesphere/cloud-controller-manager:v1.4.6
- image: kubesphere/cloud-controller-manager:v1.4.7
name: qingcloud-cloud-controller-manager
imagePullPolicy: IfNotPresent
2 changes: 1 addition & 1 deletion deploy/kube-cloud-controller-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ spec:
- -v=3
- --cloud-provider=qingcloud
- --cloud-config=/etc/kubernetes/qingcloud.yaml
image: kubesphere/cloud-controller-manager:v1.4.7
image: qingcloud/cloud-controller-manager:v1.4.8
imagePullPolicy: IfNotPresent
name: qingcloud-cloud-controller-manager
resources:
Expand Down
66 changes: 33 additions & 33 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
module github.com/yunify/qingcloud-cloud-controller-manager

go 1.13
go 1.16

require (
github.com/davecgh/go-spew v1.1.1
github.com/sirupsen/logrus v1.6.0 // indirect
github.com/stretchr/testify v1.6.1 // indirect
github.com/spf13/pflag v1.0.5
github.com/yunify/qingcloud-sdk-go v2.0.0-alpha.38+incompatible
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.18.8
k8s.io/apimachinery v0.18.8
k8s.io/client-go v0.18.8
k8s.io/cloud-provider v0.18.8
k8s.io/component-base v0.18.8
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/client-go v0.21.1
k8s.io/cloud-provider v0.21.1
k8s.io/component-base v0.21.1
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.18.8
k8s.io/klog/v2 v2.9.0
)

replace (
k8s.io/api => k8s.io/api v0.18.8
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.8
k8s.io/apimachinery => k8s.io/apimachinery v0.18.9-rc.0
k8s.io/apiserver => k8s.io/apiserver v0.18.8
k8s.io/cli-runtime => k8s.io/cli-runtime v0.18.8
k8s.io/client-go => k8s.io/client-go v0.18.8
k8s.io/cloud-provider => k8s.io/cloud-provider v0.18.8
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.18.8
k8s.io/code-generator => k8s.io/code-generator v0.18.9-rc.0
k8s.io/component-base => k8s.io/component-base v0.18.8
k8s.io/cri-api => k8s.io/cri-api v0.18.9-rc.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.18.8
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.18.8
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.18.8
k8s.io/kube-proxy => k8s.io/kube-proxy v0.18.8
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.18.8
k8s.io/kubectl => k8s.io/kubectl v0.18.8
k8s.io/kubelet => k8s.io/kubelet v0.18.8
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.18.8
k8s.io/metrics => k8s.io/metrics v0.18.8
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.18.8
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.18.8
k8s.io/sample-controller => k8s.io/sample-controller v0.18.8
k8s.io/api => k8s.io/api v0.21.1
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.21.1
k8s.io/apimachinery => k8s.io/apimachinery v0.21.1
k8s.io/apiserver => k8s.io/apiserver v0.21.1
k8s.io/cli-runtime => k8s.io/cli-runtime v0.21.1
k8s.io/client-go => k8s.io/client-go v0.21.1
k8s.io/cloud-provider => k8s.io/cloud-provider v0.21.1
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.21.1
k8s.io/code-generator => k8s.io/code-generator v0.21.1
k8s.io/component-base => k8s.io/component-base v0.21.1
k8s.io/component-helpers => k8s.io/component-helpers v0.21.1
k8s.io/controller-manager => k8s.io/controller-manager v0.21.1
k8s.io/cri-api => k8s.io/cri-api v0.21.1
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.21.1
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.21.1
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.21.1
k8s.io/kube-proxy => k8s.io/kube-proxy v0.21.1
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.21.1
k8s.io/kubectl => k8s.io/kubectl v0.21.1
k8s.io/kubelet => k8s.io/kubelet v0.21.1
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.21.1
k8s.io/metrics => k8s.io/metrics v0.21.1
k8s.io/mount-utils => k8s.io/mount-utils v0.21.1
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.21.1
)
Loading

0 comments on commit eb4e273

Please sign in to comment.