2019-10-15 21:17:26 +00:00
|
|
|
package cloudprovider
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2022-03-02 23:47:27 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/version"
|
2021-01-23 00:59:48 +00:00
|
|
|
"k8s.io/client-go/informers"
|
|
|
|
informercorev1 "k8s.io/client-go/informers/core/v1"
|
|
|
|
"k8s.io/client-go/tools/cache"
|
2019-10-15 21:17:26 +00:00
|
|
|
cloudprovider "k8s.io/cloud-provider"
|
|
|
|
)
|
|
|
|
|
|
|
|
type k3s struct {
|
2021-01-23 00:59:48 +00:00
|
|
|
nodeInformer informercorev1.NodeInformer
|
|
|
|
nodeInformerHasSynced cache.InformerSynced
|
2019-10-15 21:17:26 +00:00
|
|
|
}
|
|
|
|
|
2021-01-23 00:59:48 +00:00
|
|
|
var _ cloudprovider.Interface = &k3s{}
|
|
|
|
var _ cloudprovider.InformerUser = &k3s{}
|
|
|
|
|
2019-10-15 21:17:26 +00:00
|
|
|
func init() {
|
2020-05-05 22:09:04 +00:00
|
|
|
cloudprovider.RegisterCloudProvider(version.Program, func(config io.Reader) (cloudprovider.Interface, error) {
|
2019-10-15 21:17:26 +00:00
|
|
|
return &k3s{}, nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (k *k3s) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) {
|
2021-01-23 00:59:48 +00:00
|
|
|
}
|
2019-10-15 21:17:26 +00:00
|
|
|
|
2021-01-23 00:59:48 +00:00
|
|
|
func (k *k3s) SetInformers(informerFactory informers.SharedInformerFactory) {
|
|
|
|
k.nodeInformer = informerFactory.Core().V1().Nodes()
|
|
|
|
k.nodeInformerHasSynced = k.nodeInformer.Informer().HasSynced
|
2019-10-15 21:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (k *k3s) Instances() (cloudprovider.Instances, bool) {
|
|
|
|
return k, true
|
|
|
|
}
|
|
|
|
|
2020-08-05 16:26:36 +00:00
|
|
|
func (k *k3s) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
|
|
|
return nil, false
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:17:26 +00:00
|
|
|
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 {
|
2020-05-05 22:09:04 +00:00
|
|
|
return version.Program
|
2019-10-15 21:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (k *k3s) HasClusterID() bool {
|
2020-11-03 19:07:32 +00:00
|
|
|
return true
|
2019-10-15 21:17:26 +00:00
|
|
|
}
|