Skip to content

Commit 61dbbde

Browse files
committed
README: Whole bunch of updates
This reworks the README with a bunch of fixes, including but not limited to: Updating with respect to the rest of the tinkerbell project Simpler sentences Grammar/spelling fixes Better nix help Better syntax highling for terminal sessions Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
1 parent 3fc04c3 commit 61dbbde

File tree

1 file changed

+61
-56
lines changed

1 file changed

+61
-56
lines changed

README.md

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,35 @@ It runs in-memory, installs operating system, and handles deprovisioning.
55

66
## Motivation
77

8-
<!-- TODO: Move this to the documentation repository once this is part of the Tinkerbell organisation. -->
9-
10-
One of the [Tinkerbell] components is the operating system installation environment.
11-
Currently, Tinkerbell uses [OSIE].
12-
That implementation is open-sourced by Equinix Metal and it is serving the purpose of provisioning and de-provisioning hardware at a huge scale.
13-
But why we started this project?
14-
15-
- Because we like to Hack the Kernel!
16-
- Tinkerbell architecture leaves an open door in terms of the operating system installation environment you can use, it serves one for simplicity ,but users can write their own.
8+
One of the [Tinkerbell] components is the Operating System Installation Environment (OSIE).
9+
The Tinkerbell project originally used [OSIE] as its default OSIE.
10+
That implementation was open-sourced by Equinix Metal as is and was difficult to modify/extend.
11+
(Not to mention confusing, [OSIE] is our OSIE, hook is a new OSIE and you can have your very own OSIE too)
12+
We started this project for the following reasons:
13+
14+
- Because we like to hack on the Kernel!
15+
- Tinkerbell architecture leaves an open door in terms of the OSIE you can use, one is provided by default for simplicity, but users can write their own.
1716
This is an implementation to validate that the model works (it does!! this is why we are here)
18-
- Looking at the CI/CD build time for OSIE is ~1h on average
19-
- The building process is not standardised, which is critical for an open-source project because it causes friction for contributors.
20-
This project, as highlighted later in this page, uses [LinuxKit] a tool provided by Docker, now part of the Linux Computing Foundation.
17+
- Looking at the CI/CD build time for [OSIE] was ~1h on average
18+
- The [OSIE] build process was not standardised, which is critical for an open-source project because it causes friction for contributors.
19+
This project, as highlighted later in this page, uses [LinuxKit].
2120
It gives us:
2221
- Documentation about how the building phase works
2322
- A clear and defined CLI and [specification] (YAML)
24-
- A community that is built and supportive
23+
- A shared community that is supportive
2524
- LinuxKit cross-compiles in many architectures
26-
- [Different output formats]: ISO, init ramkdisk, aws, docker, rpi3...
27-
- It is not easy to explain to the Tinkerbell community how OSIE works and the components it is made for, a lot of them are coming from specific Equinix Metal operational experience and they are not strictly needed in Tinkerbell.
28-
There is an ongoing conversation from the contributors about a replacement or a complete refactoring for OSIE.
25+
- Different output formats: ISO, init ramkdisk, aws, docker, rpi3... see [formats].
26+
- It was not easy to explain to the Tinkerbell community how [OSIE] works and the components it is made for.
27+
A lot of the components were Equinix Metal specific and are not strictly needed in Tinkerbell.
2928

3029
## Architecture
3130

32-
The hook project aims to provide an "in-place" swappable set of files (`kernel`/`initramfs`) that can be used to replace the [OSIE] environment that comes from Equinix Metal.
31+
The hook project aims to provide an "in-place" swappable set of files (`kernel`/`initramfs`) that can be used to function as the Tinkerbell OSIE.
3332
The key aims of this new project:
3433

3534
- Immutable output
3635
- Batteries included (but swappable if needed)
37-
- Ease of build (Subsequent builds of hook are ~47 seconds)
36+
- Ease of build (subsequent builds of hook are ~47 seconds)
3837
- Lean / simple design
3938
- Clean base to build upon
4039

