Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue-7148] Legacyetcd support for Digital Ocean #7221

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -40,6 +40,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"
srikiz marked this conversation as resolved.
Show resolved Hide resolved
- "--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)
}