Consul
Discover services with Consul on Kubernetes
This page provides an overview of Consul service discovery operations when running on Kubernetes.
Use KubeDNS to perform service discovery operations by default. If you use Consul's service mesh features and prefer to use KubeDNS, refer to onboard services in transparent proxy mode.
Introduction
Kubernetes deployments support Consul's service discovery features. When running Consul on Kubernetes, you can adopt either of the following service discovery strategies:
- Configure Kubernetes to use Consul DNS
- Use KubeDNS to resolve DNS addresses and manage service discovery in your employment
You can also use the kubectl exec
command to connect directly to a Consul container and interact with Consul's service discovery features.
If you use KubeDNS with Consul's service mesh enabled, you must also configure transparent proxy mode to enable permissive mTLS between services.
Application load balancing
A load balancer accepts incoming traffic requests and routes them to service instances in a distributed network so that resource consumption is spread between available instances and individual nodes are not overworked. Consul functions as a load balancer by directing traffic to healthy service instances using information registered to the catalog and Consul DNS. Consul can also integrate with external load balancers such as NGINX and HAProxy.
Load balancing is a core component of Consul's service discovery functionality. For more information, refer to service discovery overview.
Static lookups
To lookup details about registered services and specific service instances, perform a static query using Consul DNS to return A and SRV records for your deployment. Consul DNS enables you to return results from across your Consul deployment, including the number of healthy instances and network addresses of nodes that match service names or custom tags.
Consul Enterprise enables static lookups for Enterprise features such as virtual services and sameness groups. Refer to Perform static DNS queries for more information.
Prepared queries
Prepared queries are configurations that enable you to register a complex service query and perform dynamic lookups on services using Consul DNS. Prepared queries enable advanced lookup scenarios such filtering by multiple tags and returning services that match a prefix. You can also use prepared queries to implement service failover scenarios between datacenters.
For more information, refer to Perform dynamic service lookups with prepared queries.
Runtime specific usage documentation
For runtime-specific guidance, refer to the following pages:
Reference documentation
For reference material related to Consul's service discovery functions on Kubernetes, refer to the following pages:
Constraints, limitations, and troubleshooting
If you experience errors when using Consul's service discovery features, refer to the following list of technical constraints.
- Consul's DNS and service discovery features are enabled by default. When Consul service mesh is enabled, you can use an existing DNS such as CoreDNS by configuring Consul's transparent proxy. Refer to transparent proxy for more information.
- When Consul's service mesh is enabled, you can use configuration entries that have additional impacts on Consul's service discovery behavior:
- You can customize Consul's load balancing policy using a service resolver configuration entry.
- You can adjust the request rate for services using a service defaults configuration entry.