Skip to content

Commit

Permalink
Merge pull request #15189 from hakman/automated-cherry-pick-of-#15040…
Browse files Browse the repository at this point in the history
…-upstream-release-1.25

Automated cherry pick of #15040: gce: When using network native pod IPs, open firewall to
  • Loading branch information
k8s-ci-robot authored Mar 3, 2023
2 parents cfd98bb + 776802a commit 55c2d03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/model/gcemodel/api_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gcemodel

import (
"fmt"
"strconv"

"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/wellknownports"
Expand Down Expand Up @@ -95,6 +96,18 @@ func createPublicLB(b *APILoadBalancerBuilder, c *fi.ModelBuilderContext) error
TargetTags: []string{b.GCETagForRole(kops.InstanceGroupRoleMaster)},
Allowed: []string{"tcp:443"},
})

if b.NetworkingIsIPAlias() {
c.AddTask(&gcetasks.FirewallRule{
Name: s(b.NameForFirewallRule("pod-cidrs-to-https-api")),
Lifecycle: b.Lifecycle,
Network: network,
SourceRanges: []string{b.Cluster.Spec.PodCIDR},
TargetTags: []string{b.GCETagForRole(kops.InstanceGroupRoleMaster)},
Allowed: []string{"tcp:" + strconv.Itoa(wellknownports.KubeAPIServer)},
})
}

}
return nil

Expand Down
14 changes: 14 additions & 0 deletions pkg/model/gcemodel/external_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ limitations under the License.
package gcemodel

import (
"strconv"

"k8s.io/klog/v2"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/wellknownports"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup/gcetasks"
)
Expand Down Expand Up @@ -112,6 +115,17 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.ModelBuilderContext) error {
SourceRanges: b.Cluster.Spec.KubernetesAPIAccess,
Network: network,
})

if b.NetworkingIsIPAlias() {
c.AddTask(&gcetasks.FirewallRule{
Name: s(b.NameForFirewallRule("pod-cidrs-to-https-api")),
Lifecycle: b.Lifecycle,
Network: network,
SourceRanges: []string{b.Cluster.Spec.PodCIDR},
TargetTags: []string{b.GCETagForRole(kops.InstanceGroupRoleMaster)},
Allowed: []string{"tcp:" + strconv.Itoa(wellknownports.KubeAPIServer)},
})
}
}

return nil
Expand Down

0 comments on commit 55c2d03

Please sign in to comment.