Learn how to Create a Remote Adapter

Our remote adapter model was designed so developers could use their preferred language, but so far, all of the remote adapters were written in Ruby. We recently released a Marathon Adapter using Go. After creating the Marathon Adapter, we split the codebase to provide developers an easy integration to their favorite orchestrator using Go. This article will explain the process of using the Panamax Adapter project to build a remote adapter.

Building an Adapter

Everything you need to create an adapter is outlined in the Adapter Developer Guide. An adapter must implement the REST interface methods described in the developer guide and be deployed within a container so the remote agent can communicate with it.

The Panamax Adapter library provides a server which already implements the adapter REST contract and an interface for developers code. Therefore, a development team using the Panamax Adapter has only two steps to create a working adapter.

Adapter Interface

Within the Panamax Adapter library an interface is provided which has the CRUD operations defined in the developer guide. A structure which implements these methods enables the integration between the Panamax Service definition and the orchestration system.

type PanamaxAdapter interface {
GetServices() ([]*Service, *Error)
GetService(string) (*Service, *Error)
CreateServices([]*Service) ([]*Service, *Error)
UpdateService(*Service) *Error
DestroyService(string) *Error

Hook in the Server

Once the interface has been implemented the final step is to hook it into the server. This simply is providing the adapter as a parameter to the server.

adapter := new(SampleAdapter)
server := pmxadapter.NewServer(adapter)
log.Printf("Starting Sample Adapter")
server.Start()

Go on a Diet

Once the previous tasks are complete and the adapter build successfully its time to create an image for deployment. The standard process will create an image of at least 500MB size using a Go base image. However, you can create the smallest image possible (~5mb) using the Golang Builder process outlined in the article Small Docker Images for Go Apps.

Summary

Building an adapter to any orchestration framework does not require learning a new programming language, because the architecture relies on containers. The labs team created the Marathon Adapter using Go to demonstrate this powerful architectural advantage.

Using the Panamax Adapter library and the Golang Builder process it is very easy for teams to create a small efficient Golang container for the adapter they require. A sample using the points in this article can be found here: https://github.com/CenturyLinkLabs/sample-go-adapter.

Don't have a CenturyLink account? No problem. Get started with CenturyLink Cloud for free and receive a healthy credit toward any of our products or services.