Discover, bridge, and resolve services in Kubernetes
Table of Contents
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.
- 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.
- 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.
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
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"]
With the following configuration, KubeBridge will sync services with the specified service types only.
sync:
allowServiceTypes:
- NodePort
- ClusterIP
- LoadBalancer
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
Service names can be resolved using the *.kube.bridge
domain.
dns:
domain: kube.bridge
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."
}
}
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
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
}
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"
]
}
- Support exporting Prometheus metrics.
- Support Kubernetes CRDs to manage custom DNS configurations.
- Support traffic management for service discovery.
Hayk Davtyan:
- Email - [email protected]
- GitHub - hayk96
MIT License, see LICENSE.