Merge pull request #7221 from srikiz/DO-7148-legacyetcdSupport

[Issue-7148] Legacyetcd support for Digital Ocean
This commit is contained in:
Kubernetes Prow Robot 2019-07-19 09:55:15 -07:00 committed by GitHub
commit 039cee170f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 8 deletions

View File

@ -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
@ -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

View File

@ -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",

View File

@ -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"
@ -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)
}

View File

@ -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:

View File

@ -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)
}

View File

@ -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)
}