Skip to content

Commit

Permalink
Set BindAddress appropriately when in IPv6-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Jun 11, 2021
1 parent 84cecd5 commit b0068b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package kops

import (
"fmt"
"net"

"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -793,6 +794,11 @@ func (c *Cluster) IsSharedAzureRouteTable() bool {
return c.Spec.CloudConfig.Azure.RouteTableName != ""
}

func (c *ClusterSpec) IsIPv6Only() bool {
cidr, _, _ := net.ParseCIDR(c.NonMasqueradeCIDR)
return cidr != nil && cidr.To4() == nil
}

// EnvVar represents an environment variable present in a Container.
type EnvVar struct {
// Name of the environment variable. Must be a C_IDENTIFIER.
Expand Down
6 changes: 5 additions & 1 deletion pkg/model/components/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(o interface{}) error {
c.LogLevel = 2
c.SecurePort = 443

c.BindAddress = "0.0.0.0"
if clusterSpec.IsIPv6Only() {
c.BindAddress = "::"
} else {
c.BindAddress = "0.0.0.0"
}

c.AllowPrivileged = fi.Bool(true)
c.ServiceClusterIPRange = clusterSpec.ServiceClusterIPRange
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/iam/subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func supportsPublicJWKS(clusterSpec *kops.ClusterSpec) bool {
return false
}
for _, cidr := range clusterSpec.KubernetesAPIAccess {
if cidr == "0.0.0.0/0" {
if cidr == "0.0.0.0/0" || cidr == "::/0" {
return true
}
}
Expand Down

0 comments on commit b0068b4

Please sign in to comment.