![Page 1: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/1.jpg)
Service Discovery in OSGi
Beyond the JVM using Docker and Consul
![Page 2: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/2.jpg)
About me
CTO @ Dexels
Architect at Sendrato Wearables
OSGi tinkerer
NoSQL advocate
![Page 3: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/3.jpg)
Service Discovery
• As old as distributed systems
• Find system components
• Prevent hard-coding network addresses
• Important for micro service architectures
![Page 4: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/4.jpg)
Service Discovery
• Finding services by exploring systems
• Use a well-known central registry where every service registers
![Page 5: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/5.jpg)
Service Repository
• Watch out for a single point of failure
• Distributed key-value stores
• Low volume
• Resilience and availability are most important
![Page 6: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/6.jpg)
Service Discovery (SOA)
• Can change providers at will
• Access to many 3rd party services
• Services go shopping for other services
• Services can respond to ‘markets’
![Page 7: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/7.jpg)
Docker containers
• Light-weight virtual machine
• Process with a filesystem and a network
• Universal, polyglot application deployment mechanism
• DockerHub image store
![Page 8: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/8.jpg)
Mini demo
![Page 9: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/9.jpg)
Docker from a service perspective
• An image
• An id
• Exposed ports
• ENV variables (& labels since Docker 1.6)
![Page 10: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/10.jpg)
Docker
• Makes reasoning about services much easier
![Page 11: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/11.jpg)
Docker
• Restful HTTP daemon on each host
• CLI tools use the HTTP interface to the daemon
![Page 12: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/12.jpg)
Service discovery
So how do we ‘discover’ these services?
We ask the Docker daemon
![Page 13: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/13.jpg)
What’s missing?
HostIp: 192.168.59.103
HostPort: 49212
ContainerPort: 3306
Protocol: TCP
… we need more metadata
![Page 14: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/14.jpg)
Metadata• Which service is this (name, tags)
• What protocol? How do I consume the service?
We can add them as environment parameters
![Page 15: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/15.jpg)
Monitor the Docker Daemon
• Completely generic
• No need for a registry
• Only require a few ‘annotations’
![Page 16: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/16.jpg)
This was the easy part
![Page 17: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/17.jpg)
Dynamic Services
• Any service can just appear
• Multiple instances can appear
• Instances can disappear without warning
• Service cascades
![Page 18: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/18.jpg)
OSGi
• Java based dynamic service framework
• Since 1999
• Initially for embedded systems
• Now very popular in cloud deployments
![Page 19: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/19.jpg)
OSGi• Central ‘Service Bus’
• Any Java object can be registered as a service
• Code can redeploy on the fly
• Services can come and go dynamically
• Services can depend on other services
![Page 20: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/20.jpg)
Docker & OSGi
• Monitor the Docker daemon
• Inject into OSGi
![Page 21: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/21.jpg)
Docker & OSGi
• Mismatch between Java objects and Docker connection data
• The Docker ‘monitor’ won’t know what a service is really about
![Page 22: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/22.jpg)
Configuration Admin
• Create Configuration objects based on docker data
• Leave the actual interpretation to ‘driver bundles’
![Page 23: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/23.jpg)
Docker
Container
Container
OSGi Environment
Config
Config
Bridge
Factory
Instance
Instance
![Page 24: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/24.jpg)
Another demo!
![Page 25: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/25.jpg)
Limitations
• Single host*
• Docker API Security
• Scalability
![Page 26: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/26.jpg)
Consul• Distributed Key/Value configuration store
• Like Etcd or Zookeeper
• Very robust for node failure
• But specifically built for Service Discovery
• Nice web UI
![Page 27: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/27.jpg)
ConsulDocker
Container
ContainerContainer
OSGi Environment
Config
ConfigConfig
Consul Bridge
Consul Cluster
Node
NodeNode
Host Bridge
![Page 28: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/28.jpg)
Final demo!
![Page 29: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/29.jpg)
Future work
• Conventions on metadata would be nice
• Better security model for Docker
• Use other sources of configuration like Kubernetes
![Page 30: Service Discovery in OSGi - 2015.javacro.hr · Beyond the JVM using Docker and Consul. About me CTO @ Dexels Architect at Sendrato Wearables OSGi tinkerer NoSQL advocate. ... Service](https://reader036.vdocument.in/reader036/viewer/2022063017/5fd7674b0e2e5901df2bf307/html5/thumbnails/30.jpg)
Thank [email protected]
Twitter @lyaruu
Tasman: https://github.com/flyaruu/tasman
Blog: http://www.codemonkey.nl/