let a second machine join the main node's k3s and run pods from images only the main node holds
This commit is contained in:
parent
9d9757c153
commit
6be1b59ffc
1 changed files with 1106 additions and 96 deletions
|
|
@ -26,7 +26,7 @@ the container environment).
|
|||
## The image set
|
||||
|
||||
Each of these is a flake package named `image-<daemon>`, and the image name is
|
||||
`hyperhive/<daemon>`:
|
||||
`registry.hyperhive.invalid/<daemon>` ([the registry host](#the-registry-host)):
|
||||
|
||||
- `swarm-controller`
|
||||
- `swarm-nats-auth`
|
||||
|
|
@ -55,6 +55,41 @@ nix eval --raw .#image-swarm-logs-auth.imageName
|
|||
nix eval --raw .#image-swarm-logs-auth.imageTag
|
||||
```
|
||||
|
||||
## The registry host
|
||||
|
||||
Every image name starts with `registry.hyperhive.invalid`, which
|
||||
`mkServiceImage` takes from `registryHost` in `nix/images/default.nix`.
|
||||
RFC 6761 reserves `.invalid`, and it never resolves, so the name has no
|
||||
registry behind it. Containerd expands a name with no host, such as
|
||||
`hyperhive/<daemon>`, to `docker.io/hyperhive/<daemon>`, and a node that holds
|
||||
no copy would ask Docker Hub for it. With this host the pull fails instead.
|
||||
|
||||
## Where a node gets an image
|
||||
|
||||
The main node imports the tarballs into containerd before k3s starts, and
|
||||
k3s's embedded registry mirror (`--embedded-registry`, on the main node) shares
|
||||
what a node holds with the others. `/etc/rancher/k3s/registries.yaml` on every
|
||||
node enables the mirror for the one host:
|
||||
|
||||
```yaml
|
||||
mirrors:
|
||||
registry.hyperhive.invalid:
|
||||
```
|
||||
|
||||
k3s documents the flag, the file and the rule that applies here: a node shares
|
||||
images it imported from a tarball when their tag names a registry the file
|
||||
enables for mirroring, and the upstream registry doesn't have to exist
|
||||
(<https://docs.k3s.io/installation/registry-mirror>). The file names only this
|
||||
host and not `"*"`, so the node's pulls of public images stay direct.
|
||||
|
||||
A pod that lands on a node without its image, a node that joined, pulls the
|
||||
image from a peer that holds it (`imagePullPolicy: IfNotPresent`). If no peer
|
||||
holds it, for instance because the main node is down and the node never had
|
||||
the image, the pull fails with the host's name in the error, and the pod
|
||||
retries once a peer has the image. Images a node holds stay: k3s doesn't
|
||||
prune imported tarball images. The mirror doesn't share a `latest` tag, and
|
||||
the tags here are content hashes.
|
||||
|
||||
## Loading an image
|
||||
|
||||
`nix build` produces a `.tar.gz` that `podman load`, `skopeo` and the k3s image
|
||||
|
|
|
|||
Loading…
Reference in a new issue