Skip to content

Commit

Permalink
Skeleton bare-metal provider
Browse files Browse the repository at this point in the history
Just creating the provider, it isn't wired in yet.
  • Loading branch information
justinsb committed Aug 28, 2017
1 parent 327235a commit 3d65361
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions hack/.packages
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ k8s.io/kops/upup/pkg/fi/assettasks
k8s.io/kops/upup/pkg/fi/cloudup
k8s.io/kops/upup/pkg/fi/cloudup/awstasks
k8s.io/kops/upup/pkg/fi/cloudup/awsup
k8s.io/kops/upup/pkg/fi/cloudup/baremetal
k8s.io/kops/upup/pkg/fi/cloudup/cloudformation
k8s.io/kops/upup/pkg/fi/cloudup/dnstasks
k8s.io/kops/upup/pkg/fi/cloudup/do
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/kops/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func FindKopsVersionSpec(versions []KopsVersionSpec, version semver.Version) *Ko

type CloudProviderID string

const CloudProviderBareMetal CloudProviderID = "baremetal"
const CloudProviderAWS CloudProviderID = "aws"
const CloudProviderGCE CloudProviderID = "gce"
const CloudProviderDO CloudProviderID = "digitalocean"
Expand Down
46 changes: 46 additions & 0 deletions upup/pkg/fi/cloudup/baremetal/cloud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
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.
*/

package baremetal

import (
"fmt"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kubernetes/federation/pkg/dnsprovider"
)

type Cloud struct {
dns dnsprovider.Interface
}

var _ fi.Cloud = &Cloud{}

func NewCloud(dns dnsprovider.Interface) (*Cloud, error) {
return &Cloud{dns: dns}, nil
}

func (c *Cloud) ProviderID() kops.CloudProviderID {
return kops.CloudProviderBareMetal
}

func (c *Cloud) DNS() (dnsprovider.Interface, error) {
return c.dns, nil
}

func (c *Cloud) FindVPCInfo(id string) (*fi.VPCInfo, error) {
return nil, fmt.Errorf("baremetal FindVPCInfo not supported")
}
39 changes: 39 additions & 0 deletions upup/pkg/fi/cloudup/baremetal/target.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
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.
*/

package baremetal

import (
"k8s.io/kops/upup/pkg/fi"
)

type Target struct {
cloud *Cloud
}

var _ fi.Target = &Target{}

func NewTarget(cloud *Cloud) *Target {
return &Target{cloud: cloud}
}

func (t *Target) Finish(taskMap map[string]fi.Task) error {
return nil
}

func (t *Target) ProcessDeletions() bool {
return true
}
16 changes: 16 additions & 0 deletions upup/pkg/fi/cloudup/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
"k8s.io/kops/upup/pkg/fi/cloudup/baremetal"
"k8s.io/kops/upup/pkg/fi/cloudup/do"
"k8s.io/kops/upup/pkg/fi/cloudup/gce"
"k8s.io/kops/upup/pkg/fi/cloudup/vsphere"
Expand Down Expand Up @@ -121,6 +122,21 @@ func BuildCloud(cluster *kops.Cluster) (fi.Cloud, error) {
cloud = doCloud
}

case string(kops.CloudProviderBareMetal):
{
// TODO: Allow dns provider to be specified
dns, err := dnsprovider.GetDnsProvider(route53.ProviderName, nil)
if err != nil {
return nil, fmt.Errorf("Error building (k8s) DNS provider: %v", err)
}

baremetalCloud, err := baremetal.NewCloud(dns)
if err != nil {
return nil, err
}
cloud = baremetalCloud
}

default:
return nil, fmt.Errorf("unknown CloudProvider %q", cluster.Spec.CloudProvider)
}
Expand Down

0 comments on commit 3d65361

Please sign in to comment.