diff --git a/hack/.packages b/hack/.packages index 8d32ebde96..01c1a738f7 100644 --- a/hack/.packages +++ b/hack/.packages @@ -103,6 +103,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 diff --git a/upup/pkg/fi/cloudup/baremetal/cloud.go b/upup/pkg/fi/cloudup/baremetal/cloud.go new file mode 100644 index 0000000000..5d55ea7b91 --- /dev/null +++ b/upup/pkg/fi/cloudup/baremetal/cloud.go @@ -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") +} diff --git a/upup/pkg/fi/cloudup/baremetal/target.go b/upup/pkg/fi/cloudup/baremetal/target.go new file mode 100644 index 0000000000..a270480fa6 --- /dev/null +++ b/upup/pkg/fi/cloudup/baremetal/target.go @@ -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 +} diff --git a/upup/pkg/fi/cloudup/utils.go b/upup/pkg/fi/cloudup/utils.go index d0705d1562..1088220989 100644 --- a/upup/pkg/fi/cloudup/utils.go +++ b/upup/pkg/fi/cloudup/utils.go @@ -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" @@ -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) }