• Stars
    star
    226
  • Rank 176,514 (Top 4 %)
  • Language
    Go
  • Created about 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Zero-configuration containers under systemd using systemd-nspawn

hastur

hastur is a tool for launching systemd-nspawn containers without the need for manual configuration.

It will setup networking, a base root FS and even an overlay FS for containers automatically.

The primary usecase for hastur is supporting testcases for distributed systems and running a local set of trusted containers.

gif

Motivation

systemd-nspawn is useful tool, which can create and run lightweight containers without any additional software, because it's available out-of-the-box systemd.

However, it requires some configuration to run a working container, such as managing the network configuration, and downloading and extracting packages.

hastur offers all this configuration automatically, which makes it possible to run fully-configured systemd-nspawn containers in seconds.

Installation

Arch Linux

hastur is available for Arch Linux (for now, only) through the AUR:

https://aur4.archlinux.org/packages/hastur/

go get

hastur is also go-gettable:

go get github.com/seletskiy/hastur

Usage

Testing water

The most simple usage is testing hastur out-of-the-box: you can tell it to create an ephemeral container with a basic set of packages:

sudo hastur -S

After invoking that command, you will end up in Cthulhu's void in the bash shell.

This test container will be deleted after you exit its shell.

Creating non-ephemeral containers

Passing the -k flag will tell hastur to keep the container after exit:

sudo hastur -kS

If you don't like the fantastical autogenerated names, you can pass the flag -n:

sudo hastur -Sn my-cool-name

Note that ephemeral containers are only the ones that both have autogenerated names and were not started with the -k flag.

Networking

hastur will take care of setting up the networking by creating a bridge and setting up a shared network. By default, hastur will automatically generate IP addresses, and you can see a container's address either in its starting message or by running the query command:

sudo hastur -Q

You can specify your own IP address by passing the -a flag, like this:

sudo hastur -S -a 10.0.0.2/8

But what about software?

hastur uses package-based container configurations and will happily populate your container with the packages that you want. You can use the -p flag for this:

sudo hastur -S -p nginx

That will create a container with the nginx package pre-installed. In actuality, hastur uses overlays to keep base dirs separate from container data. The base dirs, or, if you like, images, are just prepared root filesystems, which have pre-installed packages. You can query the cached base dirs by running hastur with the -Qi flag:

sudo hastur -Qi

In fact, from hastur's standpoint, a container is just a data dir, which gets overlayed on top of a root filesystem and then given network capability, so it will not remember what IP address a container has or what set of packages it has installed if you forget to specify the correct options.

For example:

sudo hastur -Sn test -p git -- /bin/git --version

Will output:

git version 2.5.3

But running this container the next time without -p git will tell you that git is not installed:

sudo hastur -Sn test -- /bin/git --version

This outputs:

No such file or directory

However, this test container will have a separate FS and all data files will persist across the two runs.

Additional information

hastur can operate over several root directories and keep container instances separately from each other. The -r flag is used for this:

sudo hastur -r solar-system -Sn earth
sudo hastur -r solar-system -Sn moon
sudo hastur -r alpha-centauri -Sn a
sudo hastur -r alpha-centauri -Sn b
sudo hastur -r alpha-centauri -Sn c

The output will be different for these two commands:

sudo hastur -r solar-system -Q
sudo hastur -r alpha-centauri -Q

The first one will list only the earth and moon containers, and the second will only list the a, b and c containers.

License

MIT.

More Repositories

1

go-android-rpc

Native Android UI via shared Golang library
Go
135
star
2

go-makepkg

Generate PKGBUILD for Golang programs and run makepkg
Go
62
star
3

firebase-emulator

Run Firebase Database emulator locally in Docker container
Shell
51
star
4

zsh-fuzzy-search-and-edit

Find and open editor on matched line lightning-fast
Shell
33
star
5

jira-agile-worklog-helper

Helper which track time spent on issue for you
JavaScript
32
star
6

monaco-font

My own pixel font for programming/shell; if you're using this, you're insane
Makefile
30
star
7