@@ -43,31 +42,37 @@ The linuxkit project combines a Linux kernel with a number of additional contain
4342
We have built upon the minimal set of components:
4443

4544
- containerd (the engine to start/stop all other components in a LinuxKit OS)
46-
- dhcp (for network access)
47-
- ntp (network time)
45+
- dhcpd (for network access)
46+
- ntpd (network time)
4847
- rngd (random number gen for entropy)
4948

5049
To this minimal build, we've added our own set of containers that will provide the functionality needed for a `tink-worker` to run successfully:
5150

5251
### hook-docker
5352

54-
The `hook-docker` container builds upon the upstream `dind` (docker-in-docker) container and adds the additional functionality to retrieve the certificates needed for the docker engine to communicate with the Tinkerbell repository **before** it starts the docker engine.
55-
The docker engine will be exposed through the `/var/run/docker.sock` that will use a bind mount so that the container `hook-bootkit` can access it.
53+
The `hook-docker` container builds upon the upstream `dind` (docker-in-docker) container.
54+
It adds the additional functionality to retrieve the certificates needed for the docker engine to communicate with the Tinkerbell repository **before** it starts the docker engine.
55+
The docker engine will be exposed through the `/var/run/docker.sock` that will use a bind mount so that the container `bootkit` can access it.
5656

5757
### hook-bootkit
5858

5959
The `hook-bootkit` container will parse the `/proc/cmdline` and the metadata service in order to retrieve the specific configuration for tink-worker to be started for the current/correct machine.
60-
It will then speak with the `hook-docker` engine API through the shared `/var/run/docker.sock`, where it will ask the engine to run the `tink-worker:latest` container, which in turn will begin to execute the workflow/actions associated with that machine.
60+
It will then speak with the `hook-docker` engine API through the shared `/var/run/docker.sock`, where it will ask the engine to run the `tink-worker:latest` container.
61+
`tink-worker:latest` will in turn begin to execute the workflow/actions associated with that machine.
6162

6263
## How to use hook with Sandbox
6364

64-
[sandbox] is a project that helps you to create and run the Tinkerbell stack locally with Vagrant, on Equinix Metal with Terraform and, acts as a guide to deploying Tinkerbell wherever you like.
65-
I will tell you how you can change the default operating system installer environment called [OSIE] with this project.
65+
[sandbox] is a project that helps you to create and run the Tinkerbell stack.
66+
You can use it to run the stack locally with Vagrant, on Equinix Metal with Terraform or just plain docker-compose.
67+
It acts as a guide to deploying Tinkerbell wherever you like.
68+
Hook has become the default OSIE in sandbox, thus no extra action is needed to use hook.
69+
6670

67-
There are essentially two methods a manual one and a more automatic one.
68-
Have a look at the manual one even if you intend to use the automatic one to learn what what the automation does for you.
71+
## How to build and use hook with Sandbox
6972

70-
### The manual way
73+
### Using a published build
74+
75+
### Using a local/unpublished build
7176

7277
When you start sandbox in vagrant, for example as part of the provisioning step for the provisioner machine the `setup.sh` script gets executed.
7378
The script does a bunch of things the one we care about here is the `setup_osie` function.
@@ -77,15 +82,15 @@ If you ran sandbox you already have that directory.
7782
You can even move or delete that directory because we have to replace it with the release package containing the new operating system.
7883
After you have removed the directory, it is time to re-create it:
7984

80-
```
85+
```ShellSession
8186
# check out this repo
82-
git clone https://github.com/tinkerbell/hook.git
87+
$ git clone https://github.com/tinkerbell/hook.git
8388

8489
# build it - this produces a hook-<commit SHA>.tar.gz
85-
make dist
90+
$ make dist
8691

8792
# copy the output to current (the filename will be different)
88-
tar -xf hook-bc3e58a-dirty.tar.gz -C ../sandbox/deploy/state/webroot/misc/osie/current/
93+
$ tar -xf hook-bc3e58a-dirty.tar.gz -C ../sandbox/deploy/state/webroot/misc/osie/current/
8994
```
9095

9196
Now you are ready to boot the worker, it will pick up the new operating system installation environment.
@@ -97,63 +102,63 @@ If you change `OSIE_DOWNLOAD_LINK` with the hook link the setup.sh script will d
97102

98103
## Package a release
99104

100-
```
101-
make dist
105+
```ShellSession
106+
$ make dist
102107
```
103108

