1# xDS Bootstrap File Format in gRPC 2 3This document specifies the xDS bootstrap file format supported by gRPC. 4 5## Background 6 7gRPC expects the xDS bootstrap configuration to be specified as a JSON string. 8The xDS bootstrap file location may be specified using the environment variable 9`GRPC_XDS_BOOTSTRAP`. Alternatively, the bootstrap file contents may be 10specified using the environment variable `GRPC_XDS_BOOTSTRAP_CONFIG`. If both 11are specified, the former takes precedence. 12 13The xDS client inside of gRPC parses the bootstrap configuration specified by 14one of the above means when it is created to configure itself. 15 16The following sections describe the bootstrap file format, including links to 17gRFCs where support for appropriate fields was added. 18 19## File Format 20 21``` 22{ 23 // The xDS server to talk to. The value is an ordered array of server 24 // configurations, to support failing over to a secondary xDS server if the 25 // primary is down. 26 // 27 // Prior to gRFC A71, all but the first entry was ignored. 28 "xds_servers": [ 29 { 30 31 // A target URI string suitable for creating a gRPC channel. 32 "server_uri": <string containing the target URI of xds server>, 33 34 // List of channel creds; client will stop at the first type it 35 // supports. This field is required and must contain at least one 36 // channel creds type that the client supports. 37 // 38 // See section titled "Supported Channel Credentials". 39 "channel_creds": [ 40 { 41 "type": <string containing channel cred type>, 42 43 // The "config" field is optional; it may be missing if the 44 // credential type does not require config parameters. 45 "config": <JSON object containing config for the type> 46 } 47 ], 48 49 // A list of features supported by the server. New values will 50 // be added over time. For forward compatibility reasons, the 51 // client will ignore any entry in the list that it does not 52 // understand, regardless of type. 53 // 54 // See section titled "Supported Server Features". 55 "server_features": [ ... ] 56 } 57 ], 58 59 // Identifies a specific gRPC instance. 60 "node": { 61 62 // Opaque identifier for the gRPC instance. 63 "id": <string>, 64 65 // Identifier for the local service cluster where the gRPC instance is 66 // running. 67 "cluster": <string>, 68 69 // Specifies where the gRPC instance is running. 70 "locality": { 71 "region": <string>, 72 "zone": <string>, 73 "sub_zone": <string>, 74 }, 75 76 // Opaque metadata extending the node identifier. 77 "metadata": <JSON Object>, 78 } 79 80 // Map of supported certificate providers, keyed by the provider instance 81 // name. 82 // See section titled "Supported certificate providers". 83 "certificate_providers": { 84 85 // Certificate provider instance name, specified by the 86 // control plane, to fetch certificates from. 87 "<instance_name>": { 88 89 // Name of the plugin implementation. 90 "plugin_name": <string containing plugin type>, 91 92 // A JSON object containing the configuration for the plugin, whose schema 93 // is defined by the plugin. The "config" field is optional; it may be 94 // missing if the credential type does not require config parameters. 95 "config": <JSON object containing config for the type> 96 } 97 } 98 99 // A template for the name of the Listener resource to subscribe to for a gRPC 100 // server. If the token `%s` is present in the string, all instances of the 101 // token will be replaced with the server's listening "IP:port" (e.g., 102 // "0.0.0.0:8080", "[::]:8080"). 103 "server_listener_resource_name_template": "example/resource/%s", 104 105 // A template for the name of the Listener resource to subscribe to for a gRPC 106 // client channel. Used only when the channel is created with an "xds:" URI 107 // with no authority. 108 // 109 // If starts with "xdstp:", will be interpreted as a new-style name, in which 110 // case the authority of the URI will be used to select the relevant 111 // configuration in the "authorities" map. 112 // 113 // The token "%s", if present in this string, will be replaced with the 114 // service authority (i.e., the path part of the target URI used to create the 115 // gRPC channel). If the template starts with "xdstp:", the replaced string 116 // will be percent-encoded. In that case, the replacement string must include 117 // only characters allowed in a URI path as per RFC-3986 section 3.3 (which 118 // includes '/'), and all other characters must be percent-encoded. 119 // 120 // Defaults to "%s". 121 "client_default_listener_resource_name_template": <string>, 122 123 // A map of authority name to corresponding configuration. 124 // 125 // This is used in the following cases: 126 // - A gRPC client channel is created using an "xds:" URI that includes 127 // an authority. 128 // - A gRPC client channel is created using an "xds:" URI with no 129 // authority, but the "client_default_listener_resource_name_template" 130 // field turns it into an "xdstp:" URI. 131 // - A gRPC server is created and the 132 // "server_listener_resource_name_template" field is an "xdstp:" URI. 133 // 134 // In any of those cases, it is an error if the specified authority is 135 // not present in this map. 136 "authorities": { 137 // Entries are keyed by authority name. 138 // Note: If a new-style resource name has no authority, we will use 139 // the empty string here as the key. 140 "<authority_name>": { 141 142 // A template for the name of the Listener resource to subscribe 143 // to for a gRPC client channel. Used only when the channel is 144 // created using an "xds:" URI with this authority name. 145 // 146 // The token "%s", if present in this string, will be replaced 147 // with percent-encoded service authority (i.e., the path part of the 148 // target URI used to create the gRPC channel). The replacement string 149 // must include only characters allowed in a URI path as per RFC-3986 150 // section 3.3 (which includes '/'), and all other characters must be 151 // percent-encoded. 152 // 153 // Must start with "xdstp://<authority_name>/". If it does not, 154 // that is considered a bootstrap file parsing error. 155 // 156 // If not present in the bootstrap file, defaults to 157 // "xdstp://<authority_name>/envoy.config.listener.v3.Listener/%s". 158 "client_listener_resource_name_template": <string>, 159 160 // Ordered list of xDS servers to contact for this authority. 161 // Format is exactly the same as the top level "xds_servers" field. 162 // 163 // If the same server is listed in multiple authorities, the 164 // entries will be de-duped (i.e., resources for both authorities 165 // will be fetched on the same ADS stream). 166 // 167 // If not specified, the top-level server list is used. 168 "xds_servers": [ ... ] 169 } 170 } 171} 172``` 173 174### Supported Channel Credentials 175 176gRPC supports the following channel credentials as part of the `channel_creds` 177field of `xds_servers`. 178 179#### Insecure credentials 180 181- **Type Name**: `insecure` 182- **Config**: Accepts no configuration 183 184#### Google Default credentials 185 186- **Type Name**: `google_default` 187- **Config**: Accepts no configuration 188 189#### mTLS credentials 190 191- **Type Name**: `tls` 192- **Config**: As described in [gRFC A65](a65): 193``` 194{ 195 // Path to CA certificate file. 196 // If unset, system-wide root certs are used. 197 "ca_certificate_file": <string>, 198 199 // Paths to identity certificate file and private key file. 200 // If either of these fields are set, both must be set. 201 // If set, mTLS will be used; if unset, normal TLS will be used. 202 "certificate_file": <string>, 203 "private_key_file": <string>, 204 205 // How often to re-read the certificate files. 206 // Value is the JSON format described for a google.protobuf.Duration 207 // message in https://protobuf.dev/programming-guides/proto3/#json. 208 // If unset, defaults to "600s". 209 "refresh_interval": <string> 210} 211``` 212 213### Supported Certificate Provider Instances 214 215gRPC supports the following Certificate Provider instances as part of the 216`certificate_providers` field: 217 218#### PEM file watcher 219 220- **Plugin Name**: `file_watcher` 221- **Config**: As described in [gRFC A29](a29): 222``` 223{ 224 "certificate_file": "<path to the certificate file in PEM format>", 225 "private_key_file": "<path to private key file in PEM format>", 226 "ca_certificate_file": "<path to CA certificate file in PEM format>", 227 "refresh_interval": "<JSON form of google.protobuf.Duration>" 228} 229``` 230 231### Supported Server Features 232 233gRPC supports the following server features in the `server_features` field 234inside `xds_servers`: 235- `xds_v3`: Added in gRFC A30. Supported in older versions of gRPC. See 236[here](grpc_xds_features.md) for when gRPC added support for xDS transport 237protocol v3, and when support for xDS transport protocol v2 was dropped. 238- `ignore_resource_deletion`: Added in [gRFC A53](a53) 239 240 241### When were fields added? 242 243| Bootstrap Field | Relevant gRFCs 244------------------|--------------- 245`xds_servers` | [A27](a27), [A71](a71) 246`google_default` channel credentials | [A27](a27) 247`insecure` channel credentials | [A27](a27) 248`node` | [A27](a27) 249`certificate_providers` | [A29](a29) 250`file_watcher`certificate provider | [A29](a29) 251`xds_servers.server_features` | [A30](a30) 252`server_listener_resource_name_template` | [A36](a36), [A47](a47) 253`client_default_listener_resource_name_template` | [A47](a47) 254`authorities` | [A47](a47) 255`tls` channel credentials | [A65](a65) 256 257 258[a27]: https://github.com/grpc/proposal/blob/master/A27-xds-global-load-balancing.md 259[a29]: https://github.com/grpc/proposal/blob/master/A29-xds-tls-security.md#file_watcher-certificate-provider 260[a30]: https://github.com/grpc/proposal/blob/master/A30-xds-v3.md 261[a36]: https://github.com/grpc/proposal/blob/master/A36-xds-for-servers.md 262[a47]: https://github.com/grpc/proposal/blob/master/A47-xds-federation.md 263[a53]: https://github.com/grpc/proposal/blob/master/A53-xds-ignore-resource-deletion.md 264[a65]: https://github.com/grpc/proposal/blob/master/A65-xds-mtls-creds-in-bootstrap.md#proposal 265[a71]: https://github.com/grpc/proposal/blob/master/A71-xds-fallback.md