Skip to content

Commit

Permalink
address #26
Browse files Browse the repository at this point in the history
  • Loading branch information
idroz committed Oct 14, 2020
1 parent 25a1f98 commit 30f3b0f
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 90 deletions.
11 changes: 11 additions & 0 deletions Makefile
Expand Up @@ -13,6 +13,17 @@ ubuntu:
@echo "version: "$(VERSION)
@echo "Bravetools installed"

linux:
@echo "Building Bravetools ..."
go clean
go get
rm -f install/linux/$(BINARY_NAME)
@GOOS=linux go build -ldflags=$(GO_LDFLAGS) -o install/linux/$(BINARY_NAME) *.go
@echo "Installing ..."
sudo cp install/linux/brave /usr/bin/
@echo "version: "$(VERSION)
@echo "Bravetools installed"

darwin:
@echo "Building Bravetools ..."
go clean
Expand Down
244 changes: 155 additions & 89 deletions README.md
Expand Up @@ -13,91 +13,22 @@ Configurable system images have many advantages, but their use has been limited.

* **Focus on code not infrastructure**. Maintaining and configuring infrastructure is difficult! With any application built and deployed using Bravetools infrastructure and environment have to be configured just once. Developers can spend more time on creating and improving software and less time on managing production environments.

## Quick tour

Here's a toy example showing how to create a simple container configuration, add some useful packages to it, and deploy your image as a service.

