2018-10-03 19:37:53 +00:00
|
|
|
package envoy
|
|
|
|
|
|
|
|
type templateArgs struct {
|
|
|
|
ProxyCluster, ProxyID string
|
2018-10-09 09:57:26 +00:00
|
|
|
AgentAddress string
|
|
|
|
AgentPort string
|
2018-10-03 19:37:53 +00:00
|
|
|
AgentTLS bool
|
|
|
|
AgentCAFile string
|
|
|
|
AdminBindAddress string
|
|
|
|
AdminBindPort string
|
|
|
|
LocalAgentClusterName string
|
|
|
|
Token string
|
|
|
|
}
|
|
|
|
|
2018-10-09 09:57:26 +00:00
|
|
|
const bootstrapTemplate = `{
|
2018-10-05 20:08:01 +00:00
|
|
|
"admin": {
|
|
|
|
"access_log_path": "/dev/null",
|
|
|
|
"address": {
|
|
|
|
"socket_address": {
|
|
|
|
"address": "{{ .AdminBindAddress }}",
|
|
|
|
"port_value": {{ .AdminBindPort }}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"node": {
|
|
|
|
"cluster": "{{ .ProxyCluster }}",
|
|
|
|
"id": "{{ .ProxyID }}"
|
|
|
|
},
|
|
|
|
"static_resources": {
|
|
|
|
"clusters": [
|
|
|
|
{
|
|
|
|
"name": "{{ .LocalAgentClusterName }}",
|
|
|
|
"connect_timeout": "1s",
|
|
|
|
"type": "STATIC",
|
2018-10-09 09:57:26 +00:00
|
|
|
{{- if .AgentTLS -}}
|
2018-10-05 20:08:01 +00:00
|
|
|
"tls_context": {
|
|
|
|
"common_tls_context": {
|
|
|
|
"validation_context": {
|
|
|
|
"trusted_ca": {
|
|
|
|
"filename": "{{ .AgentCAFile }}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{{- end }}
|
|
|
|
"http2_protocol_options": {},
|
|
|
|
"hosts": [
|
|
|
|
{
|
|
|
|
"socket_address": {
|
2018-10-09 09:57:26 +00:00
|
|
|
"address": "{{ .AgentAddress }}",
|
|
|
|
"port_value": {{ .AgentPort }}
|
2018-10-05 20:08:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"dynamic_resources": {
|
|
|
|
"lds_config": { "ads": {} },
|
|
|
|
"cds_config": { "ads": {} },
|
|
|
|
"ads_config": {
|
|
|
|
"api_type": "GRPC",
|
|
|
|
"grpc_services": {
|
|
|
|
"initial_metadata": [
|
|
|
|
{
|
|
|
|
"key": "x-consul-token",
|
|
|
|
"value": "{{ .Token }}"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"envoy_grpc": {
|
|
|
|
"cluster_name": "{{ .LocalAgentClusterName }}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-03 19:37:53 +00:00
|
|
|
`
|