Skip to content

Support specifying VPC #225

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

Merged
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: 11 additions & 0 deletions api/v1alpha3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type DONetwork struct {
// Configures an API Server loadbalancers
// +optional
APIServerLoadbalancers DOLoadBalancer `json:"apiServerLoadbalancers,omitempty"`
// VPC defines the VPC configuration.
// +optional
VPC DOVPC `json:"vpc,omitempty"`
}

// DOLoadBalancer define the DigitalOcean loadbalancers configurations.
Expand All @@ -121,6 +124,14 @@ type DOLoadBalancer struct {
HealthCheck DOLoadBalancerHealthCheck `json:"healthCheck,omitempty"`
}

// DOVPC define the DigitalOcean VPC configuration.
type DOVPC struct {
// VPCUUID defines the VPC UUID to use. An empty value implies using the
// default VPC.
// +optional
VPCUUID string `json:"vpc_uuid,omitempty"`
}

var (
DefaultLBPort = 6443
DefaultLBAlgorithm = "round_robin"
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,8 @@ func (s *ClusterScope) APIServerLoadbalancers() *infrav1.DOLoadBalancer {
func (s *ClusterScope) APIServerLoadbalancersRef() *infrav1.DOResourceReference {
return &s.DOCluster.Status.Network.APIServerLoadbalancersRef
}

// VPC gets the DOCluster Spec Network VPC.
func (s *ClusterScope) VPC() *infrav1.DOVPC {
return &s.DOCluster.Spec.Network.VPC
}
1 change: 1 addition & 0 deletions cloud/services/computes/droplets.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (s *Service) CreateDroplet(scope *scope.MachineScope) (*godo.Droplet, error
UserData: bootstrapData,
PrivateNetworking: true,
Volumes: volumes,
VPCUUID: s.scope.VPC().VPCUUID,
}

request.Tags = infrav1.BuildTags(infrav1.BuildTagParams{
Expand Down
3 changes: 2 additions & 1 deletion cloud/services/networking/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func (s *Service) CreateLoadBalancer(spec *infrav1.DOLoadBalancer) (*godo.LoadBa
UnhealthyThreshold: spec.HealthCheck.UnhealthyThreshold,
HealthyThreshold: spec.HealthCheck.HealthyThreshold,
},
Tag: infrav1.ClusterNameRoleTag(clusterName, infrav1.APIServerRoleTagValue),
Tag: infrav1.ClusterNameRoleTag(clusterName, infrav1.APIServerRoleTagValue),
VPCUUID: s.scope.VPC().VPCUUID,
}

lb, _, err := s.scope.LoadBalancers.Create(s.ctx, request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ spec:
minimum: 1
type: integer
type: object
vpc:
description: VPC defines the VPC configuration.
properties:
vpc_uuid:
description: VPCUUID defines the VPC UUID to use. An empty
value implies using the default VPC.
type: string
type: object
type: object
region:
description: The DigitalOcean Region the cluster lives in. It must
Expand Down