Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 22 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ environments while using shared components and consistent interfaces.
_InfraKit_ leverages _Plugins_ to manage arbitrary systems in diverse environments, which can be composed to meet
different needs. Technically, a Plugin is an HTTP server with a well-defined API, listening on a unix socket.

[Utilities](spi/http) are provided as libraries to simplify Plugin development in Go.
[Utilities](pkg/rpc) are provided as libraries to simplify Plugin development in Go.

### Plugin types
#### Group
Expand All @@ -43,7 +43,7 @@ Since _InfraKit_ emphasizes on declarative infrastructure, there are no operatio
state to another. Instead, you _declare_ your desired state of the infrastructure. _InfraKit_ is responsible
for converging towards, and maintaining, that desired state.

Therefore, a [group plugin](spi/group/spi.go) manages Groups of Instances and exposes the operations that are of
Therefore, a [group plugin](pkg/spi/group/spi.go) manages Groups of Instances and exposes the operations that are of
interest to a user:

+ commit a group configuration, to start managing a group
Expand All @@ -60,7 +60,7 @@ infrastructure management system. This would allow you to use _InfraKit_ toolin
different infrastructure using the same interface.

#### Instance
Instances are members of a group. An [instance plugin](spi/instance/spi.go) manages some physical resource instances.
Instances are members of a group. An [instance plugin](pkg/spi/instance/spi.go) manages some physical resource instances.
It knows only about individual instances and nothing about Groups. Instance is technically defined by the plugin, and
need not be a physical machine at all.

Expand All @@ -73,7 +73,7 @@ persistent, stable state. These properties are captured via the _flavors_ of the

#### Flavor
Flavors help distinguish members of one group from another by describing how these members should be treated.
A [flavor plugin](spi/flavor/spi.go) can be thought of as defining what runs on an Instance.
A [flavor plugin](pkg/spi/flavor/spi.go) can be thought of as defining what runs on an Instance.
It is responsible for dictating commands to run services, and check the health of those services.

Flavors allow a group of instances to have different characteristics. In a group of cattle,
Expand All @@ -93,12 +93,12 @@ to start a discussion before contributing to these plugins with non-trivial code

| plugin | type | description |
|:---------------------------------------------------|:---------|:----------------------------------------|
| [swarm](example/flavor/swarm) | flavor | runs Docker in Swarm mode |
| [vanilla](example/flavor/vanilla) | flavor | manual specification of instance fields |
| [zookeeper](example/flavor/zookeeper) | flavor | run an Apache ZooKeeper ensemble |
| [infrakit/file](example/instance/file) | instance | useful for development and testing |
| [infrakit/terraform](example/instance/terraform) | instance | creates instances using Terraform |
| [infrakit/vagrant](example/instance/vagrant) | instance | creates Vagrant VMs |
| [swarm](pkg/example/flavor/swarm) | flavor | runs Docker in Swarm mode |
| [vanilla](pkg/example/flavor/vanilla) | flavor | manual specification of instance fields |
| [zookeeper](pkg/example/flavor/zookeeper) | flavor | run an Apache ZooKeeper ensemble |
| [infrakit/file](pkg/example/instance/file) | instance | useful for development and testing |
| [infrakit/terraform](pkg/example/instance/terraform) | instance | creates instances using Terraform |
| [infrakit/vagrant](pkg/example/instance/vagrant) | instance | creates Vagrant VMs |


