Skip to content

Commit

Permalink
Merge pull request kubernetes#7221 from srikiz/DO-7148-legacyetcdSupport
Browse files Browse the repository at this point in the history
[Issue-7148] Legacyetcd support for Digital Ocean
  • Loading branch information
k8s-ci-robot committed Jul 19, 2019
2 parents 64ff358 + 6392725 commit 039cee1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
11 changes: 6 additions & 5 deletions docs/tutorial/digitalocean.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export S3_ENDPOINT=nyc3.digitaloceanspaces.com # this can also be ams3.digitaloc
export S3_ACCESS_KEY_ID=<access-key-id> # where <access-key-id> is the Spaces API Access Key for your bucket
export S3_SECRET_ACCESS_KEY=<secret-key> # where <secret-key> is the Spaces API Secret Key for your bucket

# this is required since DigitalOcean support is currently in alpha so it is feature gated
export KOPS_FEATURE_FLAGS="AlphaAllowDO"
# this is required since DigitalOcean support is currently in alpha so it is feature gated, also need Override flag to use legacy etcd.
# we will eventually support etcdmanager, but until then, we need to specify this flag.
export KOPS_FEATURE_FLAGS="AlphaAllowDO,+SpecOverrideFlag"
```

## Creating a Cluster
Expand All @@ -35,15 +36,15 @@ Note that you kops will only be able to successfully provision clusters in regio

```bash
# coreos (the default) + flannel overlay cluster in tor1
kops create cluster --cloud=digitalocean --name=my-cluster.example.com --networking=flannel --zones=tor1 --ssh-public-key=~/.ssh/id_rsa.pub
kops create cluster --cloud=digitalocean --name=my-cluster.example.com --networking=flannel --zones=tor1 --ssh-public-key=~/.ssh/id_rsa.pub --override cluster.spec.etcdClusters[*].provider=Legacy
kops update cluster my-cluster.example.com --yes

# ubuntu + weave overlay cluster in nyc1 using larger droplets
kops create cluster --cloud=digitalocean --name=my-cluster.example.com --image=ubuntu-16-04-x64 --networking=weave --zones=nyc1 --ssh-public-key=~/.ssh/id_rsa.pub --node-size=s-8vcpu-32gb
kops create cluster --cloud=digitalocean --name=my-cluster.example.com --image=ubuntu-16-04-x64 --networking=weave --zones=nyc1 --ssh-public-key=~/.ssh/id_rsa.pub --node-size=s-8vcpu-32gb --override cluster.spec.etcdClusters[*].provider=Legacy
kops update cluster my-cluster.example.com --yes

# debian + flannel overlay cluster in ams3 using optimized droplets
kops create cluster --cloud=digitalocean --name=my-cluster.example.com --image=debian-9-x64 --networking=flannel --zones=ams3 --ssh-public-key=~/.ssh/id_rsa.pub --node-size=c-4
kops create cluster --cloud=digitalocean --name=my-cluster.example.com --image=debian-9-x64 --networking=flannel --zones=ams3 --ssh-public-key=~/.ssh/id_rsa.pub --node-size=c-4 --override cluster.spec.etcdClusters[*].provider=Legacy
kops update cluster my-cluster.example.com --yes

# to delete a cluster
Expand Down
1 change: 1 addition & 0 deletions pkg/model/components/etcdmanager/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ go_library(
"//pkg/urls:go_default_library",
"//upup/pkg/fi:go_default_library",
"//upup/pkg/fi/cloudup/awsup:go_default_library",
"//upup/pkg/fi/cloudup/do:go_default_library",
"//upup/pkg/fi/cloudup/gce:go_default_library",
"//upup/pkg/fi/fitasks:go_default_library",
"//upup/pkg/fi/loader:go_default_library",
Expand Down
11 changes: 11 additions & 0 deletions pkg/model/components/etcdmanager/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"k8s.io/kops/pkg/model"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
"k8s.io/kops/upup/pkg/fi/cloudup/do"
"k8s.io/kops/upup/pkg/fi/cloudup/gce"
"k8s.io/kops/upup/pkg/fi/fitasks"
"k8s.io/kops/util/pkg/exec"
Expand Down Expand Up @@ -380,6 +381,16 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster *kops.EtcdClusterSpec) (*v1.Po
}
config.VolumeNameTag = gce.GceLabelNameEtcdClusterPrefix + etcdCluster.Name

case kops.CloudProviderDO:
config.VolumeProvider = "do"

config.VolumeTag = []string{
fmt.Sprintf("kubernetes.io/cluster/%s=owned", b.Cluster.Name),
do.TagNameEtcdClusterPrefix + etcdCluster.Name,
do.TagNameRolePrefix + "master=1",
}
config.VolumeNameTag = do.TagNameEtcdClusterPrefix + etcdCluster.Name

default:
return nil, fmt.Errorf("CloudProvider %q not supported with etcd-manager", b.Cluster.Spec.CloudProvider)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ spec:
operator: Exists
tolerationSeconds: 300
containers:
- image: digitalocean/digitalocean-cloud-controller-manager:v0.1.7
- image: digitalocean/digitalocean-cloud-controller-manager:v0.1.15
name: digitalocean-cloud-controller-manager
command:
- "/bin/digitalocean-cloud-controller-manager"
- "--cloud-provider=digitalocean"
- "--leader-elect=true"
resources:
requests:
Expand Down
9 changes: 8 additions & 1 deletion upup/pkg/fi/cloudup/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (
// https://en.wikipedia.org/wiki/Reserved_IP_addresses
PlaceholderIP = "203.0.113.123"
PlaceholderTTL = 10
// DigitalOcean's DNS servers require a certain minimum TTL (it's 30), keeping 60 here.
PlaceholderTTLDigitialOcean = 60
)

func findZone(cluster *kops.Cluster, cloud fi.Cloud) (dnsprovider.Zone, error) {
Expand Down Expand Up @@ -228,7 +230,12 @@ func precreateDNS(cluster *kops.Cluster, cloud fi.Cloud) error {

klog.V(2).Infof("Pre-creating DNS record %s => %s", dnsHostname, PlaceholderIP)

changeset.Add(rrs.New(dnsHostname, []string{PlaceholderIP}, PlaceholderTTL, rrstype.A))
if cloud.ProviderID() == kops.CloudProviderDO {
changeset.Add(rrs.New(dnsHostname, []string{PlaceholderIP}, PlaceholderTTLDigitialOcean, rrstype.A))
} else {
changeset.Add(rrs.New(dnsHostname, []string{PlaceholderIP}, PlaceholderTTL, rrstype.A))
}

created = append(created, dnsHostname)
}

Expand Down
3 changes: 3 additions & 0 deletions upup/pkg/fi/cloudup/do/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
"k8s.io/kops/upup/pkg/fi"
)

const TagNameEtcdClusterPrefix = "k8s.io/etcd/"
const TagNameRolePrefix = "k8s.io/role/"

func NewDOCloud(region string) (fi.Cloud, error) {
return digitalocean.NewCloud(region)
}

0 comments on commit 039cee1

Please sign in to comment.