mirror of https://github.com/kubernetes/kops.git
More updates to protokube seeding DO cloud provider
This commit is contained in:
parent
cb4a8ef6fc
commit
c52d4d9dbd
|
|
@ -47,6 +47,7 @@ func (d *DropletBuilder) Build(c *fi.ModelBuilderContext) error {
|
|||
|
||||
// replace "." with "-" since DO API does not accept "."
|
||||
clusterTag := do.TagKubernetesClusterNamePrefix + ":" + strings.Replace(d.ClusterName(), ".", "-", -1)
|
||||
clusterMasterTag := do.TagKubernetesClusterMasterPrefix + ":" + strings.Replace(d.ClusterName(), ".", "-", -1)
|
||||
|
||||
masterIndexCount := 0
|
||||
// In the future, DigitalOcean will use Machine API to manage groups,
|
||||
|
|
@ -71,6 +72,7 @@ func (d *DropletBuilder) Build(c *fi.ModelBuilderContext) error {
|
|||
masterIndexCount++
|
||||
clusterTagIndex := do.TagKubernetesClusterIndex + ":" + strconv.Itoa(masterIndexCount)
|
||||
droplet.Tags = append(droplet.Tags, clusterTagIndex)
|
||||
droplet.Tags = append(droplet.Tags, clusterMasterTag)
|
||||
}
|
||||
|
||||
userData, err := d.BootstrapScript.ResourceNodeUp(ig, d.Cluster)
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ package do
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
//"errors"
|
||||
"context"
|
||||
"strings"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kops/pkg/resources/digitalocean"
|
||||
"k8s.io/kops/protokube/pkg/gossip"
|
||||
//"github.com/digitalocean/godo"
|
||||
)
|
||||
|
||||
type SeedProvider struct {
|
||||
|
|
@ -46,20 +48,41 @@ func (p *SeedProvider) GetSeeds() ([]string, error) {
|
|||
for _, dropTag := range droplet.Tags {
|
||||
klog.V(2).Infof("Get Seeds - droplet found=%s,SeedProvider Tag=%s", dropTag, p.tag)
|
||||
if strings.Contains(dropTag, strings.Replace(p.tag, ".", "-", -1)) {
|
||||
klog.V(2).Infof("Tag matched for droplet tag =%s. Getting private IP", p.tag)
|
||||
ip, err := droplet.PrivateIPv4()
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
klog.V(2).Infof("Appending a seed for cluster tag:%s, with ip=%s", p.tag, ip)
|
||||
seeds = append(seeds, ip)
|
||||
} else {
|
||||
klog.V(2).Infof("Ah ...Private IP failed for tag=%s, error=%v", p.tag, err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
klog.V(2).Infof("Tag NOT matched for droplet tag =%s. and pTag=%s", dropTag, p.tag)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
klog.V(2).Infof("Get seeds function done")
|
||||
klog.V(2).Infof("Get seeds function done now")
|
||||
return seeds, nil
|
||||
}
|
||||
|
||||
// func GetPrivateIP(d *godo.Droplet) (string, error) {
|
||||
// klog.V(2).Infof("Get PrivateIP: droplet name =%s", d.Name)
|
||||
// if d.Networks == nil {
|
||||
// return "", errors.New("no networks have been defined")
|
||||
// }
|
||||
|
||||
// for _, v4 := range d.Networks.V4 {
|
||||
// klog.V(2).Infof("Get PrivateIP: droplet name =%s, v4 type=%s, Ip address=%s", d.Name, v4.Type, v4.IPAddress)
|
||||
// if v4.Type == "private" {
|
||||
// return v4.IPAddress, nil
|
||||
// }
|
||||
// }
|
||||
|
||||
// return "", errors.New("Could not find v4 network")
|
||||
// }
|
||||
|
||||
|
||||
func NewSeedProvider(cloud *digitalocean.Cloud, tag string) (*SeedProvider, error) {
|
||||
klog.V(2).Infof("Trying new seed provider with cluster tag:%s", tag)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ const TagKubernetesClusterIndex = "k8s-index"
|
|||
const TagNameEtcdClusterPrefix = "etcdCluster-"
|
||||
const TagNameRolePrefix = "k8s.io/role/"
|
||||
const TagKubernetesClusterNamePrefix = "KubernetesCluster"
|
||||
const TagKubernetesClusterMasterPrefix = "KubernetesCluster-Master"
|
||||
|
||||
func SafeClusterName(clusterName string) string {
|
||||
// DO does not support . in tags / names
|
||||
|
|
|
|||
Loading…
Reference in New Issue