D.I.Y. mesos framework part 1
I’ve covered Apache Mesos concepts in the past. Now let’s see it in action!
Setup
I’m using a Mac so I will provide setup steps for running a local Mesos slave and master.
Docker for Mac should also be installed and running.
Get your system’s IP: Apple
-> System Preferences
-> Network
. The IP address will show up in the upper right. Jot it down.
Now open 4 terminal windows and let’s begin.
Launch Mesos Master and Agent
Terminal 1: Launch a Mesos Master node:
Terminal 2: Launch a Mesos agent node:
Register a custom Mesos Framework
Here is where the fun begins. We will be using the Mesos HTTP Interface to create our Framework and manage tasks.
To create the Framework, we must use curl
or another tool that will keep the connection open. Why? The HTTP response to our framework-creation request is “chunked” from the Mesos Master, which results in a connection being left open for the remainder of the framework’s lifespan. Offers, task updates, and other communications with the Master node come across this connection for parsing by the framework. The effect is a “streaming” subscription to Mesos events.
NOTE: the “user” in this command must be the same as the output of a whoami
command in the terminal. This becomes important later for launching tasks.
Terminal 3:
We should see a “Subscribed” response from Mesos. Note the following fields in the response:
Immediately following the “Subscribed” event, we should see a “Offer”. This is Mesos letting us know about resources available on the agent node which we can use to launch our tasks. Note the following fields in the offer:
NOTE - the “id” of the offer is nested in the response at id.value
Now if we visit http://localhost:5050
and click on “Frameworks” we will see our framework listed. Nice! We have just registered a custom framework with Mesos.
Next time we will launch some tasks.