From 63927250babf075b12d830e11893138d608317b2 Mon Sep 17 00:00:00 2001 From: Srikanth Date: Sat, 15 Jun 2019 15:56:22 -0500 Subject: [PATCH] Initial changes to add DO models for etcd-manager update template Update notes for digital ocean Update TTL to 60 seconds and version upgrade to 0.1.15 for DO Cloud Controller Manager Update review comments Format go code --- docs/tutorial/digitalocean.md | 11 ++++++----- pkg/model/components/etcdmanager/BUILD.bazel | 1 + pkg/model/components/etcdmanager/model.go | 11 +++++++++++ .../k8s-1.8.yaml.template | 3 +-- upup/pkg/fi/cloudup/dns.go | 9 ++++++++- upup/pkg/fi/cloudup/do/cloud.go | 3 +++ 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/tutorial/digitalocean.md b/docs/tutorial/digitalocean.md index 52f644749d..645ec3b382 100644 --- a/docs/tutorial/digitalocean.md +++ b/docs/tutorial/digitalocean.md @@ -24,8 +24,9 @@ export S3_ENDPOINT=nyc3.digitaloceanspaces.com # this can also be ams3.digitaloc export S3_ACCESS_KEY_ID= # where is the Spaces API Access Key for your bucket export S3_SECRET_ACCESS_KEY= # where 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 @@ -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 diff --git a/pkg/model/components/etcdmanager/BUILD.bazel b/pkg/model/components/etcdmanager/BUILD.bazel index 6dfc9e72b8..7eff6f2b07 100644 --- a/pkg/model/components/etcdmanager/BUILD.bazel +++ b/pkg/model/components/etcdmanager/BUILD.bazel @@ -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", diff --git a/pkg/model/components/etcdmanager/model.go b/pkg/model/components/etcdmanager/model.go index 61274989a0..608dafd4b5 100644 --- a/pkg/model/components/etcdmanager/model.go +++ b/pkg/model/components/etcdmanager/model.go @@ -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" @@ -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) } diff --git a/upup/models/cloudup/resources/addons/digitalocean-cloud-controller.addons.k8s.io/k8s-1.8.yaml.template b/upup/models/cloudup/resources/addons/digitalocean-cloud-controller.addons.k8s.io/k8s-1.8.yaml.template index 4f17e98b93..bbb7f72195 100644 --- a/upup/models/cloudup/resources/addons/digitalocean-cloud-controller.addons.k8s.io/k8s-1.8.yaml.template +++ b/upup/models/cloudup/resources/addons/digitalocean-cloud-controller.addons.k8s.io/k8s-1.8.yaml.template @@ -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: diff --git a/upup/pkg/fi/cloudup/dns.go b/upup/pkg/fi/cloudup/dns.go index 20186985d7..961fa63b55 100644 --- a/upup/pkg/fi/cloudup/dns.go +++ b/upup/pkg/fi/cloudup/dns.go @@ -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) { @@ -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) } diff --git a/upup/pkg/fi/cloudup/do/cloud.go b/upup/pkg/fi/cloudup/do/cloud.go index ad1f2e2d20..c86f945781 100644 --- a/upup/pkg/fi/cloudup/do/cloud.go +++ b/upup/pkg/fi/cloudup/do/cloud.go @@ -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) }