Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
xDS API をそのまま記述した例
{
"cds": {
"resources": [
{
"@type": "type.googleapis.com/envoy.api.v2.Cluster",
"circuit_breakers": {
"thresholds": [
{
"max_connections": 256,
"max_pending_requests": 512,
"max_retries": 2
}
]
},
"connect_timeout": "3s",
"dns_lookup_family": "V4_ONLY",
"load_assignment": {
"cluster_name": "upstream2",
"endpoints": [
{
"lb_endpoints": [
{
"endpoint": {
"address": {
"socket_address": {
"address": "upstream2.example.com",
"port_value": 80
}
}
}
}
]
}
]
},
"name": "upstream2",
"protocol_selection": "USE_DOWNSTREAM_PROTOCOL",
"type": "STRICT_DNS"
}
],
"type_url": "type.googleapis.com/envoy.api.v2.Cluster",
"version_info": "sample"
},
"rds": {
"resources": [
{
"@type": "type.googleapis.com/envoy.api.v2.RouteConfiguration",
"name": "sample",
"virtual_hosts": [
{
"domains": [
"upstream2"
],
"name": "upstream2",
"routes": [
{
"match": {
"headers": [
{
"name": ":method",
"safe_regex_match": {
"google_re2": { },
"regex": "(GET|HEAD)"
}
}
],
"prefix": "/"
},
"route": {
"auto_host_rewrite": true,
"cluster": "upstream2",
"retry_policy": {
"num_retries": 3,
"per_try_timeout": "3s",
"retry_on": "5xx,connect-failure,refused-stream"
},
"timeout": "10s"
}
},
{
"match": {
"prefix": "/"
},
"route": {
"auto_host_rewrite": true,
"cluster": "barbeque",
"timeout": "10s"
}
}
]
}
]
}
],
"type_url": "type.googleapis.com/envoy.api.v2.RouteConfiguration",
"version_info": "sample"
}
}
local xdsTemplate = import 'lib/xds_template.libsonnet';
local upstream2 = import 'lib/upstreams/upstream2.libsonnet';
local env = 'production';
local upstreams = [
upstream2,
];
xdsTemplate.generate(upstreams, env)
local cds = import '../cds.libsonnet';
local circuitBreakers = import '../circuit_breakers.libsonnet';
local rds = import '../rds.libsonnet';
local routes = import '../routes.libsonnet';
local name = 'upstream2';
local clusterNameProduction = 'upstream2-production';
{
production: {
rds: rds.default(name) {
routes: routes.default(clusterNameProduction),
},
cds: cds.lb(clusterNameProduction, '3s', 'upstream2.example.com', 80) {
circuit_breakers: circuitBreakers.default,
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.