Skip to content

Commit 3a6a987

Browse files
committed
first draft
1 parent 2cc5632 commit 3a6a987

44 files changed

Lines changed: 1536 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/advanced/linux-kernel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Linux Kernel

docs/advanced/manual-flash-mode.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
sidebar_position: 5
3+
---
4+
5+
# Manual Flash Mode
6+
7+
This document refers to the [mode a machine can be snapshotted](../resources/machines.md#manual-flash-mode).

docs/getting-started/authentication.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,19 @@ sidebar_position: 2
33
---
44

55
# Authentication
6+
7+
Right now the only way to authenticate is with your provided JWT token.
8+
9+
Once you have installed the CLI in the previous step, [Installing the CLI](./installing-the-cli.md), you can authenticate by running the following command:
10+
11+
```sh
12+
lttle login --api http://eu.lttle.cloud:5100 jwt
13+
```
14+
15+
The only supported region is `eu`.
16+
17+
:::note Question
18+
19+
The region API endpoint for `eu` is using the http protocol. We should upgrade it to https for better security.
20+
21+
:::

docs/getting-started/deploying-a-static-site.md

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,274 @@ sidebar_position: 3
33
---
44

55
# Deploying a static site
6+
7+
In this exercise we will be deploying a simple [Astro](https://astro.build/) project using [Nginx](https://nginx.org/) to serve the static files.
8+
9+
Please make sure you have Node.js installed and Docker installed. We will be deploying a lttle machine that will serve outbound traffic via a lttle service.
10+
11+
Superficially a machine can be viewed as a container that runs somewhere in the lttle.cloud infrastructure and a service relates to traffic management and routing.
12+
13+
## Creating an Astro Project
14+
15+
To deploy a static site, you will need to have the CLI installed and be authenticated. If you haven't done that yet, please follow the previous steps: [Installing the CLI](./installing-the-cli.md) and [Authentication](./authentication.md).
16+
17+
In this exercise we will be deploying a simple [Astro](https://astro.build/) project. If you don't have an Astro project ready, you can create one quickly by following the [Astro documentation](https://astro.build/docs).
18+
19+
```bash npm2yarn
20+
npm create astro@latest
21+
```
22+
23+
Do any changes you would like to the newly generated Astro project, such as adding components, pages, or styles. Once you are satisfied with your changes, you can deploy your static site follow the next steps.
24+
25+
## Setting up your Code Editor / IDE
26+
27+
All lttle resources are defined using YAML files. To get started, we have prepared a YAML schema to facilitate resource creation. You can find it here: [resources.json](https://raw.githubusercontent.com/lttle-cloud/ignition/refs/heads/master/schemas/resources.json).
28+
29+
To make working with YAML files easier, you can set up your code editor or IDE with the following extensions:
30+
31+
### Visual Studio Code
32+
33+
Install the [YAML Language Support](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) extension for better YAML syntax highlighting and validation.
34+
35+
Create in the `.vscode` folder a `settings.json`, file with the following content:
36+
37+
```json
38+
{
39+
"yaml.schemas": {
40+
"https://raw.githubusercontent.com/lttle-cloud/ignition/refs/heads/master/schemas/resources.json": "/*.lttle.yaml"
41+
}
42+
}
43+
```
44+
45+
### JetBrains IDEs
46+
47+
Enable YAML support in your IDE settings and install any necessary plugins for enhanced YAML editing.
48+
49+
### Cursor
50+
51+
### Zed
52+
53+
### NeoVim
54+
55+
## Creating your first deployment
56+
57+
In order to deploy our statically generated Astro project, we need:
58+
59+
1. Create an Nginx configuration file
60+
2. Create a Dockerfile that will contain our static site and Nginx
61+
3. Push the Docker image to a container registry
62+
4. Create a machine resource to run our Docker container
63+
5. Create a service resource to route traffic to our machine
64+
6. Deploy the machine and the service to lttle.cloud
65+
66+
### Configuring Nginx
67+
68+
Create a file called `nginx.conf` in the root of your project with the following content:
69+
70+
```nginx title="nginx.conf"
71+
server {
72+
listen 80;
73+
server_name _;
74+
75+
location / {
76+
root /usr/share/nginx/html;
77+
index index.html;
78+
79+
try_files $uri $uri/index.html =404;
80+
81+
# Since we are serving static files, we can enable gzip compression
82+
# We will be pre-compressing our static files since we care about cpu-cost
83+
gzip_static on;
84+
gzip_comp_level 6;
85+
}
86+
87+
# Custom 404 page
88+
error_page 404 /404.html;
89+
location = /404.html {
90+
internal;
91+
}
92+
}
93+
```
94+
95+
### Building & Pushing the Docker Image
96+
97+
First we need to create a `Dockerfile` where we will be putting our static site:
98+
99+
```Dockerfile title="Dockerfile"
100+
FROM node:22.18.0-alpine3.22 AS build
101+
102+
WORKDIR /build
103+
104+
COPY . .
105+
106+
RUN npm install --frozen-lockfile
107+
108+
RUN npm run build
109+
110+
# Compress all build files with gzip
111+
# But keep original files
112+
RUN cd /build/build && find . -type f -exec gzip -9 -k \{\} \;
113+
114+
FROM nginx:1.29.1-alpine3.22
115+
116+
COPY --from=build /build/build /usr/share/nginx/html
117+
COPY nginx.conf /etc/nginx/conf.d/default.conf
118+
```
119+
120+
Then we need to build and push the Docker image.
121+
122+
```sh
123+
docker build . -t username/image:tag
124+
docker push username/image:tag
125+
```
126+
127+
### Creating your first machine
128+
129+
In order to deploy our simple Astro project, we need to create a machine resource. Create a file called `machine.lttle.yaml` in the root of your project with the following content:
130+
131+
```yaml title="static-site.lttle.yaml"
132+
machine:
133+
namespace: static-site
134+
name: nginx
135+
image: username/image:tag
136+
resources:
137+
# The smallest number of CPUs we can actually have
138+
cpu: 1
139+
# The smallest amount of memory we can actually have
140+
memory: 64
141+
mode:
142+
# This tells lttle.cloud that 5 seconds after nginx starts listening
143+
# we can stop the machine if it is not receiving any traffic
144+
flash:
145+
timeout: 5
146+
strategy:
147+
listen-on-port: 80
148+
```
149+
150+
More about [machines](../resources/machines.md).
151+
152+
:::note TODO
153+
154+
The dark theme does not support the yaml syntax highlighting.
155+
156+
:::
157+
158+
You can read more about the [machine resource](../resources/machines.md).
159+
160+
### Creating your first service
161+
162+
We need to have a service that it will tell lttle.cloud how to route traffic to our machine. Create a file called `service.lttle.yaml` in the root of your project with the following content:
163+
164+
```yaml title="service.lttle.yaml"
165+
service:
166+
namespace: static-site
167+
name: ingress
168+
target:
169+
name: nginx
170+
port: 80
171+
protocol: http
172+
connection-tracking: connection-aware
173+
bind:
174+
external:
175+
host: my-static-site-eu.lttle.host
176+
protocol: https
177+
```
178+
179+
More about [services](../resources/services.md).
180+
181+
:::info HTTPS
182+
183+
All subdomains of `eu.lttle.host` are covered by our wildcard certificate.
184+
::::
185+
186+
:::note TODO
187+
188+
We should only allow binding to `something.eu.lttle.host` by some sort of rule.
189+
190+
Example: `something-namespace-tenant.eu.lttle.host`
191+
192+
:::
193+
194+
### Deploying to lttle.cloud
195+
196+
Now that we have our machine and service resources defined, we can deploy them to lttle.cloud.
197+
198+
Run the following command to deploy the machine:
199+
200+
```bash
201+
lttle deploy ./static-site.lttle.yaml
202+
```
203+
204+
You will see this output underlining the details of your current deployment:
205+
206+
```text
207+
Successfully deployed machine: static-site/nginx
208+
name: nginx
209+
namespace: static-site
210+
status: pulling-image
211+
mode: flash
212+
snapshot strategy: listen on port 80
213+
suspend timeout: 5s
214+
image: docker.io/username/image:tag
215+
cpus: 1
216+
memory: 64 MiB
217+
```
218+
219+
Now, we run the following command to deploy the service:
220+
221+
```bash
222+
lttle deploy ./service.lttle.yaml
223+
```
224+
225+
And you will get this output:
226+
227+
```text
228+
Successfully deployed service: static-site/ingress
229+
name: ingress
230+
namespace: static-site
231+
mode: external
232+
target: static-site/nginx
233+
target port: 80
234+
host: my-static-site-eu.lttle.host
235+
service ip: 10.1.136.41
236+
route: :443 (https) → :80 (http)
237+
connection tracking: connection aware
238+
```
239+
240+
:::info Deploy command output
241+
242+
The command outputs more information about the deployment process, we only included the most relevant parts here.
243+
244+
:::
245+
246+
## Seeing your deployment in action
247+
248+
Once your deployment is complete, you can visit https://my-static-site-eu.lttle.host in your web browser to see your static site in action. It may take a moment for the site to become available.
249+
250+
To see the details of your deployment in the CLI you can run the following command:
251+
252+
```bash
253+
lttle machine get --namespace static-site nginx
254+
```
255+
256+
Or you could visit the [lttle.cloud | Web Console](https://console.eu.lttle.host/) to see your deployment and its details.
257+
258+
:::info Delay
259+
260+
Right now there is a bit of a delay after your machine is ready or suspended.
261+
262+
:::
263+
264+
## Final notes
265+
266+
In this example we have deployed a static Astro site using Nginx machine. We have attached a service to that machine that routes traffic to and from it.
267+
268+
We have specified that the machine should be in [flash mode](../resources/machines.md#flash-mode) with a timeout of 5 seconds and that the service should be [connection-aware](../resources/services.md#connection-aware) of the it's target (the machine).
269+
270+
The result of this means that the machine will be snapshotted and suspended 5 seconds after Nginx starts listening on port 80 if there is no active connection to it. When a request comes in, the machine will be resumed from the snapshot and will start serving traffic until, again, there are no active connections to it, then the machine will be re-snapshotted and suspended immediately.
271+
272+
This is the main functionality of lttle.cloud and it allows you to run your workloads in a cost efficient manner. For a more detailed explanation of the machine states and lifecycle, please check [Machine State Lifecycle](../machine-state-lifecycle.md).
273+
274+
## More scenarios
275+
276+
If you want to deploy more complex applications we have prepared additional [guides & samples](../guides-and-samples/introduction.md) and dynamic templates via the lttle new.

docs/getting-started/installing-the-cli.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,37 @@ sidebar_position: 1
33
---
44

55
# Installing the CLI
6+
7+
The easiest way is to use the install script:
8+
9+
```sh
10+
curl -fsSL https://install.lttle.sh | bash
11+
```
12+
13+
---
14+
15+
If you want to build it from source, you will need to have Rust and Cargo installed. You can find instructions on how to do that [here](https://www.rust-lang.org/tools/install).
16+
17+
Then you can clone the repository:
18+
19+
```sh
20+
git clone git@github.com:lttle-cloud/ignition.git
21+
```
22+
23+
And then you can build the project using Cargo:
24+
25+
```sh
26+
cargo build --release
27+
```
28+
29+
And you will find it in `target/release/lttle`.
30+
31+
:::info Tip
32+
33+
You can symlink the binary to a directory in your PATH for easier access:
34+
35+
```sh
36+
ls -sr ./target/release/lttle ~/.local/bin/lttle
37+
```
38+
39+
:::
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Introduction
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Hello World in Go
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Hello World in Java
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Spring
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sidebar_position: 7
3+
---
4+
5+
# Angular

0 commit comments

Comments
 (0)