Skip to content

Commit

Permalink
fix kubelet sg rules
Browse files Browse the repository at this point in the history
  • Loading branch information
zetaab committed Sep 11, 2019
1 parent 5be76d3 commit 8924193
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions pkg/model/openstackmodel/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,26 +270,28 @@ func (b *FirewallModelBuilder) addHTTPSRules(c *fi.ModelBuilderContext, sgMap ma
return nil
}

// addKubeletRules - Add rules to 10250 to the KubernetesAPIAccess list
// addKubeletRules - Add rules to 10250 port
func (b *FirewallModelBuilder) addKubeletRules(c *fi.ModelBuilderContext, sgMap map[string]*openstacktasks.SecurityGroup) error {

//TODO: This is the default port for kubelet and may be overwridden
masterName := b.SecurityGroupName(kops.InstanceGroupRoleMaster)
nodeName := b.SecurityGroupName(kops.InstanceGroupRoleNode)
masterSG := sgMap[masterName]
nodeSG := sgMap[nodeName]

kubeletRule := &openstacktasks.SecurityGroupRule{
Lifecycle: b.Lifecycle,
Direction: s(string(rules.DirIngress)),
Protocol: s(IPProtocolTCP),
EtherType: s(IPV4),
PortRangeMin: i(10250),
PortRangeMax: i(10250),
}

// allow node-node, node-master and master-master and master-node
for _, sgName := range []*openstacktasks.SecurityGroup{masterSG, nodeSG} {
for _, apiAccess := range b.Cluster.Spec.KubernetesAPIAccess {
addDirectionalGroupRule(c, sgName, nil, &openstacktasks.SecurityGroupRule{
Lifecycle: b.Lifecycle,
Direction: s(string(rules.DirIngress)),
Protocol: s(IPProtocolTCP),
EtherType: s(IPV4),
PortRangeMin: i(10250),
PortRangeMax: i(10250),
RemoteIPPrefix: s(apiAccess),
})
}
addDirectionalGroupRule(c, masterSG, sgName, kubeletRule)
addDirectionalGroupRule(c, nodeSG, sgName, kubeletRule)
}
return nil
}
Expand Down

0 comments on commit 8924193

Please sign in to comment.