Code Monkey home page Code Monkey logo

ext-mdns-over-host-avahi's Introduction

ext-mdns-over-host-avahi

ext-mdns-over-host-avahi provides external Multicast DNS hostnames names to Kubernetes Services by leveraging the hosts avahi-daemon.

Summary

ext-mdns-over-host-avahi is targeted towards bare-metal Kubernetes clusters providing services on a home network (e.g. MicroK8s on a Raspberry Pi).

Services can be given an mDNS hostname by adding a mdns.johntrimble.com/hostname annotation to services of type=LoadBalancer. ext-mdns-over-host-avahi monitors services with this annotation and uses D-Bus to connect to the host's avahi-daemon to add appropriate address/hostname mappings making the hostnames resolvable on the local area network.

Prerequisites

  • avahi-daemon installed on kubernetes nodes
  • update any relevant AppArmor policies to allow access to D-Bus (I had to add 'dbus' to /etc/apparmor.d/cri-containerd.apparmor.d for MicroK8s)
  • a load balancer such as MetalLB

Quickstart

Install ext-mdns-over-host-avahi with:

microk8s kubectl apply -f https://raw.githubusercontent.com/johntrimble/ext-mdns-over-host-avahi/master/manifest.yaml

To test it, make an nginx deployment by putting the following in a file named example-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: my-nginx
  name: my-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-nginx
  template:
    metadata:
      labels:
        app: my-nginx
    spec:
      containers:
      - image: nginx
        name: nginx

Now apply it:

kubectl apply -f example-deployment.yaml

This will deploy nginx, but it will only be accessible withing the kubernetes cluster. To expose it on the network with an mDNS hostname, create a service like the following and save it to a file named example-service.yaml:

apiVersion: v1
kind: Service
metadata:
  annotations:
    mdns.johntrimble.com/hostname: foo.local
  labels:
    app: my-nginx
  name: my-nginx
spec:
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  selector:
    app: my-nginx
  type: LoadBalancer

Now apply it:

kubectl apply -f example-service.yaml

You should now be able to access the nginx welcome page by using the URL http://foo.local/.

ext-mdns-over-host-avahi's People

Contributors

johntrimble avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.