Skip to content

Commit b674f78

Browse files
committed
Re-enable additionalSecurityGroups for bastion LB
1 parent 3630433 commit b674f78

File tree

11 files changed

+36
-8
lines changed

11 files changed

+36
-8
lines changed

k8s/crds/kops.k8s.io_clusters.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6386,7 +6386,6 @@ spec:
63866386
loadBalancer:
63876387
properties:
63886388
additionalSecurityGroups:
6389-
description: AdditionalSecurityGroups is unused
63906389
items:
63916390
type: string
63926391
type: array

pkg/apis/kops/bastion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type BastionSpec struct {
2424
}
2525

2626
type BastionLoadBalancerSpec struct {
27+
AdditionalSecurityGroups []string `json:"additionalSecurityGroups,omitempty"`
2728
// Type of load balancer to create, it can be Public or Internal.
2829
Type LoadBalancerType `json:"type,omitempty"`
2930
}

pkg/apis/kops/v1alpha2/bastion.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ type BastionSpec struct {
2525
}
2626

2727
type BastionLoadBalancerSpec struct {
28-
// AdditionalSecurityGroups is unused
29-
// +k8s:conversion-gen=false
3028
AdditionalSecurityGroups []string `json:"additionalSecurityGroups,omitempty"`
3129
// Type of load balancer to create, it can be Public or Internal.
3230
Type LoadBalancerType `json:"type,omitempty"`

pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/bastion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type BastionSpec struct {
2424
}
2525

2626
type BastionLoadBalancerSpec struct {
27+
AdditionalSecurityGroups []string `json:"additionalSecurityGroups,omitempty"`
2728
// Type of load balancer to create, it can be Public or Internal.
2829
Type LoadBalancerType `json:"type,omitempty"`
2930
}

pkg/apis/kops/v1alpha3/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/model/awsmodel/bastion.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,20 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error {
393393

394394
c.AddTask(tg)
395395

396+
// Add additional security groups to the NLB
397+
if b.Cluster.Spec.Networking.Topology != nil && b.Cluster.Spec.Networking.Topology.Bastion != nil && b.Cluster.Spec.Networking.Topology.Bastion.LoadBalancer != nil && b.Cluster.Spec.Networking.Topology.Bastion.LoadBalancer.AdditionalSecurityGroups != nil {
398+
for _, id := range b.Cluster.Spec.Networking.Topology.Bastion.LoadBalancer.AdditionalSecurityGroups {
399+
t := &awstasks.SecurityGroup{
400+
Name: fi.PtrTo(id),
401+
Lifecycle: b.SecurityLifecycle,
402+
ID: fi.PtrTo(id),
403+
Shared: fi.PtrTo(true),
404+
}
405+
c.EnsureTask(t)
406+
nlb.SecurityGroups = append(nlb.SecurityGroups, t)
407+
}
408+
}
409+
396410
c.AddTask(nlb)
397411
}
398412

tests/integration/update_cluster/bastionadditional_user-data/data/aws_s3_object_cluster-completed.spec_content

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ spec:
209209
zone: us-test-1a
210210
topology:
211211
bastion:
212-
loadBalancer: {}
212+
loadBalancer:
213+
additionalSecurityGroups:
214+
- sg-exampleid
213215
dns:
214216
type: Public

0 commit comments

Comments
 (0)