Skip to content
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
9 changes: 5 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
run: |
tar -czf kl-${{ matrix.arch }}.tar.gz -C ./target kl

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: binaries
name: kl-${{ matrix.arch }}
if-no-files-found: error
path: kl-${{ matrix.arch }}.tar.gz

Expand All @@ -65,9 +65,10 @@ jobs:
- uses: actions/checkout@v4

- name: Download Binary Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: binaries
merge-multiple: true
pattern: kl-*
path: bin

- name: Calculate checksums
Expand Down
70 changes: 37 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ stack so long as the stack is or can be dockerized.

### Index

+ [**Installation**](#installation)
+ [**Initial Setup**](#initial-setup)
+ [**Network Topology**](./docs/network-topology.md)
+ [**Concepts**](#concepts)
+ [**Modules**](#modules)
+ [**Services**](#services)
+ [**Endpoints**](#endpoints)
+ [**Routes**](#routes)
+ [**Prompts**](#Prompts)
- [**Installation**](#installation)
- [**Initial Setup**](#initial-setup)
- [**Network Topology**](./docs/network-topology.md)
- [**Concepts**](#concepts)
- [**Modules**](#modules)
- [**Services**](#services)
- [**Endpoints**](#endpoints)
- [**Routes**](#routes)
- [**Prompts**](#Prompts)

---

Expand All @@ -41,7 +41,7 @@ You can use the below script to automatically install the latest release
bash < <(curl -s https://raw.githubusercontent.com/kepler16/kl/master/install.sh)
```

Or you can get the binaries directly from the GitHub releases page and put them on your PATH.
Or you can get the binaries directly from the GitHub releases page and put them on your `PATH`.

---

Expand All @@ -67,8 +67,8 @@ sudo mkdir -p /etc/resolver
echo 'nameserver 127.0.0.1' | sudo tee -a /etc/resolver/test > /dev/null
```

KL runs this DNS server for you as one of the networking containers. See the [Network
Topology](./docs/network-topology.md) document for more information on the networking containers.
KL runs this DNS server for you as one of the networking containers. See the
[Network Topology](./docs/network-topology.md) document for more information on the networking containers.

Now you can start the docker network and proxy containers:

Expand All @@ -79,8 +79,8 @@ kl network start
### `Linux`

Linux doesn't have a completely standard way of handling DNS and so this setup will depend a bit on your particular
setup. A very common/standard DNS resolver setup on Linux is `systemd-resolved` and so below is a guide on how to set
get setup using this. If you don't use `systemd-resolved` then you will need to configure your system to route `.test`
setup. A very common/standard DNS resolver setup on Linux is `systemd-resolved` and so below is a guide on how to get
setup using this. If you don't use `systemd-resolved` then you will need to configure your system to route `.test`
domains to `127.0.0.1` however is appropriate for you.

Edit your `/etc/systemd/resolved.conf` file and add the following to the `[Resolve]` section:
Expand Down Expand Up @@ -109,9 +109,9 @@ kl network start

> [!NOTE]
>
> On Linux the host DNS network container's port defaults to binding to `5343`. If you would like to change this
> you can start the networking components with a different port by running `kl network start --host-dns-port=<custom-port>`.
> You will then also need to update your `/etc/systemd/resolved.conf` file to match.
> On Linux the host DNS network container's port defaults to binding to `5343`. If you would like to change this you can
> start the networking components with a different port by running `kl network start --host-dns-port=<custom-port>`. You
> will then also need to update your `/etc/systemd/resolved.conf` file to match.

---

Expand All @@ -130,8 +130,8 @@ with regardless of where those services are running or what their ip:port combin
These domains are stable across all developers' machines and don't change when a developer needs to alter how or where
they are running any particular service.

For an overview of the network topology constructed by kl head over to the [Network
Topology](./docs/network-topology.md) document.
For an overview of the network topology constructed by kl head over to the
[Network Topology](./docs/network-topology.md) document.

#### Containers

Expand Down Expand Up @@ -174,17 +174,17 @@ A module is a directory located in `~/.config/kl/modules/` that must contain at
:service :example}}}

:containers {:example {:image "ghcr.io/example/example:{{SHA_SHORT}}"
:volumes ["{{DIR}}/config.toml:/config.toml"]}}}
:volumes ["{{DIR}}/config.toml:/config.toml"]}}}
```

#### Module Resolution

Any submodules defined in a module will be recursively resolved and deep-merged with its parent module. When there are
module conflicts (more than one module with the same name) then they are resolved as follows:

+ If the conflict is in a child module, the parent will be used.
+ If there are no matching parent modules then the chosen module is essentially random - the first module to resolve
will be used.
- If the conflict is in a child module, the parent will be used.
- If there are no matching parent modules then the chosen module is essentially random - the first module to resolve
will be used.

The module resolution is performed once and the result stored in a lockfile called `module.lock.edn`. This allows a
developers' local dev-setup to be unaffected by any upstream changes _by default_ until the developer decides to
Expand All @@ -209,9 +209,13 @@ defined by one of the referenced submodules.
When a module is resolved kl will perform some basic variable substitution to allow for simple templating. Variables
should be in the form `{{VAR_NAME}}` where `VAR_NAME` can be one of the following:

Variable | Description ---|--- SHA | The full git SHA that the module was resolved as SHA_SHORT | The short version of
`SHA` - only the first 7 chars DIR | This is the local module directory on the host machine. This can be used for
referencing config files that are included as part of the module.
Here's the properly formatted markdown table:

| Variable | Description |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| SHA | The full git SHA that the module was resolved as |
| SHA_SHORT | The short version of `SHA` - only the first 7 chars |
| DIR | This is the local module directory on the host machine. This can be used for referencing config files that are included as part of the module. |

Here is an example module that makes use of templating:

Expand Down Expand Up @@ -251,15 +255,15 @@ container/docker network. This also means that `localhost` or `127.0.0.1` does _

Below are some common ways of addressing services running in different contexts:

+ A container called `example` with a port `8080` defined in the module could be addressed as
+ `http://example:8080`
+ `http://<container-ip>:8080`
+ A process running on the host and bound to port `8080` could be addressed as
+ On macOS and Linux* - `http://host.docker.internal:8080`
+ On Linux - `http://172.17.0.1:8080`
- A container called `example` with a port `8080` defined in the module could be addressed as
- `http://example:8080`
- `http://<container-ip>:8080`
- A process running on the host and bound to port `8080` could be addressed as
- On macOS and Linux\* - `http://host.docker.internal:8080`
- On Linux - `http://172.17.0.1:8080`

> [!NOTE]
>
>
> On **Linux\*** docker does not configure the `host.docker.internal` domain which is typically only available on macOS
> when using something like Docker Desktop.
>
Expand Down
10 changes: 5 additions & 5 deletions docs/network-topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ All three components are running inside a Docker network and have predefined, st
Which this topology, the following properties are observed:

+ All `*.test` DNS requests made from the host machine are routed to `127.0.0.1`
+ All `*.test` DNS requests made from within the docker network are routed to `172.16.238.4` which is the IP address of the proxy inside the network
+ All `*.test` DNS requests made from within the docker network are routed to `172.5.0.101` which is the IP address of the proxy inside the network

> Note: All docker containers that need to be able to resolve `.test` domains must have their DNS server (use the flag `--dns`) set to the IP of the internal dnsmasq container

Expand All @@ -31,17 +31,17 @@ flowchart TD

proxy[Traefik Proxy]

proc1 -. proc2.test .-> di
proc2 -. proc3.test .-> di
proc1 -. "proc2.test" .-> di
proc2 -. "proc3.test" .-> di

di -. dns resolution .-> proxy
end
end


proc3 -. proc1.test .-> de -. dns resolution .-> proxy
proc3 -. "proc1.test" .-> de -. dns resolution .-> proxy

proxy --proxies to--> proc1 & proc2 & proc3
proxy -- "proxies to" --> proc1 & proc2 & proc3
```

## IPs
Expand Down