Skip to content

Commit

Permalink
internal: Drop support for v2 xDS resource version (projectcontour#3111)
Browse files Browse the repository at this point in the history
Drop support for xDS v3 resource version by changing the default
boostrap resource version to v3 and removing the v2 xDS resource server.

Updates projectcontour#1898

Signed-off-by: Steve Sloka <slokas@vmware.com>
  • Loading branch information
stevesloka authored Nov 10, 2020
1 parent 315ada8 commit 2885e38
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 1,397 deletions.
2 changes: 1 addition & 1 deletion cmd/contour/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ func registerBootstrap(app *kingpin.Application) (*kingpin.CmdClause, *envoy.Boo
bootstrap.Flag("envoy-cert-file", "Client certificate filename for Envoy secure xDS gRPC communication.").Envar("ENVOY_CERT_FILE").StringVar(&config.GrpcClientCert)
bootstrap.Flag("envoy-key-file", "Client key filename for Envoy secure xDS gRPC communication.").Envar("ENVOY_KEY_FILE").StringVar(&config.GrpcClientKey)
bootstrap.Flag("namespace", "The namespace the Envoy container will run in.").Envar("CONTOUR_NAMESPACE").Default("projectcontour").StringVar(&config.Namespace)
bootstrap.Flag("xds-resource-version", "The versions of the xDS resources to request from Contour.").Default("v2").StringVar((*string)(&config.XDSResourceVersion))
bootstrap.Flag("xds-resource-version", "The versions of the xDS resources to request from Contour.").Default("v3").StringVar((*string)(&config.XDSResourceVersion))
return bootstrap, &config
}
13 changes: 2 additions & 11 deletions cmd/contour/contour.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ import (

resource "github.com/envoyproxy/go-control-plane/pkg/resource/v2"
"github.com/projectcontour/contour/internal/build"
envoy_v2 "github.com/projectcontour/contour/internal/envoy/v2"
envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3"
"github.com/projectcontour/contour/internal/k8s"
"github.com/projectcontour/contour/pkg/config"
"github.com/sirupsen/logrus"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
Expand Down Expand Up @@ -75,15 +73,8 @@ func main() {
if err != nil {
log.WithError(err).Fatal("failed to parse bootstrap args")
}
switch bootstrapCtx.XDSResourceVersion {
case config.XDSv3:
if err := envoy_v3.WriteBootstrap(bootstrapCtx); err != nil {
log.WithError(err).Fatal("failed to write bootstrap configuration")
}
default:
if err := envoy_v2.WriteBootstrap(bootstrapCtx); err != nil {
log.WithError(err).Fatal("failed to write bootstrap configuration")
}
if err := envoy_v3.WriteBootstrap(bootstrapCtx); err != nil {
log.WithError(err).Fatal("failed to write bootstrap configuration")
}
case certgenApp.FullCommand():
doCertgen(certgenConfig, log)
Expand Down
14 changes: 0 additions & 14 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"time"

envoy_auth_v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2/auth"
envoy_server_v2 "github.com/envoyproxy/go-control-plane/pkg/server/v2"
envoy_server_v3 "github.com/envoyproxy/go-control-plane/pkg/server/v3"
contour_api_v1 "github.com/projectcontour/contour/apis/projectcontour/v1"
"github.com/projectcontour/contour/internal/annotation"
Expand All @@ -40,7 +39,6 @@ import (
"github.com/projectcontour/contour/internal/timeout"
"github.com/projectcontour/contour/internal/workgroup"
"github.com/projectcontour/contour/internal/xds"
contour_xds_v2 "github.com/projectcontour/contour/internal/xds/v2"
contour_xds_v3 "github.com/projectcontour/contour/internal/xds/v3"
"github.com/projectcontour/contour/internal/xdscache"
xdscache_v2 "github.com/projectcontour/contour/internal/xdscache/v2"
Expand Down Expand Up @@ -563,20 +561,8 @@ func doServe(log logrus.FieldLogger, ctx *serveContext) error {
v3cache := contour_xds_v3.NewSnapshotCache(false, log)
snapshotHandler.AddSnapshotter(v3cache)
contour_xds_v3.RegisterServer(envoy_server_v3.NewServer(context.Background(), v3cache, nil), grpcServer)

// Check an internal feature flag to disable xDS v2 endpoints. This is strictly for testing.
if config.GetenvOr("CONTOUR_INTERNAL_DISABLE_XDSV2", "N") == "N" {
v2cache := contour_xds_v2.NewSnapshotCache(false, log)
snapshotHandler.AddSnapshotter(v2cache)
contour_xds_v2.RegisterServer(envoy_server_v2.NewServer(context.Background(), v2cache, nil), grpcServer)
}
case config.ContourServerType:
contour_xds_v3.RegisterServer(contour_xds_v3.NewContourServer(log, xdscache.ResourcesOf(resources)...), grpcServer)

// Check an internal feature flag to disable xDS v2 endpoints. This is strictly for testing.
if config.GetenvOr("CONTOUR_INTERNAL_DISABLE_XDSV2", "N") == "N" {
contour_xds_v2.RegisterServer(contour_xds_v2.NewContourServer(log, xdscache.ResourcesOf(resources)...), grpcServer)
}
default:
// This can't happen due to config validation.
log.Fatalf("invalid xDS server type %q", ctx.Config.Server.XDSServerType)
Expand Down
4 changes: 2 additions & 2 deletions internal/envoy/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ type BootstrapConfig struct {
// Defaults to 127.0.0.1.
XDSAddress string

// XDSGRPCPort is the management server port that provides the v2 gRPC API.
// XDSGRPCPort is the management server port that provides the v3 gRPC API.
// Defaults to 8001.
XDSGRPCPort int

// XDSResourceVersion defines the XDS Server Version to use.
// Defaults to "v2"
// Defaults to "v3"
XDSResourceVersion config.ResourceVersion

// Namespace is the namespace where Contour is running
Expand Down
Loading

0 comments on commit 2885e38

Please sign in to comment.