Service defaults

Take a look at the following configuration, which is used to define protocol and gateway defaults for an existing service. These are identified through Name:

Kind = "service-defaults"
Name = "web"

Protocol = "http"

MeshGateway = {
mode = "local"
}

The preceding configuration is valid for both Kubernetes and non-Kubernetes environments. It is created automatically through the consul-connect-inject-init init-container when a Consul sidecar Envoy proxy is injected when a deployment is created. The following is an example of this:

Init Containers:
consul-connect-inject-init:

...

# Create the central config's service registration
cat <<EOF >/consul/connect-inject/central-config.hcl
kind = "service-defaults"
name = "web"
protocol = "http"
MeshGateway = {
mode = "local"
}

EOF

/bin/consul config write -cas -modify-index 0
/consul/connect-inject/central-config.hcl || true
...

However, for services running in a non-Kubernetes environment, service-defaults needs to be created manually or needs to be part of some automation. One of the interesting features of service-defaults is the use of the mesh gateway, which provides configuration so that individual services to failover from one data center to another or provide distributed services to act together through mutual TLS to provide a mesh of services that can span multiple zones/regions and hybrid configurations. 

proxy-defaults is used to provide defaults at the global level to enable the gateways for all Consul services. This can be seen in the following code:

Kind = "proxy-defaults"
Name = "global"
MeshGateway {
Mode = "local"
}

Remember that service defaults are configured automatically in a Kubernetes environment, as shown through init-containers while deploying a sidecar proxy. However, service-defaults need to be created manually for services in the VM environment.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.80.45