#### Supported implementations
Expand Down Expand Up @@ -154,32 +154,22 @@ $ make binaries
```
Executables will be placed in the `./build` directory.
This will produce binaries for tools and several reference Plugin implementations:
+ [`infrakit`](./cmd/cli/README.md): a command line interface to interact with plugins
+ [`infrakit-group-default`](./cmd/group/README.md): the default [Group plugin](./spi/group)
+ [`infrakit-instance-file`](./example/instance/file): an Instance plugin using dummy files to represent instances
+ [`infrakit-instance-terraform`](./example/instance/terraform):
+ [`infrakit`](cmd/cli/README.md): a command line interface to interact with plugins
+ [`infrakit-group-default`](cmd/group/README.md): the default [Group plugin](./spi/group)
+ [`infrakit-instance-file`](pkg/example/instance/file): an Instance plugin using dummy files to represent instances
+ [`infrakit-instance-terraform`](pkg/example/instance/terraform):
an Instance plugin integrating [Terraform](https://www.terraform.io)
+ [`infrakit-instance-vagrant`](./example/instance/vagrant):
+ [`infrakit-instance-vagrant`](pkg/example/instance/vagrant):
an Instance plugin using [Vagrant](https://www.vagrantup.com/)
+ [`infrakit-flavor-vanilla`](./example/flavor/vanilla):
+ [`infrakit-flavor-vanilla`](pkg/example/flavor/vanilla):
a Flavor plugin for plain vanilla set up with user data and labels
+ [`infrakit-flavor-zookeeper`](./example/flavor/zookeeper):
+ [`infrakit-flavor-zookeeper`](pkg/example/flavor/zookeeper):
a Flavor plugin for [Apache ZooKeeper](https://zookeeper.apache.org/) ensemble members
+ [`infrakit-flavor-swarm`](./example/flavor/swarm):
+ [`infrakit-flavor-swarm`](pkg/example/flavor/swarm):
a Flavor plugin for Docker in [Swarm mode](https://docs.docker.com/engine/swarm/).

All provided binaries have a `help` sub-command to get usage and a `version` sub-command to identify the build revision.

## Examples
There are a few examples of _InfraKit_ plugins:

+ Terraform Instance Plugin
- [README](./example/instance/terraform/README.md)
- [Code] (./example/instance/terraform/plugin.go) and [configs](./example/instance/terraform/aws-two-tier)
+ Zookeeper / Vagrant
- [README](./example/flavor/zookeeper/README.md)
- [Code] (./plugin/flavor/zookeeper)


# Design

Expand All @@ -200,10 +190,10 @@ A common pattern for a JSON object looks like this:

There is only one `Properties` field in this JSON and its value is a JSON object. The opaque
JSON value for `Properties` is decoded via the Go `Spec` struct defined within the package of the plugin --
for example -- [`vanilla.Spec`](/plugin/flavor/vanilla/flavor.go).
for example -- [`vanilla.Spec`](pkg/plugin/flavor/vanilla/flavor.go).

The JSON above is a _value_, but the type of the value belongs outside the structure. For example, the
default Group [Spec](/plugin/group/types/types.go) is composed of an Instance plugin, a Flavor plugin, and an
default Group [Spec](pkg/plugin/group/types/types.go) is composed of an Instance plugin, a Flavor plugin, and an
Allocation:

```json
Expand Down Expand Up @@ -305,7 +295,7 @@ The CLI shows which plugins are [discoverable](cmd/cli/README.md#list-plugins).

## Docs

Design docs can be found [here](./docs).
Additional documentation can be found [here](docs).

## Reporting security issues

Expand All @@ -327,7 +317,7 @@ _InfraKit_ is currently focused on supporting setup and management of base infra
orchestrator. The image below illustrates an architecture we are working towards supporting - a Docker cluster in Swarm
mode.

![arch image](images/arch.png)
![arch image](docs/images/arch.png)

This configuration co-locates _InfraKit_ with Swarm manager nodes and offers high availability of _InfraKit_ itself and
Swarm managers (using attached storage). _InfraKit_ is shown managing two groups - managers and workers that will be
Expand Down
10 changes: 5 additions & 5 deletions cmd/cli/flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"strings"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/discovery"
"github.com/docker/infrakit/plugin/group/types"
flavor_plugin "github.com/docker/infrakit/rpc/flavor"
"github.com/docker/infrakit/spi/flavor"
"github.com/docker/infrakit/spi/instance"
"github.com/docker/infrakit/pkg/discovery"
"github.com/docker/infrakit/pkg/plugin/group/types"
flavor_plugin "github.com/docker/infrakit/pkg/rpc/flavor"
"github.com/docker/infrakit/pkg/spi/flavor"
"github.com/docker/infrakit/pkg/spi/instance"
"github.com/spf13/cobra"
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/cli/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"strings"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/discovery"
group_plugin "github.com/docker/infrakit/rpc/group"
"github.com/docker/infrakit/spi/group"
"github.com/docker/infrakit/pkg/discovery"
group_plugin "github.com/docker/infrakit/pkg/rpc/group"
"github.com/docker/infrakit/pkg/spi/group"
"github.com/spf13/cobra"
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/cli/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"strings"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/discovery"
instance_plugin "github.com/docker/infrakit/rpc/instance"
"github.com/docker/infrakit/spi/instance"
"github.com/docker/infrakit/pkg/discovery"
instance_plugin "github.com/docker/infrakit/pkg/rpc/instance"
"github.com/docker/infrakit/pkg/spi/instance"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/cli"
"github.com/docker/infrakit/discovery"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"github.com/docker/infrakit/discovery"
"github.com/docker/infrakit/pkg/discovery"
"github.com/spf13/cobra"
)

