Sign inSign up

fpco/consul-service-mapper

By fpco

Updated almost 9 years ago

Register Kubernetes services with Consul.

Image
0

257

fpco/consul-service-mapper repository overview

consul-service-mapper

Register Kubernetes services with Consul.

This registers Kubernetes load balancer services that have the correct label (default dns: consul) and annotation (default consul.io/service) as external services with Consul. Each Kubernetes load balancer is registered as a Consul node with the load balancer endpoint as its address, and a Consul service is registered as the Kubernetes annotation value for its name and the Kubernetes service's first port for its port. The following Consul node metadata values are also set: k8s_cluster, k8s_kind, k8s_name, k8s_namespace, and k8s_service_type.

Registered services can be looked up on Consul's DNS server as <<<SERVICE>>>.service.<<<DOMAIN>>> (where <<<DOMAIN>>> is Consul's domain, and <<<SERVICE>>> is the value of the annotation), for example myservice.service.consul.

Installation

Copy example-manifest.yaml and adjust the following environment variables, and then kubectl apply -f <<<MANIFEST>>>.yaml.

Environment variables
  • CLUSTER: Name of the Kubernetes cluster; Consul node names will be based on the cluster name to allow multiple Kubernetes clusters to register services with the same Consul (required)
  • CONSUL_URL: URL of Consul (default: http://consul:8500)
  • SELECTOR: Label selector to filter Kubernetes services to process (default dns=consul)
  • ANNOTATION: Annotation that specifies the Consul service name (default consul.io/service)

Example

Here's an example of a service that uses consul-service-mapper to register with Consul:

apiVersion: v1
kind: Service
metadata:
  name: myservice
  labels:
    app: myservice
    dns: consul
  annotations:
    consul.io/service: myservice
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: myservice
  type: LoadBalancer

Tag summary

Content type

Image

Digest

Size

22.4 MB

Last updated

almost 9 years ago

docker pull fpco/consul-service-mapper:0.0.2