mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
31575e407a
Resolves warning 2 from #2471. As per https://github.com/kubernetes/cloud-provider/issues/12 the ClusterID requirement was never really followed through on, so the flag is probably going to be removed in the future. One side-effect of this is that the core k8s cloud-controller-manager also wants to watch nodes, and needs RBAC to do so. Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
package cloudprovider
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/rancher/k3s/pkg/version"
|
|
"github.com/rancher/wrangler-api/pkg/generated/controllers/core"
|
|
coreclient "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
|
|
"github.com/rancher/wrangler/pkg/start"
|
|
cloudprovider "k8s.io/cloud-provider"
|
|
)
|
|
|
|
type k3s struct {
|
|
NodeCache coreclient.NodeCache
|
|
}
|
|
|
|
func init() {
|
|
cloudprovider.RegisterCloudProvider(version.Program, func(config io.Reader) (cloudprovider.Interface, error) {
|
|
return &k3s{}, nil
|
|
})
|
|
}
|
|
|
|
func (k *k3s) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) {
|
|
coreFactory := core.NewFactoryFromConfigOrDie(clientBuilder.ConfigOrDie("cloud-controller-manager"))
|
|
|
|
go start.All(context.Background(), 1, coreFactory)
|
|
|
|
k.NodeCache = coreFactory.Core().V1().Node().Cache()
|
|
}
|
|
|
|
func (k *k3s) Instances() (cloudprovider.Instances, bool) {
|
|
return k, true
|
|
}
|
|
|
|
func (k *k3s) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
func (k *k3s) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
func (k *k3s) Zones() (cloudprovider.Zones, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
func (k *k3s) Clusters() (cloudprovider.Clusters, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
func (k *k3s) Routes() (cloudprovider.Routes, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
func (k *k3s) ProviderName() string {
|
|
return version.Program
|
|
}
|
|
|
|
func (k *k3s) HasClusterID() bool {
|
|
return true
|
|
}
|