example

package
v0.0.0-...-d64db01 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 31 Imported by: 0

README

Example xDS Server

This is an example of a trivial xDS V3 control plane server. It serves an Envoy configuration that's roughly equivalent to the one used by the Envoy "Quick Start" docs: a simple http proxy. You can run the example using the project top-level Makefile, e.g.:

go-control-plane$ make example

The Makefile builds the example server and then runs build/example.sh which runs both Envoy and the example server. The example server serves a configuration defined in internal/example/resource.go. If everything works correctly, you should be able to open a browser to http://localhost:10000 and see Envoy's website.

Files

  • main/main.go is the example program entrypoint. It instantiates the cache and xDS server and runs the xDS server process.
  • resource.go generates a Snapshot structure which describes the configuration that the xDS server serves to Envoy.
  • server.go runs the xDS control plane server.
  • logger.go implements the pkg/log/Logger interface which provides logging services to the cache.

Documentation

Overview

Copyright 2020 Envoyproxy Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2020 Envoyproxy Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2020 Envoyproxy Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

View Source
const (
	UserClusterName  = "user_proxy_cluster"
	RouteName        = "local_route"
	ListenerName     = "listener_0"
	ListenerPort     = 10000
	UserUpstreamHost = "192.168.65.2"
	UserUpstreamPort = 8081

	TempHandlerClusterName = "temphandler_cluster"

	MiddlewareClusterName = "middleware_cluster"
)

Variables

View Source
var MiddlewareUpsteamHost string
View Source
var MiddlewareUpsteamPort uint32
View Source
var TempHandlerUpsteamHost string
View Source
var TempHandlerUpsteamPort uint32

Functions

func GenerateOriginalSnapshot

func GenerateOriginalSnapshot() cache.Snapshot

func GenerateSnapshot

func GenerateSnapshot(tokenMap map[string]SingleRouteInfo) cache.Snapshot

func GenerateTestSnapshot

func GenerateTestSnapshot(num int) cache.Snapshot

func InitFixedInfo

func InitFixedInfo() error

func RunKServer

func RunKServer(updateSignal *serverv3.UpdateSignal, cache cachev3.SnapshotCache)

func RunServer

func RunServer(ctx context.Context, srv3 serverv3.Server, port uint)

RunServer starts an xDS server at the given port.

Types

type FixedInfo

type FixedInfo struct {
	TempHandlerUpsteamHost string
	TempHandlerUpsteamPort uint32
	MiddlewareUpsteamHost  string
	MiddlewareUpsteamPort  uint32
}

type Logger

type Logger struct {
	Debug bool
}

An example of a logger that implements `pkg/log/Logger`. Logs to stdout. If Debug == false then Debugf() and Infof() won't output anything.

func (Logger) Debugf

func (logger Logger) Debugf(format string, args ...interface{})

Log to stdout only if Debug is true.

func (Logger) Errorf

func (logger Logger) Errorf(format string, args ...interface{})

Log to stdout always.

func (Logger) Infof

func (logger Logger) Infof(format string, args ...interface{})

Log to stdout only if Debug is true.

func (Logger) Warnf

func (logger Logger) Warnf(format string, args ...interface{})

Log to stdout always.

type SingleRouteInfo

type SingleRouteInfo struct {
	// contains filtered or unexported fields
}

type SnapshotFeed

type SnapshotFeed struct {
	// contains filtered or unexported fields
}

func GenerateOriginalSnapshotFeed

func GenerateOriginalSnapshotFeed() SnapshotFeed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL