Skip to content

Commit ae9ca2c

Browse files
timoreimannTimo Reimann
authored andcommitted
Support specifying VPC
This change adds a field to DONetwork specifying the VPC UUID and updates the controllers to pass the ID into droplet and load balancer create requests.
1 parent 4fc3ece commit ae9ca2c

File tree

8 files changed

+25
-7
lines changed

8 files changed

+25
-7
lines changed

api/v1alpha3/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ type DONetwork struct {
7777
// Configures an API Server loadbalancers
7878
// +optional
7979
APIServerLoadbalancers DOLoadBalancer `json:"apiServerLoadbalancers,omitempty"`
80+
// VPCUUID defines the VPC UUID to use. An empty value implies using the
81+
// default VPC.
82+
// +optional
83+
VPCUUID string `json:"vpc_uuid,omitempty"`
8084
}
8185

8286
// DOLoadBalancer define the DigitalOcean loadbalancers configurations.

cloud/scope/cluster.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,8 @@ func (s *ClusterScope) APIServerLoadbalancers() *infrav1.DOLoadBalancer {
148148
func (s *ClusterScope) APIServerLoadbalancersRef() *infrav1.DOResourceReference {
149149
return &s.DOCluster.Status.Network.APIServerLoadbalancersRef
150150
}
151+
152+
// VPCUUID get the DOCluster Spec Network VPCUUID.
153+
func (s *ClusterScope) VPCUUID() string {
154+
return s.DOCluster.Spec.Network.VPCUUID
155+
}

cloud/services/computes/droplets.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func (s *Service) CreateDroplet(scope *scope.MachineScope) (*godo.Droplet, error
9292
},
9393
UserData: bootstrapData,
9494
PrivateNetworking: true,
95+
VPCUUID: s.scope.VPCUUID(),
9596
}
9697

9798
request.Tags = infrav1.BuildTags(infrav1.BuildTagParams{

cloud/services/networking/loadbalancers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ func (s *Service) CreateLoadBalancer(spec *infrav1.DOLoadBalancer) (*godo.LoadBa
6363
UnhealthyThreshold: spec.HealthCheck.UnhealthyThreshold,
6464
HealthyThreshold: spec.HealthCheck.HealthyThreshold,
6565
},
66-
Tag: infrav1.ClusterNameRoleTag(clusterName, infrav1.APIServerRoleTagValue),
66+
Tag: infrav1.ClusterNameRoleTag(clusterName, infrav1.APIServerRoleTagValue),
67+
VPCUUID: s.scope.VPCUUID(),
6768
}
6869

6970
lb, _, err := s.scope.LoadBalancers.Create(s.ctx, request)

config/crd/bases/infrastructure.cluster.x-k8s.io_doclusters.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ spec:
256256
minimum: 1
257257
type: integer
258258
type: object
259+
vpc_uuid:
260+
description: VPCUUID defines the VPC UUID to use. An empty value
261+
implies using the default VPC.
262+
type: string
259263
type: object
260264
region:
261265
description: The DigitalOcean Region the cluster lives in. It must

test/e2e/config/digitalocean-ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ providers:
6969

7070
variables:
7171
REDACT_LOG_SCRIPT: "${PWD}/hack/log/redact.sh"
72-
KUBERNETES_VERSION: "v1.18.10"
72+
KUBERNETES_VERSION: "v1.17.11"
7373
EXP_CLUSTER_RESOURCE_SET: "true"
7474
# Cluster Addons
7575
CNI: "${PWD}/test/e2e/data/cni/calico/calico.yaml"
7676
CCM: "${PWD}/test/e2e/data/ccm/digitalocean-cloud-controller-manager.yaml"
7777
# Following CAPDO variables should be set before testing
7878
DO_REGION: "nyc1"
7979
DO_CONTROL_PLANE_MACHINE_TYPE: "s-2vcpu-2gb"
80-
DO_CONTROL_PLANE_MACHINE_IMAGE: "63624555"
80+
DO_CONTROL_PLANE_MACHINE_IMAGE: "74542261"
8181
DO_NODE_MACHINE_TYPE: "s-2vcpu-2gb"
82-
DO_NODE_MACHINE_IMAGE: "63624555"
83-
CONFORMANCE_CI_ARTIFACTS_KUBERNETES_VERSION: "v1.18.10"
82+
DO_NODE_MACHINE_IMAGE: "74542261"
83+
CONFORMANCE_CI_ARTIFACTS_KUBERNETES_VERSION: "v1.17.11"
8484
CONFORMANCE_WORKER_MACHINE_COUNT: "5"
8585
CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1"
8686

test/e2e/config/digitalocean-dev.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ providers:
6969
- sourcePath: "../data/infrastructure-digitalocean/metadata.yaml"
7070

7171
variables:
72+
REDACT_LOG_SCRIPT: "${PWD}/hack/log/redact.sh"
7273
KUBERNETES_VERSION: "v1.17.11"
7374
EXP_CLUSTER_RESOURCE_SET: "true"
7475
# Cluster Addons
@@ -77,9 +78,9 @@ variables:
7778
# Following CAPDO variables should be set before testing
7879
DO_REGION: "nyc1"
7980
DO_CONTROL_PLANE_MACHINE_TYPE: "s-2vcpu-2gb"
80-
# DO_CONTROL_PLANE_MACHINE_IMAGE: ""
81+
DO_CONTROL_PLANE_MACHINE_IMAGE: "74542261"
8182
DO_NODE_MACHINE_TYPE: "s-2vcpu-2gb"
82-
# DO_NODE_MACHINE_IMAGE: ""
83+
DO_NODE_MACHINE_IMAGE: "74542261"
8384
# Also following variables are required but it is recommended to use env variables to avoid disclosure of sensitive data
8485
# DO_SSH_KEY_FINGERPRINT: ""
8586

test/e2e/data/infrastructure-digitalocean/cluster-template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ metadata:
2525
name: "${CLUSTER_NAME}"
2626
spec:
2727
region: ${DO_REGION}
28+
network:
29+
vpc_uuid: 6e54bce7-b371-43fd-9f5f-b564f1f31fc8
2830
---
2931
kind: KubeadmControlPlane
3032
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3

0 commit comments

Comments
 (0)