kiwi-scp/README.md

183 lines
5.5 KiB
Markdown
Raw Normal View History

2020-08-26 12:25:53 +00:00
# kiwi-scp
2021-09-28 17:54:22 +00:00
[![Build Status](https://github.drone.yavook.de/api/badges/ldericher/kiwi-scp/status.svg)](https://github.drone.yavook.de/ldericher/kiwi-scp)
2020-08-26 12:25:53 +00:00
> `kiwi` - simple, consistent, powerful
The simple tool for managing container servers
2020-08-25 16:01:39 +00:00
## Quick start
- Learn to use `docker` with `docker-compose`
2020-08-26 11:56:51 +00:00
- Install kiwi-scp
2020-08-25 16:01:39 +00:00
- Look at [the example instance](./example)
- Look at the output of `kiwi --help`
- Start building your own instances
2020-08-25 16:01:39 +00:00
## Installation
2022-02-21 23:02:28 +00:00
A convenience installer is available as [install.sh](./dist/install.sh) in the `dist` directory.
2020-08-25 16:01:39 +00:00
You can `curl | sh` it using the following one-liner.
```shell script
2022-02-21 23:02:28 +00:00
curl --proto '=https' --tlsv1.2 -sSf 'https://raw.githubusercontent.com/ldericher/kiwi-scp/master/dist/install.sh' | sh
```
2020-08-25 16:01:39 +00:00
The installer downloads the `kiwi` launcher script and installs it to a location of your choice.
Please consider installing into a directory inside your `$PATH`.
2022-02-21 23:02:28 +00:00
Run in a root shell or use `sudo sh` at the end instead for system-wide installation.
2020-08-25 16:01:39 +00:00
2022-02-21 23:02:28 +00:00
You should now be able to run `kiwi list --show` and see the default configuration file.
This installs the latest version of the kiwi-scp package and sets it up for you.
2020-08-25 16:01:39 +00:00
### Adjusting environment for `kiwi`
2022-02-21 23:02:28 +00:00
The `kiwi` executable depends on [Python](https://www.python.org/) 3.6.1 (or later) and
2020-08-25 16:01:39 +00:00
[less](http://www.greenwoodsoftware.com/less/) being in your `$PATH`.
2020-08-26 12:25:53 +00:00
In some cases, notably when using a multi-version system such as
[CentOS SCL](https://wiki.centos.org/AdditionalResources/Repositories/SCL), not all of these are in your `$PATH`
2020-08-25 16:01:39 +00:00
at login time.
2020-08-26 12:33:00 +00:00
In those cases, you can simply create a `.kiwi_profile` file in your home directory.
2020-08-25 16:01:39 +00:00
It will be sourced every time you use the `kiwi` command.
2020-08-26 12:33:00 +00:00
For the aforementioned case where you installed `centos-release-scl` and `rh-python36`, your `~/.kiwi_profile` should
2020-08-25 16:01:39 +00:00
contain:
```shell script
#!/bin/sh
. /opt/rh/rh-python36/enable
```
## Get started
2020-08-26 11:56:51 +00:00
### Create a kiwi-scp instance
2020-08-25 16:01:39 +00:00
2020-08-26 12:25:53 +00:00
Any directory is implicitly a valid kiwi-scp instance using the default configuration.
To prevent surprises however, you should run `kiwi init` in an empty directory and follow its directions to
create a `kiwi.yml` before using `kiwi` more.
2020-08-25 16:01:39 +00:00
### Concept
2020-08-26 12:25:53 +00:00
A kiwi-scp instance is a directory containing a bunch of static configuration files.
2020-08-25 16:01:39 +00:00
"Static" there as in "those don't change during normal service operation".
These files could be anything from actual `.conf` files to entire html-web-roots.
2022-02-21 23:02:28 +00:00
Non-static, but persistent files are to be kept in a "service data directory", by default `/var/local/kiwi`.
In your `docker-compose.yml` files, you can refer to that directory as **${KIWI_INSTANCE}**.
2020-08-25 16:01:39 +00:00
2020-08-26 12:25:53 +00:00
Start the current directory as a kiwi-scp instance using `kiwi up`, or stop it using `kiwi down`.
2020-08-25 16:01:39 +00:00
This also creates kiwi's internal hub network, which you can use as **kiwi_hub** in your `docker-compose.yml` files.
### Projects
2020-08-26 12:25:53 +00:00
A kiwi-scp instance usually contains several projects.
2020-08-25 16:01:39 +00:00
A project is a collection of dependent or at least logically connected services, described by a `docker-compose.yml`.
A well-known example would be webserver + php + database.
To create a project, use the `kiwi new <project-name>` command.
By default, this creates a new disabled project.
Before enabling or starting, consider editing the new project's `docker-compose.yml` file to your liking.
Finally, enable it with `kiwi enable <project-name>`.
You can also create, enable or (analogously) disable multiple projects in a single command.
2022-02-21 23:02:28 +00:00
Each project will have its own place in the service data directory, which you can refer to as **${KIWI_PROJECT}**.
2020-08-25 16:01:39 +00:00
Finally, start a project using `kiwi up <project-name>`.
2020-08-26 12:25:53 +00:00
### Advanced kiwi usage
2020-08-25 16:01:39 +00:00
2020-08-26 12:25:53 +00:00
kiwi-scp extends the logical bounds of `docker-compose` to handling multiple projects.
2020-08-25 16:01:39 +00:00
#### The `kiwi_hub`
2022-02-21 23:02:28 +00:00
With kiwi-scp, you get the internal `kiwi_hub` network for free.
2020-08-25 16:01:39 +00:00
It allows for network communication between services in different projects.
Be aware, services only connected to the kiwi_hub can't use a port mapping!
In most cases, you will want to use this:
```yaml
networks:
- default
- kiwi_hub
2020-08-26 12:25:53 +00:00
```
2020-08-25 16:01:39 +00:00
2022-02-21 23:02:28 +00:00
#### The `KIWI_CONFIG`
2020-08-25 16:01:39 +00:00
Sometimes, it's convenient to re-use configuration files across projects.
2022-02-21 23:02:28 +00:00
For this use case, create a directory named `config` in your instance.
In your `docker-compose.yml` files, you can refer to that directory as **${KIWI_CONFIG}**.
2020-08-25 16:06:29 +00:00
2020-08-26 12:25:53 +00:00
#### `kiwi.yml` options
##### `version`
2022-02-21 23:02:28 +00:00
Version of kiwi-scp to use for this instance.
2020-08-26 12:25:53 +00:00
2022-02-21 23:02:28 +00:00
Default: Version of [`master` branch](https://github.com/ldericher/kiwi-scp/tree/master).
##### `shells`
Sequence of additionally preferable shell executables when entering service containers.
2020-08-26 12:25:53 +00:00
Default: `- /bin/bash`
Example:
```yaml
runtime:
shells:
- /bin/zsh
- /bin/fish
```
2022-02-21 23:02:28 +00:00
##### `projects`
Sequence of project definitions in this instance.
###### Project definition
Defining a project in this instance. Any subdirectory with a `docker-compose.yml` might be considered a project.
Format: Mapping using the keys `name`, `enabled` and `override_storage`
2020-08-26 12:25:53 +00:00
Example:
```yaml
2022-02-21 23:02:28 +00:00
- name: "hello_world"
enabled: true
2020-08-26 12:25:53 +00:00
```
2022-02-21 23:02:28 +00:00
##### `environment`
Custom variables available in projects' `docker-compose.yml` files.
Format: Mapping of `KEY: "value"` pairs
Example:
```yaml
environment:
HELLO: "World"
FOO: "Bar"
```
##### `storage`
Configuration for the service data storage.
Format: Mapping using the key `directory`
###### `storage:directory`
Path to the local service data directory, the only currently supported service data storage.
Available as **${KIWI_INSTANCE}** in projects.
Default: `/var/local/kiwi`
##### `network`
2020-08-26 12:25:53 +00:00
#### For everything else, look at `kiwi --help`
#### Happy kiwi-ing!