bootstrap

package
v1.40.0-dev Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package bootstrap provides the functionality to initialize certain aspects of an xDS client by reading a bootstrap file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// BalancerName is the name of the management server to connect to.
	//
	// The bootstrap file contains a list of servers (with name+creds), but we
	// pick the first one.
	BalancerName string
	// Creds contains the credentials to be used while talking to the xDS
	// server, as a grpc.DialOption.
	Creds grpc.DialOption
	// TransportAPI indicates the API version of xDS transport protocol to use.
	// This describes the xDS gRPC endpoint and version of
	// DiscoveryRequest/Response used on the wire.
	TransportAPI version.TransportAPI
	// NodeProto contains the Node proto to be used in xDS requests. The actual
	// type depends on the transport protocol version used.
	NodeProto proto.Message
	// CertProviderConfigs contains a mapping from certificate provider plugin
	// instance names to parsed buildable configs.
	CertProviderConfigs map[string]*certprovider.BuildableConfig
	// ServerListenerResourceNameTemplate is a template for the name of the
	// Listener resource to subscribe to for a gRPC server. If the token `%s` is
	// present in the string, it will be replaced with the server's listening
	// "IP:port" (e.g., "0.0.0.0:8080", "[::]:8080"). For example, a value of
	// "example/resource/%s" could become "example/resource/0.0.0.0:8080".
	ServerListenerResourceNameTemplate string
}

Config provides the xDS client with several key bits of information that it requires in its interaction with the management server. The Config is initialized from the bootstrap file.

func NewConfig

func NewConfig() (*Config, error)

NewConfig returns a new instance of Config initialized by reading the bootstrap file found at ${GRPC_XDS_BOOTSTRAP}.

The format of the bootstrap file will be as follows:

{
   "xds_server": {
     "server_uri": <string containing URI of management server>,
     "channel_creds": [
       {
         "type": <string containing channel cred type>,
         "config": <JSON object containing config for the type>
       }
     ],
     "server_features": [ ... ],
   },
   "node": <JSON form of Node proto>,
   "certificate_providers" : {
     "default": {
       "plugin_name": "default-plugin-name",
       "config": { default plugin config in JSON }
      },
     "foo": {
       "plugin_name": "foo",
       "config": { foo plugin config in JSON }
     }
   },
   "server_listener_resource_name_template": "grpc/server?xds.resource.listening_address=%s"
}

Currently, we support exactly one type of credential, which is "google_default", where we use the host's default certs for transport credentials and a Google oauth token for call credentials.

This function tries to process as much of the bootstrap file as possible (in the presence of the errors) and may return a Config object with certain fields left unspecified, in which case the caller should use some sane defaults.

func NewConfigFromContents

func NewConfigFromContents(data []byte) (*Config, error)

NewConfigFromContents returns a new Config using the specified bootstrap file contents instead of reading the environment variable. This is only suitable for testing purposes.

Jump to

Keyboard shortcuts

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