Expand Down
16 changes: 8 additions & 8 deletions cmd/group/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/cli"
"github.com/docker/infrakit/discovery"
"github.com/docker/infrakit/plugin/group"
flavor_client "github.com/docker/infrakit/rpc/flavor"
group_server "github.com/docker/infrakit/rpc/group"
instance_client "github.com/docker/infrakit/rpc/instance"
"github.com/docker/infrakit/spi/flavor"
"github.com/docker/infrakit/spi/instance"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
"github.com/docker/infrakit/pkg/plugin/group"
flavor_client "github.com/docker/infrakit/pkg/rpc/flavor"
group_server "github.com/docker/infrakit/pkg/rpc/group"
instance_client "github.com/docker/infrakit/pkg/rpc/instance"
"github.com/docker/infrakit/pkg/spi/flavor"
"github.com/docker/infrakit/pkg/spi/instance"
"github.com/spf13/cobra"
)

Expand Down
12 changes: 6 additions & 6 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"path/filepath"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/cli"
"github.com/docker/infrakit/discovery"
"github.com/docker/infrakit/leader"
"github.com/docker/infrakit/manager"
group_rpc "github.com/docker/infrakit/rpc/group"
"github.com/docker/infrakit/store"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
"github.com/docker/infrakit/pkg/leader"
"github.com/docker/infrakit/pkg/manager"
group_rpc "github.com/docker/infrakit/pkg/rpc/group"
"github.com/docker/infrakit/pkg/store"
"github.com/spf13/cobra"
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/manager/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"path/filepath"
"time"

"github.com/docker/infrakit/discovery"
file_leader "github.com/docker/infrakit/leader/file"
file_store "github.com/docker/infrakit/store/file"
"github.com/docker/infrakit/pkg/discovery"
file_leader "github.com/docker/infrakit/pkg/leader/file"
file_store "github.com/docker/infrakit/pkg/store/file"
"github.com/spf13/cobra"
)

Expand Down
8 changes: 4 additions & 4 deletions cmd/manager/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (

log "github.com/Sirupsen/logrus"
"github.com/docker/go-connections/tlsconfig"
"github.com/docker/infrakit/discovery"
swarm_leader "github.com/docker/infrakit/leader/swarm"
swarm_store "github.com/docker/infrakit/store/swarm"
"github.com/docker/infrakit/util/docker/1.24"
"github.com/docker/infrakit/pkg/discovery"
swarm_leader "github.com/docker/infrakit/pkg/leader/swarm"
swarm_store "github.com/docker/infrakit/pkg/store/swarm"
"github.com/docker/infrakit/pkg/util/docker/1.24"
"github.com/spf13/cobra"
)

Expand Down
File renamed without changes
4 changes: 2 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ Now we must create the JSON for a group. You will find that the JSON structures

This defines the name of the `Plugin` to use and the `Properties` to configure it with. The plugins are free to define
their own configuration schema. Plugins in this repository follow a convention of using a `Spec` Go struct to define
the `Properties` schema for each plugin. The [`group.Spec`](/plugin/group/types/types.go) in the default Group plugin,
and [`vanilla.Spec`](/plugin/flavor/vanilla/flavor.go) are examples of this pattern.
the `Properties` schema for each plugin. The [`group.Spec`](../pkg/plugin/group/types/types.go) in the default Group plugin,
and [`vanilla.Spec`](../pkg/plugin/flavor/vanilla/flavor.go) are examples of this pattern.