104109
The `dist` make target will do a couple of things:
105110

106111
1. Build the required docker images using `docker buildx`.
107112
2. It will use `linuxkit build` to prepare the init ramdisk and the kernel.
108-
3. It will create a `tar.gz` archive in the root of the project containing all the files in the proper format, ready to be served via boots.
113+
3. It will create a `tar.gz` archive containing all the files in the proper format, ready to be served via boots.
109114

110115
## Build for local testing (only the local architecture)
111116

117+
```ShellSession
118+
$ make dev
112119
```
113-
make dev-dist
114-
```
115-
116-
## Next steps
117-
118-
- Test passing pid:host to hook-docker, this should allow graceful reboots [done]
119-
- Re-write a bunch of actions that are un-manageable shell scripts (disk management being the first) [done]
120120

121121
## Troubleshooting
122122

123123
It is possible to build a debug version of hook, that will have an `sshd` server running with any public keys you have.
124-
This is achieved through the command `make debug-images`
124+
This is achieved through the command `make debug`
125125

126126
## Nix for CI/CD
127127

128128
This project uses Nix for a couple of reasons.
129-
We want to use it more intensively to see if it can help me quickly iterate over CI/CD.
130-
We think we like it, but are not convinced yet.
131-
Anyway, if you are not into Nix and don't like it, here are a few tips.
129+
We want to use it more intensively to see if it can help us quickly iterate over CI/CD.
130+
If you are not into Nix and don't like it, here are a few tips.
132131

133-
First you can use Docker:
132+
Don't want to install?
133+
Just use Docker:
134134

135-
```terminal
136-
$ docker run -it -v nix-build-cache:/nix/store -v $PWD:/opt -v /var/run/docker.sock:/var/run/docker.sock --workdir /opt nixos/nix sh
135+
```ShellSession
136+
$ docker run -it -v "$PWD:$PWD" -w "$PWD" -v /var/run/docker.sock:/var/run/docker.sock nixos/nix bash
137137

138138
# now you are inside the container and you can use nix-shell to reproduce the environment
139139
$ nix-shell
140140
$ make dev
141141

142142
# or you can use make to build LinuxKit image
143-
$ make image
143+
$ make images
144144
```
145145

146-
Second: you can copy paste `./hack/build-and-deploy.sh` elsewhere and change the shebang:
146+
This will take a moment or so to download and build packages.
147+
You can pay this price only once by building a "dev" image.
147148

148-
```
149-
#!/usr/bin/env nix-shell
150-
#!nix-shell -i bash ../shell.nix
149+
```ShellSession
150+
$ docker buildx build --load -t hook-nix-dev -f hack/Dockerfile .
151+
152+
# just use the built image/tag instead of nixos/nix in the previous snipped
153+
$ docker run -it -v "$PWD:$PWD" -w "$PWD" -v /var/run/docker.sock:/var/run/docker.sock hook-nix-dev bash
151154
```
152155

153-
With `#!/bin/bash` or something similar.
156+
Alternitavely, don't use nix at all.
157+
We use nix-shell just for binaries/$PATH management, so if you have the binaries available you don't need nix at all.
158+
Of course be prepared for CI to complain about formatting/linting due to possible version differences.
154159

155160
[current_versions.sh]: https://github.com/tinkerbell/sandbox/blob/main/current_versions.sh
156-
[different output formats]: https://github.com/linuxkit/linuxkit/blob/master/README.md#booting-and-testing
161+
[formats]: https://github.com/linuxkit/linuxkit/blob/master/README.md#booting-and-testing
157162
[linuxkit]: https://github.com/linuxkit/linuxkit
158163
[osie]: https://github.com/tinkebell/osie
159164
[sandbox]: https://github.com/tinkerbell/sandbox

0 commit comments

Comments
 (0)