Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Consul Dataplane for Terminating Gateways #1534

Merged
merged 32 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fe7507b
Initial support for agentless (#1267)
ishustava Jun 24, 2022
f357a02
Register mesh-gateways using the endpoints controller. (#1464)
Sep 21, 2022
ac356f2
agentless: integrate connect-inject with consul-server-connection-man…
ishustava Sep 6, 2022
dd83678
wip
ishustava Sep 20, 2022
c7c0ece
wip: mesh gateways with connect-init and new consul-dataplane
ishustava Sep 21, 2022
3bfce31
Add bats tests for updates to mesh-gateway deployment.
thisisnotashwin Sep 21, 2022
7b89850
Initial support for agentless (#1267)
ishustava Jun 24, 2022
665b952
Enable CRD controller to talk to Consul servers (#1326)
ishustava Jul 7, 2022
0ff9531
agentless: initial integration with consul-dataplane (#1470)
ishustava Sep 6, 2022
7bb8e81
Register mesh-gateways using the endpoints controller.
thisisnotashwin Aug 30, 2022
29fe212
Review feedback from Iryna
thisisnotashwin Sep 20, 2022
f73a283
Initial support for agentless (#1267)
ishustava Jun 24, 2022
9ea04de
Register mesh-gateways using the endpoints controller.
thisisnotashwin Aug 30, 2022
4509f2a
agentless: initial integration with consul-dataplane (#1470)
ishustava Sep 6, 2022
3070bd9
Register mesh-gateways using the endpoints controller.
thisisnotashwin Aug 30, 2022
9496185
[WIP] Register mesh-gateways using the endpoints controller.
thisisnotashwin Aug 30, 2022
1e1c20d
Register Terminating Gateways with Endpoints Controller
Sep 8, 2022
fcf8809
Fix endpoints controller ent test.
thisisnotashwin Sep 22, 2022
7bf1a97
Use consul-dataplane for terminating gateways
Sep 26, 2022
ac3377e
Remove autoencrypt from acceptance tests
Sep 27, 2022
7ae3467
Run terminating gateway acceptance tests
Sep 27, 2022
6c87e94
Update BATS tests
Sep 27, 2022
673495f
Fix issues from merge
Sep 28, 2022
26cfe42
Fix loophole for mesh gateways
Sep 28, 2022
31f30ff
Fix consul namespace being set on termgw
Sep 28, 2022
1d9ac7f
Fix values passed in to consul-dataplane
Sep 28, 2022
d0ccea9
Fix terminating gateways deployment and BATS
Sep 28, 2022
0e93d55
Fix ingress and mesh BATS
Sep 28, 2022
daf6468
Set terminating gateway service name to be set by annotation
Sep 28, 2022
d009284
One more mesh gw bats fix
Sep 28, 2022
3ed7350
Make the secure setting a bit prettier :nails:
Sep 28, 2022
75b3c7c
Address Iryna's comments
Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions acceptance/tests/terminating-gateway/main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package terminatinggateway

import (
"fmt"
"os"
"testing"

Expand All @@ -11,8 +10,6 @@ import (
var suite testsuite.Suite

func TestMain(m *testing.M) {
fmt.Println("Skipping terminating gateway tests because it's not supported with agentless yet")
os.Exit(0)
//suite = testsuite.NewSuite(m)
//os.Exit(suite.Run())
suite = testsuite.NewSuite(m)
os.Exit(suite.Run())
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func TestTerminatingGatewayDestinations(t *testing.T) {

"global.acls.manageSystemACLs": strconv.FormatBool(c.secure),
"global.tls.enabled": strconv.FormatBool(c.secure),
"global.tls.autoEncrypt": strconv.FormatBool(c.secure),
}

logger.Log(t, "creating consul cluster")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ import (
"github.com/hashicorp/consul-k8s/acceptance/framework/helpers"
"github.com/hashicorp/consul-k8s/acceptance/framework/k8s"
"github.com/hashicorp/consul-k8s/acceptance/framework/logger"
"github.com/hashicorp/consul/api"
"github.com/stretchr/testify/require"
)

const testNamespace = "ns1"

// Test we can connect through the terminating gateway when both
// the terminating gateway and the connect service are in the same namespace.
// These tests currently only test non-secure and secure without auto-encrypt installations
// because in the case of namespaces there isn't a significant distinction in code between auto-encrypt
// and non-auto-encrypt secure installations, so testing just one is enough.
func TestTerminatingGatewaySingleNamespace(t *testing.T) {
cfg := suite.Config()
if !cfg.EnableEnterprise {
Expand All @@ -31,53 +26,37 @@ func TestTerminatingGatewaySingleNamespace(t *testing.T) {
secure bool
}{
{
false,
secure: false,
},
{
true,
secure: true,
},
}
for _, c := range cases {
name := fmt.Sprintf("secure: %t", c.secure)
t.Run(name, func(t *testing.T) {
ctx := suite.Environment().DefaultContext(t)

// Install the Helm chart without the terminating gateway first
// so that we can create the namespace for it.
helmValues := map[string]string{
"connectInject.enabled": "true",
"connectInject.consulNamespaces.consulDestinationNamespace": testNamespace,

"global.enableConsulNamespaces": "true",
"global.acls.manageSystemACLs": strconv.FormatBool(c.secure),
"global.tls.enabled": strconv.FormatBool(c.secure),

"terminatingGateways.enabled": "true",
"terminatingGateways.gateways[0].name": "terminating-gateway",
"terminatingGateways.gateways[0].replicas": "1",
"terminatingGateways.gateways[0].consulNamespace": testNamespace,
}

releaseName := helpers.RandomName()
consulCluster := consul.NewHelmCluster(t, helmValues, ctx, cfg, releaseName)

consulCluster.Create(t)

consulClient, _ := consulCluster.SetupConsulClient(t, c.secure)

// Create the destination namespace in the non-secure case.
// In the secure installation, this namespace is created by the server-acl-init job.
if !c.secure {
logger.Logf(t, "creating the %s namespace in Consul", testNamespace)
_, _, err := consulClient.Namespaces().Create(&api.Namespace{
Name: testNamespace,
}, nil)
require.NoError(t, err)
}

logger.Log(t, "upgrading with terminating gateways enabled")
consulCluster.Upgrade(t, map[string]string{
"terminatingGateways.enabled": "true",
"terminatingGateways.gateways[0].name": "terminating-gateway",
"terminatingGateways.gateways[0].replicas": "1",
"terminatingGateways.gateways[0].consulNamespace": testNamespace,
})

logger.Logf(t, "creating Kubernetes namespace %s", testNamespace)
k8s.RunKubectl(t, ctx.KubectlOptions(t), "create", "ns", testNamespace)
helpers.Cleanup(t, cfg.NoCleanupOnFailure, func() {
Expand Down Expand Up @@ -132,9 +111,6 @@ func TestTerminatingGatewaySingleNamespace(t *testing.T) {

// Test we can connect through the terminating gateway when the terminating gateway,
// the external service, and the connect service are in different namespace.
// These tests currently only test non-secure and secure without auto-encrypt installations
// because in the case of namespaces there isn't a significant distinction in code between auto-encrypt
// and non-auto-encrypt secure installations, so testing just one is enough.
func TestTerminatingGatewayNamespaceMirroring(t *testing.T) {
cfg := suite.Config()
if !cfg.EnableEnterprise {
Expand All @@ -145,10 +121,10 @@ func TestTerminatingGatewayNamespaceMirroring(t *testing.T) {
secure bool
}{
{
false,
secure: false,
},
{
true,
secure: true,
},
}
for _, c := range cases {
Expand Down
16 changes: 4 additions & 12 deletions acceptance/tests/terminating-gateway/terminating_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@ import (
// Test that terminating gateways work in a default and secure installations.
func TestTerminatingGateway(t *testing.T) {
cases := []struct {
secure bool
autoEncrypt bool
secure bool
}{
{
false,
false,
secure: false,
},
{
true,
true,
},
{
true,
true,
secure: true,
},
}
for _, c := range cases {
name := fmt.Sprintf("secure: %t, auto-encrypt: %t", c.secure, c.autoEncrypt)
name := fmt.Sprintf("secure: %t", c.secure)
t.Run(name, func(t *testing.T) {
ctx := suite.Environment().DefaultContext(t)
cfg := suite.Config()
Expand All @@ -46,7 +39,6 @@ func TestTerminatingGateway(t *testing.T) {

"global.acls.manageSystemACLs": strconv.FormatBool(c.secure),
"global.tls.enabled": strconv.FormatBool(c.secure),
"global.tls.autoEncrypt": strconv.FormatBool(c.autoEncrypt),
}

logger.Log(t, "creating consul cluster")
Expand Down
Loading