dotfiles

My system configuration. My introspection since 2012.
Shell
29
star
8

runki

Effortless AnkiSRS card managment to learn foreign words
Go
22
star
9

ash

Atlassian Stash (Bitbucket) reviews in editor
Go
21
star
10

carcosa

CLI password manager with profound Git integration
Go
15
star
11

vim-refugi

sshfs + fugitive = fffuuu-, sshfs + fugitive + refugi = hell yeah!
Shell
12
star
12

zsh-git-smart-commands

Wrappers for git commands to be efficient in the shell
Shell
12
star
13

kubernetes-bootstrap

Makefile for bootstrapping kubernetes cluster with Calico CNI & private Docker Image Registry
Makefile
9
star
14

urxvt-vim-insert

Make Shift-Insert work as expected in vim and shell
Perl
8
star
15

zsh-favorite-directories

zsh plugin for cd to list of favorite directories lightning fast
Shell
7
star
16

docopt-go

docopt bindings for go lang
Go
6
star
17

ebiten-android-minimal

Minimal Ebiten-powered Android App — https://ebiten.org/
Makefile
6
star
18

godiff

Unified diff file parser in Go (now with comments!)
Go
6
star
19

arch-apparmor

AppArmor Arch Linux packages that are works
Shell
6
star
20

jira-userscripts

Tracks time spent on issues
JavaScript
5
star
21

jibber

Turn WebHooks into jabber notifications
Go
5
star
22

chrome-editor

Backend for editing textarea contents in vim/emacs/sublime/whatever
Go
5
star
23

zsh-context-aliases

Dead simple implementation of context aliases
Shell
5
star
24

mainframe

Magnum Opus
Go
5
star
25

saturated

dead simple makepkg build server
Go
4
star
26

pidgin-start-conv

List buddies online or start conversation with specified buddy. Usable with dmenu!
Python
4
star
27

grapeyard

Stateless serverless DSLless cluster configuration tool
Go
4
star
28

ashium

Code review in vim with live update feature
Python
3
star
29

go-mock-file

golang lib for testing fs-related stuff
Go
3
star
30

zsh-smart-kill-word

Finally, better backward word deletion in zsh
Shell
3
star
31

zsh-zgen-compinit-tweak

Make compinit runs only once after all loading is done by zgen
Shell
3
star
32

kb

My personal knowledge base
2
star
33

zsh-prompt-lambda17

Highly extensible prompt for zsh
Shell
2
star
34

urxvt-patched

rxvt-unicode with my patches, not yet in upstream.
Shell
2
star
35

zsh-uber-ssh

Quick SSH aliases for zsh
Shell
2
star
36

tasker

My ubiquitous Tasker profiles
2
star
37

gen_tcpd

Generic TCP application, makes easy to build TCP-daemons.
Erlang
2
star
38

cake

Confluence Schedule Table Reader
Go
2
star
39

umb

UMB protocol realization for lufft.com products
Erlang
2
star
40

tplutil

Golang template utils
Go
2
star
41

mcabber-slack-completion

Autocomplete buddy names with starting @
C
2
star
42

zsh-hijack

Transform entered command line to new command line
Shell
2
star
43

zsh-hash-aliases

Global aliases starting with hash symbol
Shell
1
star
44

mcabber-autojoin

Automatically join to rooms on connect (for servers without bookmarks, like slack.com)
C
1
star
45

docopt-ver

docopt version setter for golang programs and git hook
Go
1
star
46

isnyseopen

Is NYSE open right now?
Go
1
star
47

gontrol

Ultrasimple tool for remote control from mobile phone
Go
1
star
48

slorry

Russian Post Tracker
Go
1
star
49

geth-go

Missing Ethereum geth JSON RPC client
Go
1
star
50

bloom-filter

Bloom Filter implementation in C
C
1
star
51

zsh-ssh-urxvt

Shell
1
star
52

zbackup

multithreading zfs backuper written on golang
Go
1
star
53

vim-nunu

Toggle relative number lines on cursor movement
Vim Script
1
star