Skip to content

Discover, link, and resolve services in Kubernetes (Inspired by Hashicorp Consul)

License

Notifications You must be signed in to change notification settings

hayk96/kubebridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KubeBridge
KubeBridge

Discover, bridge, and resolve services in Kubernetes

Build Release Latest Release Github stars Github forks Github issues Docker Stars Docker Pulls Docker Image Size

Table of Contents
  1. About The Project
  2. Architecture Overview
  3. Components
  4. Features
  5. Installation
  6. Configuration
  7. Resolve KubeBridge DNS requests in Kubernetes
  8. CoreDNS configuration
  9. KubeDNS configuration
  10. Roadmap
  11. Author and Maintainer
  12. License

About The Project

KubeBridge is a Kubernetes-native service discovery and DNS resolution tool that simplifies cross-namespace service communication within a cluster. It automatically maps Kubernetes services to DNS records in real-time, enabling continuous service discovery and resolution without manual configuration.

Architecture Overview

Components

  • Sync - Continuously syncs and maps Kubernetes services with DNS records real-time.
  • DNS - Resolves service names to Kubernetes service IP addresses.
  • Redis - A Pub/Sub messaging system for K8s service discovery used by Sync and DNS apps.

Features

  • Service Discovery: Automatically registers Kubernetes services and makes them resolvable via DNS.
  • DNS Resolution: Services can be queried using *.kube.bridge domain (e.g., my-service.kube.bridge) without specifying namespace.
  • Custom DNS Configuration: Supports overriding or adding new Kubernetes DNS settings for advanced use cases.

Installation

KubeBridge can be installed using Helm. The following steps will guide you through the installation process.

helm repo add kubebridge https://hayk96.github.io/kubebridge
helm repo update
helm install kubebridge kubebridge/kubebridge -n kubebridge --create-namespace --devel

Configuration

Sync

Service discovery by namespace

With the following configuration, KubeBridge will sync all services from all namespaces except kube-system and kube-public.

sync:
  allowNamespaces: ["*"]
  denyNamespaces: ["kube-system", "kube-public"]

Service discovery by service type

With the following configuration, KubeBridge will sync services with the specified service types only.

sync:
  allowServiceTypes:
    - NodePort
    - ClusterIP
    - LoadBalancer

Service discovery by service annotations

Service synchronization can be controlled based on service annotations. If the annotation kubebridge.io/service-sync is set to true on a service, that service will be explicitly synced with KubeBridge. Setting the value to false will disable the service sync.

apiVersion: v1
kind: Service
metadata:
  name: example-service
  annotations:
    kubebridge.io/service-sync: "true"
spec:
  selector:
    app: example-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: ClusterIP

DNS

Search domain

Service names can be resolved using the *.kube.bridge domain.

dns:
  domain: kube.bridge

Custom DNS configuration

Custom DNS configuration can be set to map service names to IP addresses.

dns:
  extraDNSConfig: |
    {
      "A": {
        "kubebridge.io.": [
          "127.0.0.1"
        ]
      },
      "CNAME": {
        "kube-bridge.io": "kubebridge.io."
      }
    }

Resolve KubeBridge DNS requests in Kubernetes

Depending on the DNS server used in the cluster, you can apply the following configurations to resolve KubeBridge DNS requests. To configure CoreDNS or KubeDNS, you'll first need the ClusterIP of the kubebridge-dns service created by the Helm chart.

$ kubectl -n kubebridge get svc kubebridge-dns --output jsonpath='{.spec.clusterIP}'
10.96.244.221

CoreDNS configuration

For CoreDNS, you need to update the existing coredns ConfigMap in the kube-system namespace to include a forward definition for kubebridge, pointing to the cluster IP of the kubebridge-dns service.

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns
  namespace: kube-system
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . 172.16.0.1
        cache 30
        loop
        reload
        loadbalance
    }
    kube.bridge: |  
      kube.bridge:53 {  
        errors  
        cache 30  
        forward . 10.96.244.221
        reload  
      }

KubeDNS configuration

The following example ConfigMap manifest for kube-dns includes a stubDomains configuration that sets resolver for the domain kube.bridge.

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
  name: kube-dns
  namespace: kube-system
data:
  stubDomains: |
    {
      "kube.bridge": [
        "10.96.244.221"
      ]
    }

Roadmap

  • Support exporting Prometheus metrics.
  • Support Kubernetes CRDs to manage custom DNS configurations.
  • Support traffic management for service discovery.

Author and Maintainer

Hayk Davtyan:

License

MIT License, see LICENSE.