/kube-consul-registrator

Consul service registrator for Kubernetes pod

Primary LanguageC#MIT LicenseMIT

dockeri.co

.NET Core CodeFactor codecov release docker

kube-consul-registrator

What is the kub-consul-registrator?

kube-consul-registrator is the service that can handle consul registration and deregistration while kube-consul-registrator run into the Kubernetes cluster.

Getting Started

Prerequisites

Environment variables

Envrionment variable Explaination Example
CONSUL_ADDRESS Consul address in the cluster "consul:8500"
KUBE_ALLOWED_NAMESPACES Namespaces to register pods "default,namespace1"

Annotations

These are annotation samples when you want to add a pod in the consul. You should add this annotations on the metadata of a pod. (Do not add this on the metadata of Deployment, ReplicaSet, StatefulSet, and DaemonSet)

consul-registrator/enabled: <true|false>
consul-registrator/service-id: <string>
consul-registrator/service-name: <string>
consul-registrator/service-port: <string>
consul-registrator/service-tag: <string[]>
consul-registrator/service-meta-<key>: <value>

Kubernetes definistion example

apiVersion: apps/v1
kind: Deployment
metadata:
  name: consul-register-deployment
  namespace: default
spec:
  selector:
    matchLabels:
      component: consul-register
  replicas: 1
  template:
    metadata:
      labels:
        component: consul-register
      annotations:
        consul-registrator/enabled: true
        consul-registrator/service-id: foo
        consul-registrator/service-name: bar
        consul-registrator/service-port: 80
        consul-registrator/service-tag: "tag1,tag2"         # comma separated string
        consul-registrator/service-meta-type: "test"           # add metadata [type:test]
    spec:
      serviceAccountName: consul-register
      containers:
      - name: consul-register
        image: coolexplorer/kube-consul-registrator:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 80
        env:
        - name: CONSUL_ADDRESS
          value: "consul:8500"
        - name: KUBE_ALLOWED_NAMESPACES
          value: "qe-tools,monitoring"
        - name : Logging__LogLevel__Default
          value: "Debug"

Installing

To use this service, you need to create kube-consul-registrator pod with authorization to get the cluster information from the cluster. Please refer to the files that I added in the repository.

Built With

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details