Skip to content

Commit

Permalink
Initial support for agentless (#1267)
Browse files Browse the repository at this point in the history
Add initial support for the basic service mesh running with agentless.

* Update connect-inject deployment to talk to consul servers (currently only in-cluster servers are supported; external servers support will come in a later PR)
* Update endpoints controller to register and deregister services and health checks in the catalog and stop using agent APIs
* Update connect-init command to take the -node-name flag so that it can search for services within a given node using catalog APIs
* Add k8s probes to the envoy container
* Provide -node-name flag to the consul connect envoy command so that we can generate correct configuration
* Selectively disable acceptance tests that don't yet work in this configuration
* Disable consul clients by default
  • Loading branch information
ishustava authored and jmurret committed Sep 27, 2022
1 parent d462100 commit c897e70
Show file tree
Hide file tree
Showing 49 changed files with 2,993 additions and 4,347 deletions.
17 changes: 8 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ commands:
if ! gotestsum --no-summary=all --jsonfile=jsonfile-${pkg////-} -- $pkg -p 1 -timeout 2h -failfast \
<< parameters.additional-flags >> \
${ENABLE_ENTERPRISE:+-enable-enterprise} \
-enable-multi-cluster \
-debug-directory="$TEST_RESULTS/debug" \
-consul-k8s-image=<< parameters.consul-k8s-image >>
then
Expand Down Expand Up @@ -1217,14 +1216,14 @@ workflows:
context: consul-ci
requires:
- dev-upload-docker
- acceptance-tproxy-cni:
context: consul-ci
requires:
- dev-upload-docker
- acceptance-tproxy:
context: consul-ci
requires:
- dev-upload-docker
# - acceptance-tproxy-cni:
# context: consul-ci
# requires:
# - dev-upload-docker
# - acceptance-tproxy:
# context: consul-ci
# requires:
# - dev-upload-docker
nightly-acceptance-tests:
triggers:
- schedule:
Expand Down
59 changes: 3 additions & 56 deletions acceptance/tests/connect/connect_inject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestConnectInject(t *testing.T) {
secure bool
autoEncrypt bool
}{
"Helm install without secure or auto-encrypt": {
"Helm install without secure": {
clusterKind: consul.Helm,
releaseName: helpers.RandomName(),
},
Expand All @@ -38,13 +38,7 @@ func TestConnectInject(t *testing.T) {
releaseName: helpers.RandomName(),
secure: true,
},
"Helm install with secure and auto-encrypt": {
clusterKind: consul.Helm,
releaseName: helpers.RandomName(),
secure: true,
autoEncrypt: true,
},
"CLI install without secure or auto-encrypt": {
"CLI install without secure": {
clusterKind: consul.CLI,
releaseName: consul.CLIReleaseName,
},
Expand All @@ -53,12 +47,6 @@ func TestConnectInject(t *testing.T) {
releaseName: consul.CLIReleaseName,
secure: true,
},
"CLI install with secure and auto-encrypt": {
clusterKind: consul.CLI,
releaseName: consul.CLIReleaseName,
secure: true,
autoEncrypt: true,
},
}

for name, c := range cases {
Expand Down Expand Up @@ -129,6 +117,7 @@ func TestConnectInject(t *testing.T) {
// TestConnectInjectOnUpgrade tests that Connect works before and after an
// upgrade is performed on the cluster.
func TestConnectInjectOnUpgrade(t *testing.T) {
t.Skipf("skipping this test because it's not yet supported with agentless")
cases := map[string]struct {
clusterKind consul.ClusterKind
releaseName string
Expand Down Expand Up @@ -259,48 +248,6 @@ func TestConnectInject_CleanupKilledPods(t *testing.T) {
}
}

// Test that when Consul clients are restarted and lose all their registrations,
// the services get re-registered and can continue to talk to each other.
func TestConnectInject_RestartConsulClients(t *testing.T) {
cfg := suite.Config()
ctx := suite.Environment().DefaultContext(t)

helmValues := map[string]string{
"connectInject.enabled": "true",
}

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

consulCluster.Create(t)

logger.Log(t, "creating static-server and static-client deployments")
k8s.DeployKustomize(t, ctx.KubectlOptions(t), cfg.NoCleanupOnFailure, cfg.DebugDirectory, "../fixtures/cases/static-server-inject")
if cfg.EnableTransparentProxy {
k8s.DeployKustomize(t, ctx.KubectlOptions(t), cfg.NoCleanupOnFailure, cfg.DebugDirectory, "../fixtures/cases/static-client-tproxy")
} else {
k8s.DeployKustomize(t, ctx.KubectlOptions(t), cfg.NoCleanupOnFailure, cfg.DebugDirectory, "../fixtures/cases/static-client-inject")
}

logger.Log(t, "checking that connection is successful")
if cfg.EnableTransparentProxy {
k8s.CheckStaticServerConnectionSuccessful(t, ctx.KubectlOptions(t), StaticClientName, "http://static-server")
} else {
k8s.CheckStaticServerConnectionSuccessful(t, ctx.KubectlOptions(t), StaticClientName, "http://localhost:1234")
}

logger.Log(t, "restarting Consul client daemonset")
k8s.RunKubectl(t, ctx.KubectlOptions(t), "rollout", "restart", fmt.Sprintf("ds/%s-consul-client", releaseName))
k8s.RunKubectl(t, ctx.KubectlOptions(t), "rollout", "status", fmt.Sprintf("ds/%s-consul-client", releaseName))

logger.Log(t, "checking that connection is still successful")
if cfg.EnableTransparentProxy {
k8s.CheckStaticServerConnectionSuccessful(t, ctx.KubectlOptions(t), StaticClientName, "http://static-server")
} else {
k8s.CheckStaticServerConnectionSuccessful(t, ctx.KubectlOptions(t), StaticClientName, "http://localhost:1234")
}
}

const multiport = "multiport"
const multiportAdmin = "multiport-admin"

Expand Down
7 changes: 5 additions & 2 deletions acceptance/tests/controller/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controller

import (
"fmt"
"os"
"testing"

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

func TestMain(m *testing.M) {
suite = testSuite.NewSuite(m)
os.Exit(suite.Run())
fmt.Println("Skipping controller tests because it's not supported with agentless yet")
os.Exit(0)
//suite = testSuite.NewSuite(m)
//os.Exit(suite.Run())
}
7 changes: 5 additions & 2 deletions acceptance/tests/ingress-gateway/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ingressgateway

import (
"fmt"
"os"
"testing"

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

func TestMain(m *testing.M) {
suite = testsuite.NewSuite(m)
os.Exit(suite.Run())
fmt.Println("Skipping ingress gateway tests because it's not supported with agentless yet")
os.Exit(0)
//suite = testsuite.NewSuite(m)
//os.Exit(suite.Run())
}
38 changes: 19 additions & 19 deletions acceptance/tests/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/hashicorp/consul/sdk/testutil/retry"

"github.com/hashicorp/consul-k8s/acceptance/framework/consul"
"github.com/hashicorp/consul-k8s/acceptance/framework/environment"
"github.com/hashicorp/consul-k8s/acceptance/framework/helpers"
"github.com/hashicorp/consul-k8s/acceptance/framework/k8s"
"github.com/hashicorp/consul-k8s/acceptance/framework/logger"
Expand All @@ -22,6 +21,7 @@ const StaticClientName = "static-client"
// Test that prometheus metrics, when enabled, are accessible from the
// endpoints that have been exposed on the server, client and gateways.
func TestComponentMetrics(t *testing.T) {
t.Skipf("Skipping this test because it's not yet supported with agentless")
env := suite.Environment()
cfg := suite.Config()
ctx := env.DefaultContext(t)
Expand Down Expand Up @@ -77,14 +77,14 @@ func TestComponentMetrics(t *testing.T) {
require.NoError(t, err)
require.Contains(t, metricsOutput, `consul_acl_ResolveToken{quantile="0.5"}`)

// Ingress Gateway Metrics
assertGatewayMetricsEnabled(t, ctx, ns, "ingress-gateway", `envoy_cluster_assignment_stale{local_cluster="ingress-gateway",consul_source_service="ingress-gateway"`)

// Terminating Gateway Metrics
assertGatewayMetricsEnabled(t, ctx, ns, "terminating-gateway", `envoy_cluster_assignment_stale{local_cluster="terminating-gateway",consul_source_service="terminating-gateway"`)

// Mesh Gateway Metrics
assertGatewayMetricsEnabled(t, ctx, ns, "mesh-gateway", `envoy_cluster_assignment_stale{local_cluster="mesh-gateway",consul_source_service="mesh-gateway"`)
//// Ingress Gateway Metrics
//assertGatewayMetricsEnabled(t, ctx, ns, "ingress-gateway", `envoy_cluster_assignment_stale{local_cluster="ingress-gateway",consul_source_service="ingress-gateway"`)
//
//// Terminating Gateway Metrics
//assertGatewayMetricsEnabled(t, ctx, ns, "terminating-gateway", `envoy_cluster_assignment_stale{local_cluster="terminating-gateway",consul_source_service="terminating-gateway"`)
//
//// Mesh Gateway Metrics
//assertGatewayMetricsEnabled(t, ctx, ns, "mesh-gateway", `envoy_cluster_assignment_stale{local_cluster="mesh-gateway",consul_source_service="mesh-gateway"`)
}

// Test that merged service and envoy metrics are accessible from the
Expand Down Expand Up @@ -137,13 +137,13 @@ func TestAppMetrics(t *testing.T) {
})
}

func assertGatewayMetricsEnabled(t *testing.T, ctx environment.TestContext, ns, label, metricsAssertion string) {
pods, err := ctx.KubernetesClient(t).CoreV1().Pods(ns).List(context.Background(), metav1.ListOptions{LabelSelector: fmt.Sprintf("component=%s", label)})
require.NoError(t, err)
for _, pod := range pods.Items {
podIP := pod.Status.PodIP
metricsOutput, err := k8s.RunKubectlAndGetOutputE(t, ctx.KubectlOptions(t), "exec", "deploy/"+StaticClientName, "--", "curl", "--silent", "--show-error", fmt.Sprintf("http://%s:20200/metrics", podIP))
require.NoError(t, err)
require.Contains(t, metricsOutput, metricsAssertion)
}
}
//func assertGatewayMetricsEnabled(t *testing.T, ctx environment.TestContext, ns, label, metricsAssertion string) {
// pods, err := ctx.KubernetesClient(t).CoreV1().Pods(ns).List(context.Background(), metav1.ListOptions{LabelSelector: fmt.Sprintf("component=%s", label)})
// require.NoError(t, err)
// for _, pod := range pods.Items {
// podIP := pod.Status.PodIP
// metricsOutput, err := k8s.RunKubectlAndGetOutputE(t, ctx.KubectlOptions(t), "exec", "deploy/"+StaticClientName, "--", "curl", "--silent", "--show-error", fmt.Sprintf("http://%s:20200/metrics", podIP))
// require.NoError(t, err)
// require.Contains(t, metricsOutput, metricsAssertion)
// }
//}
7 changes: 5 additions & 2 deletions acceptance/tests/snapshot-agent/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package snapshotagent

import (
"fmt"
"os"
"testing"

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

func TestMain(m *testing.M) {
suite = testsuite.NewSuite(m)
os.Exit(suite.Run())
fmt.Println("Skipping snapshot agent tests because it's not supported with agentless yet")
os.Exit(0)
//suite = testsuite.NewSuite(m)
//os.Exit(suite.Run())
}
7 changes: 5 additions & 2 deletions acceptance/tests/sync/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sync

import (
"fmt"
"os"
"testing"

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

func TestMain(m *testing.M) {
suite = testsuite.NewSuite(m)
os.Exit(suite.Run())
fmt.Println("Skipping sync catalog tests because it's not supported with agentless yet")
os.Exit(0)
//suite = testsuite.NewSuite(m)
//os.Exit(suite.Run())
}
7 changes: 5 additions & 2 deletions acceptance/tests/terminating-gateway/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package terminatinggateway

import (
"fmt"
"os"
"testing"

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

func TestMain(m *testing.M) {
suite = testsuite.NewSuite(m)
os.Exit(suite.Run())
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())
}
7 changes: 5 additions & 2 deletions acceptance/tests/vault/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vault

import (
"fmt"
"os"
"testing"

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

func TestMain(m *testing.M) {
suite = testsuite.NewSuite(m)
os.Exit(suite.Run())
fmt.Println("Skipping vault tests because it's not supported with agentless yet")
os.Exit(0)
//suite = testsuite.NewSuite(m)
//os.Exit(suite.Run())
}
Loading

0 comments on commit c897e70

Please sign in to comment.