Skip to content

Commit

Permalink
Merge pull request #2349 from neiljerram/default-allow-port-6443
Browse files Browse the repository at this point in the history
Merge pull request #2336 from neiljerram/default-allow-port-6443
  • Loading branch information
Neil Jerram authored May 26, 2020
2 parents 204a0f5 + c27a803 commit ca5e8bf
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/config_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ type Config struct {
PrometheusGoMetricsEnabled bool `config:"bool;true"`
PrometheusProcessMetricsEnabled bool `config:"bool;true"`

FailsafeInboundHostPorts []ProtoPort `config:"port-list;tcp:22,udp:68,tcp:179,tcp:2379,tcp:2380,tcp:6666,tcp:6667;die-on-fail"`
FailsafeOutboundHostPorts []ProtoPort `config:"port-list;udp:53,udp:67,tcp:179,tcp:2379,tcp:2380,tcp:6666,tcp:6667;die-on-fail"`
FailsafeInboundHostPorts []ProtoPort `config:"port-list;tcp:22,udp:68,tcp:179,tcp:2379,tcp:2380,tcp:6443,tcp:6666,tcp:6667;die-on-fail"`
FailsafeOutboundHostPorts []ProtoPort `config:"port-list;udp:53,udp:67,tcp:179,tcp:2379,tcp:2380,tcp:6443,tcp:6666,tcp:6667;die-on-fail"`

KubeNodePortRanges []numorstring.Port `config:"portrange-list;30000:32767"`
NATPortRange numorstring.Port `config:"portrange;"`
Expand Down
4 changes: 4 additions & 0 deletions config/config_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ var _ = DescribeTable("Config parsing",
{Protocol: "tcp", Port: 179},
{Protocol: "tcp", Port: 2379},
{Protocol: "tcp", Port: 2380},
{Protocol: "tcp", Port: 6443},
{Protocol: "tcp", Port: 6666},
{Protocol: "tcp", Port: 6667},
},
Expand All @@ -365,6 +366,7 @@ var _ = DescribeTable("Config parsing",
{Protocol: "tcp", Port: 179},
{Protocol: "tcp", Port: 2379},
{Protocol: "tcp", Port: 2380},
{Protocol: "tcp", Port: 6443},
{Protocol: "tcp", Port: 6666},
{Protocol: "tcp", Port: 6667},
},
Expand All @@ -381,6 +383,7 @@ var _ = DescribeTable("Config parsing",
{Protocol: "tcp", Port: 179},
{Protocol: "tcp", Port: 2379},
{Protocol: "tcp", Port: 2380},
{Protocol: "tcp", Port: 6443},
{Protocol: "tcp", Port: 6666},
{Protocol: "tcp", Port: 6667},
},
Expand All @@ -392,6 +395,7 @@ var _ = DescribeTable("Config parsing",
{Protocol: "tcp", Port: 179},
{Protocol: "tcp", Port: 2379},
{Protocol: "tcp", Port: 2380},
{Protocol: "tcp", Port: 6443},
{Protocol: "tcp", Port: 6666},
{Protocol: "tcp", Port: 6667},
},
Expand Down
2 changes: 1 addition & 1 deletion fv/connectivity/conncheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ type CheckCmd struct {
recvLen int
}

// BinaryName is the name of the binry that the connectivity Check() executes
// BinaryName is the name of the binary that the connectivity Check() executes
const BinaryName = "test-connection"

// Run executes the check command
Expand Down
10 changes: 10 additions & 0 deletions fv/hostendpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ func describeHostEndpointTests(getInfra infrastructure.InfraFactory, allInterfac
cc.ExpectNone(felixes[0], w[1])
cc.ExpectNone(felixes[1], w[0])
}
expectConnectivityToAPIServer := func() {
ip := connectivity.TargetIP(infra.(*infrastructure.K8sDatastoreInfra).EndpointIP)
cc.ExpectSome(felixes[0], ip, 6443)
cc.ExpectSome(felixes[1], ip, 6443)
}

Context("with no policies and no profiles on the host endpoints", func() {
BeforeEach(func() {
Expand Down Expand Up @@ -153,6 +158,11 @@ func describeHostEndpointTests(getInfra infrastructure.InfraFactory, allInterfac
}
})

It("should allow connectivity from nodes to the Kubernetes API server", func() {
expectConnectivityToAPIServer()
cc.CheckConnectivity()
})

It("should block all traffic except pod-to-pod and host-to-own-pod traffic", func() {
expectDenyHostToHostTraffic()
expectDenyHostToOtherPodTraffic()
Expand Down
2 changes: 2 additions & 0 deletions fv/infrastructure/infra_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type K8sDatastoreInfra struct {
K8sClient *kubernetes.Clientset

Endpoint string
EndpointIP string
BadEndpoint string

CertFileName string
Expand Down Expand Up @@ -267,6 +268,7 @@ func setupK8sDatastoreInfra() (*K8sDatastoreInfra, error) {
return nil, err
}

kds.EndpointIP = kds.k8sApiContainer.IP
kds.Endpoint = fmt.Sprintf("https://%s:6443", kds.k8sApiContainer.IP)
kds.BadEndpoint = fmt.Sprintf("https://%s:1234", kds.k8sApiContainer.IP)

Expand Down
7 changes: 7 additions & 0 deletions fv/test-connection/test-connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ func tryConnect(remoteIPAddr, remotePort, sourceIPAddr, sourcePort, protocol str
_ = tc.Close()
}()

if remotePort == "6443" {
// Testing for connectivity to the Kubernetes API server. If we reach here, we're
// good. Skip sending and receiving any data, as that would need TLS.
connectivity.Result{}.PrintToStdout()
return nil
}

if loopFile != "" {
return tc.tryLoopFile(loopFile)
}
Expand Down

0 comments on commit ca5e8bf

Please sign in to comment.