initial commit
This commit is contained in:
commit
9c7f7894b9
23 changed files with 1656 additions and 0 deletions
122
pvecloud/cloud.go
Normal file
122
pvecloud/cloud.go
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package pvecloud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
pve "git.giftfish.de/ston1th/pve-go"
|
||||
cloudprovider "k8s.io/cloud-provider"
|
||||
)
|
||||
|
||||
const (
|
||||
providerName = pve.PVEScheme
|
||||
scheme = providerName + "://"
|
||||
)
|
||||
|
||||
type cloud struct {
|
||||
client *pve.Client
|
||||
instances cloudprovider.Instances
|
||||
//zones cloudprovider.Zones
|
||||
//routes cloudprovider.Routes
|
||||
//network string
|
||||
}
|
||||
|
||||
func newCloud(_ io.Reader) (cloudprovider.Interface, error) {
|
||||
api := os.Getenv("PVE_API")
|
||||
if api == "" {
|
||||
return nil, fmt.Errorf("missing required env PVE_API")
|
||||
}
|
||||
user := os.Getenv("PVE_USER")
|
||||
if user == "" {
|
||||
return nil, fmt.Errorf("missing required env PVE_USER")
|
||||
}
|
||||
pass := os.Getenv("PVE_PASSWORD")
|
||||
if pass == "" {
|
||||
return nil, fmt.Errorf("missing required env PVE_PASSWORD")
|
||||
}
|
||||
//node := os.Getenv("NODE_NAME")
|
||||
|
||||
insecure, _ := strconv.ParseBool(os.Getenv("PVE_INSECURE"))
|
||||
client := pve.NewClient(
|
||||
pve.WithEndpoint(api),
|
||||
pve.WithCredentials(user, pass),
|
||||
pve.WithInsecureClient(insecure),
|
||||
//pvego.WithDebugWriter(os.Stderr),
|
||||
)
|
||||
|
||||
return &cloud{
|
||||
client: client,
|
||||
instances: newInstances(client),
|
||||
//zones: newZones(client, nodeName),
|
||||
//routes: nil,
|
||||
//network: network,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) {
|
||||
}
|
||||
|
||||
func (c *cloud) Instances() (cloudprovider.Instances, bool) {
|
||||
return c.instances, true
|
||||
}
|
||||
|
||||
func (c *cloud) Zones() (cloudprovider.Zones, bool) {
|
||||
//return c.zones, true
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (c *cloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (c *cloud) Clusters() (cloudprovider.Clusters, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (c *cloud) Routes() (cloudprovider.Routes, bool) {
|
||||
return nil, false
|
||||
/*
|
||||
if len(c.network) > 0 {
|
||||
r, err := newRoutes(c.client, c.network)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
return r, true
|
||||
}
|
||||
return nil, false // If no network is configured, disable the routes part
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
func (c *cloud) ProviderName() string {
|
||||
return providerName
|
||||
}
|
||||
|
||||
func (c *cloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []string) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *cloud) HasClusterID() bool {
|
||||
// TODO set to true
|
||||
return false
|
||||
}
|
||||
|
||||
func init() {
|
||||
cloudprovider.RegisterCloudProvider(providerName, func(config io.Reader) (cloudprovider.Interface, error) {
|
||||
return newCloud(config)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue