updated to latest k8s version
This commit is contained in:
parent
974555da9e
commit
bbbd20b5f2
12 changed files with 668 additions and 525 deletions
|
|
@ -1,19 +1,3 @@
|
|||
/*
|
||||
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 (
|
||||
|
|
@ -21,22 +5,66 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
_ "git.giftfish.de/ston1th/cloud-controller-manager-pve/pkg/pvecloud"
|
||||
"git.giftfish.de/ston1th/cloud-controller-manager-pve/pkg/pvecloud"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
cloudprovider "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/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
|
||||
//_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
command := app.NewCloudControllerManagerCommand()
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
logs.InitLogs()
|
||||
defer logs.FlushLogs()
|
||||
|
||||
opts, err := options.NewCloudControllerManagerOptions()
|
||||
if err != nil {
|
||||
klog.Fatalf("unable to initialize command options: %v", err)
|
||||
}
|
||||
|
||||
controllerInitializers := app.DefaultInitFuncConstructors
|
||||
fss := cliflag.NamedFlagSets{}
|
||||
command := app.NewCloudControllerManagerCommand(opts, cloudInitializer, controllerInitializers, fss, wait.NeverStop)
|
||||
|
||||
if err := command.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func cloudInitializer(config *config.CompletedConfig) cloudprovider.Interface {
|
||||
cloudConfig := config.ComponentConfig.KubeCloudShared.CloudProvider
|
||||
providerName := cloudConfig.Name
|
||||
|
||||
if providerName == "" {
|
||||
providerName = pvecloud.ProviderName
|
||||
}
|
||||
|
||||
if providerName != pvecloud.ProviderName {
|
||||
klog.Fatalf("unknown cloud provider %s, only 'pvecloud' is supported", providerName)
|
||||
}
|
||||
|
||||
// initialize cloud provider with the cloud provider name and config file provided
|
||||
cloud, err := cloudprovider.InitCloudProvider(providerName, 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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ import (
|
|||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
typedcertificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
|
||||
"k8s.io/klog/klogr"
|
||||
typedcertificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/klog/v2/klogr"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller"
|
||||
"sigs.k8s.io/controller-runtime/pkg/healthz"
|
||||
|
|
@ -123,7 +123,7 @@ func main() {
|
|||
Log: ctrl.Log.WithName("approver"),
|
||||
Scheme: mgr.GetScheme(),
|
||||
PVEClient: pveClient,
|
||||
CSRClient: typedcertificatesv1beta1.NewForConfigOrDie(rcfg),
|
||||
CSRClient: typedcertificatesv1.NewForConfigOrDie(rcfg),
|
||||
}).SetupWithManager(mgr, controller.Options{MaxConcurrentReconciles: csrConcurrency}); err != nil {
|
||||
setupLog.Error(err, "unable to create controller", "controller", "approver")
|
||||
os.Exit(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue