Skip to content

Commit

Permalink
give kindnet permissions in aws to disable the src dst check
Browse files Browse the repository at this point in the history
Change-Id: I11436822e7c8549b294f1a2d23c0d169376cbf23
  • Loading branch information
aojea committed Jan 2, 2025
1 parent 9e9e0a5 commit b74c57b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/model/components/kindnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (b *KindnetOptionsBuilder) BuildOptions(o *kops.Cluster) error {
}

// Kindnet should masquerade well known ranges if kops is not doing it
if c.Masquerade == nil && clusterSpec.Networking.NonMasqueradeCIDR == "" {
if c.Masquerade == nil {
c.Masquerade = &kops.KindnetMasqueradeSpec{
Enabled: fi.PtrTo(true),
}
Expand Down
19 changes: 19 additions & 0 deletions pkg/model/iam/iam_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ func (r *NodeRoleAPIServer) BuildAWSPolicy(b *PolicyBuilder) (*Policy, error) {
addCalicoSrcDstCheckPermissions(p)
}

if b.Cluster.Spec.Networking.Kindnet != nil {
addKindnetSrcDstCheckPermissions(p)
}

return p, nil
}

Expand Down Expand Up @@ -438,6 +442,10 @@ func (r *NodeRoleMaster) BuildAWSPolicy(b *PolicyBuilder) (*Policy, error) {
addCalicoSrcDstCheckPermissions(p)
}

if b.Cluster.Spec.Networking.Kindnet != nil {
addKindnetSrcDstCheckPermissions(p)
}

return p, nil
}

Expand Down Expand Up @@ -469,6 +477,10 @@ func (r *NodeRoleNode) BuildAWSPolicy(b *PolicyBuilder) (*Policy, error) {
addKubeRouterSrcDstCheckPermissions(p)
}

if b.Cluster.Spec.Networking.Kindnet != nil {
addKindnetSrcDstCheckPermissions(p)
}

return p, nil
}

Expand Down Expand Up @@ -777,6 +789,13 @@ func addKubeRouterSrcDstCheckPermissions(p *Policy) {
)
}

func addKindnetSrcDstCheckPermissions(p *Policy) {
p.unconditionalAction.Insert(
"ec2:DescribeInstances",
"ec2:ModifyNetworkInterfaceAttribute",
)
}

func (b *PolicyBuilder) addNodeupPermissions(p *Policy, enableHookSupport bool) {
addCertIAMPolicies(p)
addKMSGenerateRandomPolicies(p)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"ec2:DescribeVolumesModifications",
"ec2:DescribeVpcs",
"ec2:GetInstanceTypesFromInstanceRequirements",
"ec2:ModifyNetworkInterfaceAttribute",
"elasticloadbalancing:DescribeListeners",
"elasticloadbalancing:DescribeLoadBalancerAttributes",
"elasticloadbalancing:DescribeLoadBalancerPolicies",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"ec2:DescribeInstanceTypes",
"ec2:DescribeInstances",
"ec2:DescribeRegions",
"ec2:ModifyNetworkInterfaceAttribute",
"iam:GetServerCertificate",
"iam:ListServerCertificates",
"kms:GenerateRandom"
Expand Down

0 comments on commit b74c57b

Please sign in to comment.