From listing the plugins earlier, we have two plugins running. `instance-file` is the name of the File Instance Plugin,
and `flavor-vanilla` is the name of the Vanilla Flavor Plugin.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cli/serverutil.go → pkg/cli/serverutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"path"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/discovery"
"github.com/docker/infrakit/rpc/server"
"github.com/docker/infrakit/pkg/discovery"
"github.com/docker/infrakit/pkg/rpc/server"
)

// RunPlugin runs a plugin server, advertising with the provided name for discovery.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion discovery/dir.go → pkg/discovery/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sync"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/plugin"
"github.com/docker/infrakit/pkg/plugin"
)

type dirPluginDiscovery struct {
Expand Down
4 changes: 2 additions & 2 deletions discovery/dir_test.go → pkg/discovery/dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"testing"
"time"

rpc "github.com/docker/infrakit/rpc/instance"
"github.com/docker/infrakit/rpc/server"
rpc "github.com/docker/infrakit/pkg/rpc/instance"
"github.com/docker/infrakit/pkg/rpc/server"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion discovery/discovery.go → pkg/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/user"
"path"

"github.com/docker/infrakit/plugin"
"github.com/docker/infrakit/pkg/plugin"
)

// Plugins provides access to plugin discovery.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
InfraKit Flavor Plugin - Combo
==============================

A [reference](../../../README.md#reference-implementations) implementation of a Flavor Plugin that supports composition
A [reference](/README.md#reference-implementations) implementation of a Flavor Plugin that supports composition
of other Flavors.

The Combo plugin allows you to use Flavors as mixins, combining their Instance properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package main
import (
"encoding/json"
"errors"
"github.com/docker/infrakit/plugin/group"
"github.com/docker/infrakit/plugin/group/types"
"github.com/docker/infrakit/spi/flavor"
"github.com/docker/infrakit/spi/instance"
"github.com/docker/infrakit/pkg/plugin/group"
"github.com/docker/infrakit/pkg/plugin/group/types"
"github.com/docker/infrakit/pkg/spi/flavor"
"github.com/docker/infrakit/pkg/spi/instance"
"strings"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package main
import (
"encoding/json"
"errors"
mock_flavor "github.com/docker/infrakit/mock/spi/flavor"
"github.com/docker/infrakit/plugin/group"
"github.com/docker/infrakit/plugin/group/types"
"github.com/docker/infrakit/spi/flavor"
"github.com/docker/infrakit/spi/instance"
mock_flavor "github.com/docker/infrakit/pkg/mock/spi/flavor"
"github.com/docker/infrakit/pkg/plugin/group"
"github.com/docker/infrakit/pkg/plugin/group/types"
"github.com/docker/infrakit/pkg/spi/flavor"
"github.com/docker/infrakit/pkg/spi/instance"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"os"

log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/cli"
"github.com/docker/infrakit/discovery"
flavor_rpc "github.com/docker/infrakit/rpc/flavor"
"github.com/docker/infrakit/spi/flavor"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
flavor_rpc "github.com/docker/infrakit/pkg/rpc/flavor"
"github.com/docker/infrakit/pkg/spi/flavor"
"github.com/spf13/cobra"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
InfraKit Flavor Plugin - Swarm
==============================

A [reference](../../../README.md#reference-implementations) implementation of a Flavor Plugin that creates a Docker
A [reference](/README.md#reference-implementations) implementation of a Flavor Plugin that creates a Docker
cluster in [Swarm Mode](https://docs.docker.com/engine/swarm/).


Expand All @@ -24,7 +24,7 @@ The supported fields are:

## Example

Begin by building plugin [binaries](../../../README.md#binaries).
Begin by building plugin [binaries](/README.md#binaries).

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (

log "github.com/Sirupsen/logrus"
"github.com/docker/go-connections/tlsconfig"
"github.com/docker/infrakit/cli"
"github.com/docker/infrakit/plugin/flavor/swarm"
flavor_plugin "github.com/docker/infrakit/rpc/flavor"
"github.com/docker/infrakit/util/docker/1.24"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/plugin/flavor/swarm"
flavor_plugin "github.com/docker/infrakit/pkg/rpc/flavor"
"github.com/docker/infrakit/pkg/util/docker/1.24"
"github.com/spf13/cobra"
)

Expand Down
Loading