Configuration instructions are stored in a [Bravefile](https://bravetools.github.io/bravetools/docs/bravefile/). Let's crate a simple Bravefile that uses Alpine Edge image and installs python3:

```bash
$ touch Bravefile
```

Populate this Bravefile with basic configuration, adding `python3` package through `apk` manager:

```yaml
base:
image: alpine/edge/amd64
location: public
packages:
manager: apk
system:
- python3
service:
image: alpine-example-1.0
name: alpine-example
docker: "no"
version: "1.0"
ip: ""
ports: []
resources:
ram: 4GB
cpu: 2
gpu: "no"
```

To create an image from this configuration, run:

```bash
$ brave build

[alpine-example] IMPORT: alpine/edge/amd64
[alpine-example] RUN: [apk update]
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
...

OK: 56 MiB in 30 packages
Exporting image alpine-example
9691e2cf3a58abd4ca411e8085c3117a
```

List all local images and confirm successful build:

```bash
$ brave images

IMAGE CREATED SIZE HASH
alpine-example-1.0 just now 19MB 9691e2cf3a58abd4ca411e8085c3117a
```

Finally, we can deploy this image as a container:

```bash
$ brave deploy

Importing alpine-example-1.0.tar.gz
```
## Table of Contents

- [Installing Bravetools](#installing-bravetools)
* [Latest stable binary](#latest-stable-binary)
* [Install from source](#install-from-source)
+ [Ubuntu](#ubuntu)
+ [Linux](#linux)
+ [Mac OS](#mac-os)
+ [Windows](#windows)
+ [Vagrant](#vagrant)
* [Update Bravetools](#update-bravetools)
- [Initialise Bravetools](#initialise-bravetools)
- [Quick tour](#quick-tour)
- [Build Documentation](#build-documentation)
- [Command Reference](#command-reference)

Confirm that the service is up and running:

```bash
NAME STATUS IPV4 DISK PROXY
alpine-example Running eth0:10.0.0.117
```

Because this is just an LXD container, you can access it through the usual `lxc exec` command:

```bash
$ lxc exec alpine-example python3

Python 3.8.6 (default, Oct 5 2020, 00:23:48)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
```


This is a very basic example - Bravertools makes it easy to create very complex System Container environments, abstracting configuration options such as [GPU support](https://bravetools.github.io/bravetools/docs/gpu-units/), [Docker integration](https://bravetools.github.io/bravetools/docs/docker/), and seamless port-forwarding, just to name a few. To learn more about using Bravetools, please refer to our [Bravetools Documentation](https://bravetools.github.io/bravetools/).

## Installing Bravetools

Expand All @@ -118,12 +49,11 @@ To get started using Bravetools:
sudo usermod --append --groups lxd $USER
```


### Install from source

Bravetools can be built from source on any platform that supports Go and LXD.

### Ubuntu
#### Ubuntu

**Minimum Requirements**
* Operating System
Expand Down Expand Up @@ -153,7 +83,31 @@ sudo apt install zfsutils-linux

If this is your first time setting up Bravetools, run `brave init` to initialise the required profile, storage pool, and LXD bridge.

### Mac OS
#### Linux

**Minimum Rquirements**
* Hardware
* 2GB of Memory
* Software
* [Go](https://golang.org/)
* [LXD >3.0.3](https://linuxcontainers.org/lxd/getting-started-cli/)

```bash
git clone https://github.com/bravetools/bravetools
cd bravetools
make linux
```

Add your user to `lxd group`:
```bash
sudo usermod --append --groups lxd $USER
```

Depending on your Linux distribution, you may also need to install `zfs` tools to enable storage pool management in Bravetools.

If this is your first time setting up Bravetools, run `brave init` to initialise the required profile, storage pool, and LXD bridge.

#### Mac OS

**Minimum Requirements**
* Operating System
Expand All @@ -173,7 +127,7 @@ make darwin
If this is your first time setting up Bravetools, run `brave init` to initialise the required profile, storage pool, and LXD bridge.


### Windows
#### Windows

**Minimum Requirements**
* Operating System
Expand All @@ -193,7 +147,7 @@ go build -ldflags=“-s -X github.com/bravetools/bravetools/shared.braveVersion=

Where VERSION reflects the latest stable release of Bravetools e.g `shared.braveVersion=1.53`

### Vagrant
#### Vagrant

1. Start Vagrant VM:

Expand All @@ -218,6 +172,118 @@ cd bravetools
make [darwin][ubuntu]
```

## Initialise Bravetools

When Bravetools is installed for the first time, Bravetools will set up all required components to connect your host to LXD. This is achieved by running:

```bash
brave init
```

`brave init` will:

* Create `~/.bravetools` directory that stores all your local images, configurations, and a live Unit database

On Mac and Windows platforms:

* Create a new Multipass instance of Ubuntu 18.04
* Install snap LXD
* Enable mounting between host and Multipass

On Linux distributions:

* Set up a new LXD profile `brave`
* Create a new LXD bridge `bravebr0`
* Create a new storage pool `brave-TIMESTAMP`

These steps ensure that Bravetools establishes a connection with LXD server and runs a self-contained LXD environment that doesn't interfere with any potentially existing profiles and LXD bridges.

## Quick tour

Here's a toy example showing how to create a simple container configuration, add some useful packages to it, and deploy your image as a service.

Configuration instructions are stored in a [Bravefile](https://bravetools.github.io/bravetools/docs/bravefile/). Let's crate a simple Bravefile that uses Alpine Edge image and installs python3:

```bash
$ touch Bravefile
```

Populate this Bravefile with basic configuration, adding `python3` package through `apk` manager:

```yaml
base:
image: alpine/edge/amd64
location: public
packages:
manager: apk
system:
- python3
service:
image: alpine-example-1.0
name: alpine-example
docker: "no"
version: "1.0"
ip: ""
ports: []
resources:
ram: 4GB
cpu: 2
gpu: "no"
```

To create an image from this configuration, run:

```bash
$ brave build

[alpine-example] IMPORT: alpine/edge/amd64
[alpine-example] RUN: [apk update]
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
...

OK: 56 MiB in 30 packages
Exporting image alpine-example
9691e2cf3a58abd4ca411e8085c3117a
```

List all local images and confirm successful build:

```bash
$ brave images

IMAGE CREATED SIZE HASH
alpine-example-1.0 just now 19MB 9691e2cf3a58abd4ca411e8085c3117a
```

Finally, we can deploy this image as a container:

```bash
$ brave deploy

Importing alpine-example-1.0.tar.gz
```

Confirm that the service is up and running:

```bash
NAME STATUS IPV4 DISK PROXY
alpine-example Running eth0:10.0.0.117
```

Because this is just an LXD container, you can access it through the usual `lxc exec` command:

```bash
$ lxc exec alpine-example python3

Python 3.8.6 (default, Oct 5 2020, 00:23:48)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
```


This is a very basic example - Bravertools makes it easy to create very complex System Container environments, abstracting configuration options such as [GPU support](https://bravetools.github.io/bravetools/docs/gpu-units/), [Docker integration](https://bravetools.github.io/bravetools/docs/docker/), and seamless port-forwarding, just to name a few. To learn more about using Bravetools, please refer to our [Bravetools Documentation](https://bravetools.github.io/bravetools/).

## Build Documentation

Follow installation instructions for [Jekyll](https://jekyllrb.com/) on your platform.
Expand Down
20 changes: 19 additions & 1 deletion docs/docs/cli/brave_init.md
Expand Up @@ -16,7 +16,25 @@ brave init

## Description

Create a new Bravetools host
When Bravetools is installed for the first time, Bravetools will set up all required components to connect your host to LXD.

`brave init` will:

* Create `~/.bravetools` directory that stores all your local images, configurations, and a live Unit database

On Mac and Windows platforms:

* Create a new Multipass instance of Ubuntu 18.04
* Install snap LXD
* Enable mounting between host and Multipass

On Linux distributions:

* Set up a new LXD profile `brave`
* Create a new LXD bridge `bravebr0`
* Create a new storage pool `brave-TIMESTAMP`

These steps ensure that Bravetools establishes a connection with LXD server and runs a self-contained LXD environment that doesn't interfere with any potentially existing profiles and LXD bridges.

## Options

Expand Down

0 comments on commit 30f3b0f

Please sign in to comment.