Skip to content

Commit eb15f69

Browse files
authored
Merge pull request #4406 from giantswarm/save-nat-ips-status
Allow securing api LB, only allowing traffic from required sources
2 parents 7dd35e0 + 546fffc commit eb15f69

14 files changed

+333
-39
lines changed

api/v1beta1/awscluster_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
5353
for role, sg := range restored.Status.Network.SecurityGroups {
5454
dst.Status.Network.SecurityGroups[role] = sg
5555
}
56+
dst.Status.Network.NatGatewaysIPs = restored.Status.Network.NatGatewaysIPs
5657

5758
return nil
5859
}

api/v1beta1/zz_generated.conversion.go

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

api/v1beta2/network_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ type NetworkStatus struct {
3636

3737
// APIServerELB is the Kubernetes api server load balancer.
3838
APIServerELB LoadBalancer `json:"apiServerElb,omitempty"`
39+
40+
// NatGatewaysIPs contains the public IPs of the NAT Gateways
41+
NatGatewaysIPs []string `json:"natGatewaysIPs,omitempty"`
3942
}
4043

4144
// ELBScheme defines the scheme of a load balancer.
@@ -55,6 +58,15 @@ func (e ELBScheme) String() string {
5558
return string(e)
5659
}
5760

61+
// Equals returns true if two ELBScheme are equal.
62+
func (e ELBScheme) Equals(other *ELBScheme) bool {
63+
if other == nil {
64+
return false
65+
}
66+
67+
return e == *other
68+
}
69+
5870
// ELBProtocol defines listener protocols for a load balancer.
5971
type ELBProtocol string
6072

api/v1beta2/zz_generated.deepcopy.go

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

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,12 @@ spec:
13541354
balancer.
13551355
type: object
13561356
type: object
1357+
natGatewaysIPs:
1358+
description: NatGatewaysIPs contains the public IPs of the NAT
1359+
Gateways
1360+
items:
1361+
type: string
1362+
type: array
13571363
securityGroups:
13581364
additionalProperties:
13591365
description: SecurityGroup defines an AWS security group.
@@ -2815,6 +2821,12 @@ spec:
28152821
balancer.
28162822
type: object
28172823
type: object
2824+
natGatewaysIPs:
2825+
description: NatGatewaysIPs contains the public IPs of the NAT
2826+
Gateways
2827+
items:
2828+
type: string
2829+
type: array
28182830
securityGroups:
28192831
additionalProperties:
28202832
description: SecurityGroup defines an AWS security group.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,12 @@ spec:
18871887
balancer.
18881888
type: object
18891889
type: object
1890+
natGatewaysIPs:
1891+
description: NatGatewaysIPs contains the public IPs of the NAT
1892+
Gateways
1893+
items:
1894+
type: string
1895+
type: array
18901896
securityGroups:
18911897
additionalProperties:
18921898
description: SecurityGroup defines an AWS security group.

pkg/cloud/interfaces.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ type ClusterScoper interface {
7979
AdditionalTags() infrav1.Tags
8080
// SetFailureDomain sets the infrastructure provider failure domain key to the spec given as input.
8181
SetFailureDomain(id string, spec clusterv1.FailureDomainSpec)
82-
8382
// PatchObject persists the cluster configuration and status.
8483
PatchObject() error
8584
// Close closes the current scope persisting the cluster configuration and status.

pkg/cloud/scope/cluster.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ func (s *ClusterScope) SetFailureDomain(id string, spec clusterv1.FailureDomainS
299299
s.AWSCluster.Status.FailureDomains[id] = spec
300300
}
301301

302+
// SetNatGatewaysIPs sets the Nat Gateways Public IPs.
303+
func (s *ClusterScope) SetNatGatewaysIPs(ips []string) {
304+
s.AWSCluster.Status.Network.NatGatewaysIPs = ips
305+
}
306+
307+
// GetNatGatewaysIPs gets the Nat Gateways Public IPs.
308+
func (s *ClusterScope) GetNatGatewaysIPs() []string {
309+
return s.AWSCluster.Status.Network.NatGatewaysIPs
310+
}
311+
302312
// InfraCluster returns the AWS infrastructure cluster or control plane object.
303313
func (s *ClusterScope) InfraCluster() cloud.ClusterObject {
304314
return s.AWSCluster

pkg/cloud/scope/managedcontrolplane.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ func (s *ManagedControlPlaneScope) Subnets() infrav1.Subnets {
169169
return s.ControlPlane.Spec.NetworkSpec.Subnets
170170
}
171171

172+
// SetNatGatewaysIPs sets the Nat Gateways Public IPs.
173+
func (s *ManagedControlPlaneScope) SetNatGatewaysIPs(ips []string) {
174+
s.ControlPlane.Status.Network.NatGatewaysIPs = ips
175+
}
176+
177+
// GetNatGatewaysIPs gets the Nat Gateways Public IPs.
178+
func (s *ManagedControlPlaneScope) GetNatGatewaysIPs() []string {
179+
return s.ControlPlane.Status.Network.NatGatewaysIPs
180+
}
181+
172182
// IdentityRef returns the cluster identityRef.
173183
func (s *ManagedControlPlaneScope) IdentityRef() *infrav1.AWSIdentityReference {
174184
return s.ControlPlane.Spec.IdentityRef

pkg/cloud/scope/network.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ type NetworkScope interface {
4545

4646
// TagUnmanagedNetworkResources returns is tagging unmanaged network resources is set.
4747
TagUnmanagedNetworkResources() bool
48+
49+
// SetNatGatewaysIPs sets the Nat Gateways Public IPs.
50+
SetNatGatewaysIPs(ips []string)
51+
// GetNatGatewaysIPs gets the Nat Gateways Public IPs.
52+
GetNatGatewaysIPs() []string
4853
}

0 commit comments

Comments
 (0)