| 1 |
# Integration of eStargz with other tools |
| 2 |
|
| 3 |
This document lists links and information about integrations of stargz-snapshotter with tools in commuinty. |
| 4 |
|
| 5 |
You can refer to [issue #258 "Tracker issue for adoption status"](https://github.com/containerd/stargz-snapshotter/issues/258) for the list of the latest status of these integrations. |
| 6 |
|
| 7 |
## Kubernetes |
| 8 |
|
| 9 |
To use stargz snapshotter on Kubernetes nodes, you need to use containerd as the CRI runtime. |
| 10 |
You also need to run stargz snapshotter on the node. |
| 11 |
|
| 12 |
### Kind |
| 13 |
|
| 14 |
See [`/README.md#quick-start-with-kubernetes`](/README.md#quick-start-with-kubernetes). |
| 15 |
|
| 16 |
### k3s |
| 17 |
|
| 18 |
k3s >= v1.22 supports stagz-snapshotter as an experimental feature. |
| 19 |
`--snapshotter=stargz` for k3s server and agent enables this feature. |
| 20 |
|
| 21 |
``` |
| 22 |
k3s server --snapshotter=stargz |
| 23 |
``` |
| 24 |
|
| 25 |
Refer to [k3s docs](https://docs.k3s.io/advanced#enabling-lazy-pulling-of-estargz-experimental) for more details. |
| 26 |
|
| 27 |
The following is a quick demo using [k3d](https://github.com/k3d-io/k3d) (k3s in Docker). |
| 28 |
|
| 29 |
```console |
| 30 |
$ k3d cluster create mycluster --k3s-arg='--snapshotter=stargz@server:*;agent:*' |
| 31 |
$ cat <<'EOF' | kubectl --context=k3d-mycluster apply -f - |
| 32 |
apiVersion: v1 |
| 33 |
kind: Pod |
| 34 |
metadata: |
| 35 |
name: nodejs |
| 36 |
spec: |
| 37 |
containers: |
| 38 |
- name: nodejs-stargz |
| 39 |
image: ghcr.io/stargz-containers/node:17.8.0-esgz |
| 40 |
command: ["node"] |
| 41 |
args: |
| 42 |
- -e |
| 43 |
- var http = require('http'); |
| 44 |
http.createServer(function(req, res) { |
| 45 |
res.writeHead(200); |
| 46 |
res.end('Hello World!\n'); |
| 47 |
}).listen(80); |
| 48 |
ports: |
| 49 |
- containerPort: 80 |
| 50 |
EOF |
| 51 |
$ kubectl --context=k3d-mycluster get po nodejs -w |
| 52 |
$ kubectl --context=k3d-mycluster port-forward nodejs 8080:80 & |
| 53 |
$ curl 127.0.0.1:8080 |
| 54 |
Hello World! |
| 55 |
$ k3d cluster delete mycluster |
| 56 |
``` |
| 57 |
|
| 58 |
### Google Kubernetes Engine |
| 59 |
|
| 60 |
There is no node image includes stargz snapshotter by default as of now so you need to manually customize the nodes. |
| 61 |
|
| 62 |
A brief instrcution of enabling stargz snapshotter is the following: |
| 63 |
|
| 64 |
- Create a Kubernetes cluster using containerd-supported Linux node images like `ubuntu_containerd`. containerd must be >= v1.4.2. |
| 65 |
- SSH into each node and install stargz snapshotter following [`./INSTALL.md`](./INSTALL.md#install-stargz-snapshotter-for-containerd-with-systemd). You need this installation on all worker nodes. |
| 66 |
- Optionally apply configuration to allow stargz-snapshotter to access private registries following [`./overview.md`](./overview.md#authentication). |
| 67 |
|
| 68 |
### Amazon Elastic Kubernetes Service |
| 69 |
|
| 70 |
There is no AMI includes stargz snapshotter by default as of now so you need to manually customize the nodes. |
| 71 |
|
| 72 |
A brief instrcution of enabling stargz snapshotter is the following: |
| 73 |
|
| 74 |
- Create a Kubernetes cluster using containerd-supported Linux AMIs. containerd must be >= v1.4.2. e.g. Amazon EKS optimized Amazon Linux AMIs with [containerd runtime bootstrap flag](https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html). |
| 75 |
- SSH into each node and install stargz snapshotter following [`./INSTALL.md`](./INSTALL.md#install-stargz-snapshotter-for-containerd-with-systemd). You need this installation on all worker nodes. |
| 76 |
- Optionally apply configuration to allow stargz-snapshotter to access private registries following [`./overview.md`](./overview.md#authentication). |
| 77 |
|
| 78 |
## CRI runtimes |
| 79 |
|
| 80 |
### containerd |
| 81 |
|
| 82 |
See [`./INSTALL.md`](./INSTALL.md#install-stargz-snapshotter-for-containerd-with-systemd) |
| 83 |
|
| 84 |
> :information_source: There is also a doc for [integration with firecracker-containerd](https://github.com/firecracker-microvm/firecracker-containerd/blob/24f1fcf99ebf6edcb94edd71a2affbcdae6b08e7/docs/remote-snapshotter-getting-started.md). |
| 85 |
|
| 86 |
### CRI-O |
| 87 |
|
| 88 |
See [`./INSTALL.md`](./INSTALL.md#install-stargz-store-for-cri-opodman-with-systemd). |
| 89 |
|
| 90 |
## High-level container engines |
| 91 |
|
| 92 |
### Docker |
| 93 |
|
| 94 |
#### Moby |
| 95 |
|
| 96 |
Moby supports lazy pulling of eStargz since [`5c1d6c957b97321c8577e10ddbffe6e01981617a`](https://github.com/moby/moby/commit/5c1d6c957b97321c8577e10ddbffe6e01981617a) . |
| 97 |
See [`./INSTALL.md`](./INSTALL.md#install-stargz-snapshotter-for-dockermoby-with-systemd) for details. |
| 98 |
|
| 99 |
#### Docker Desktop |
| 100 |
|
| 101 |
Docker Desktop 4.12.0 "Containerd Image Store (Beta)" uses stargz-snapshotter. |
| 102 |
Refer to [Docker documentation](https://docs.docker.com/desktop/containerd/). |
| 103 |
|
| 104 |
### nerdctl |
| 105 |
|
| 106 |
See the [docs in nerdctl](https://github.com/containerd/nerdctl/blob/main/docs/stargz.md). |
| 107 |
|
| 108 |
### Podman |
| 109 |
|
| 110 |
See [`./INSTALL.md`](./INSTALL.md#install-stargz-store-for-cri-opodman-with-systemd). |
| 111 |
|
| 112 |
## Image builders |
| 113 |
|
| 114 |
### BuildKit |
| 115 |
|
| 116 |
#### Building eStargz |
| 117 |
|
| 118 |
BuildKit >= v0.10 supports creating eStargz images. |
| 119 |
See [`README.md`](/README.md#building-estargz-images-using-buildkit) for details. |
| 120 |
|
| 121 |
#### Lazy pulling of eStargz |
| 122 |
|
| 123 |
BuildKit >= v0.8 supports stargz-snapshotter and can perform lazy pulling of eStargz-formatted base images during build. |
| 124 |
`--oci-worker-snapshotter=stargz` flag enables this feature. |
| 125 |
|
| 126 |
You can try this feature using Docker Buildx as the following. |
| 127 |
|
| 128 |
``` |
| 129 |
$ docker buildx create --use --name lazy-builder --buildkitd-flags '--oci-worker-snapshotter=stargz' |
| 130 |
$ docker buildx inspect --bootstrap lazy-builder |
| 131 |
``` |
| 132 |
|
| 133 |
The following is a sample Dockerfile that uses eStargz-formatted golang image (`ghcr.io/stargz-containers/golang:1.18-esgz`) as the base image. |
| 134 |
|
| 135 |
```Dockerfile |
| 136 |
FROM ghcr.io/stargz-containers/golang:1.18-esgz AS dev |
| 137 |
COPY ./hello.go /hello.go |
| 138 |
RUN go build -o /hello /hello.go |
| 139 |
|
| 140 |
FROM scratch |
| 141 |
COPY --from=dev /hello / |
| 142 |
ENTRYPOINT [ "/hello" ] |
| 143 |
``` |
| 144 |
|
| 145 |
Put the following Go source code in the context directory with naming it `hello.go`. |
| 146 |
|
| 147 |
```golang |
| 148 |
package main |
| 149 |
|
| 150 |
import "fmt" |
| 151 |
|
| 152 |
func main() { |
| 153 |
fmt.Println("Hello, world!") |
| 154 |
} |
| 155 |
``` |
| 156 |
|
| 157 |
The following build performs lazy pulling of the eStargz-formatted golang base image. |
| 158 |
|
| 159 |
```console |
| 160 |
$ docker buildx build --load -t hello /tmp/ctx/ |
| 161 |
$ docker run --rm hello |
| 162 |
Hello, world! |
| 163 |
``` |
| 164 |
|
| 165 |
### Kaniko |
| 166 |
|
| 167 |
#### Building eStargz |
| 168 |
|
| 169 |
Kaniko >= v1.5.0 creates eStargz images when `GGCR_EXPERIMENT_ESTARGZ=1` is specified. |
| 170 |
See [`README.md`](/README.md#building-estargz-images-using-kaniko) for details. |
| 171 |
|
| 172 |
### ko |
| 173 |
|
| 174 |
ko >= v0.7.0 creates eStargz images when `GGCR_EXPERIMENT_ESTARGZ=1` is specified. |
| 175 |
Please see also [the docs in ko](https://github.com/ko-build/ko/blob/f70e3cad38c3bbd232f51604d922b8baff31144e/docs/advanced/faq.md#can-i-optimize-images-for-estargz-support). |
| 176 |
|
| 177 |
## P2P image distribution |
| 178 |
|
| 179 |
### IPFS |
| 180 |
|
| 181 |
See [`./ipfs.md`](./ipfs.md) |
| 182 |
|
| 183 |
### Dragonfly |
| 184 |
|
| 185 |
Change the `/etc/containerd-stargz-grpc/config.toml` configuration to make dragonfly as registry mirror. |
| 186 |
`127.0.0.1:65001` is the proxy address of dragonfly peer, |
| 187 |
and the `X-Dragonfly-Registry` header is the address of origin registry, |
| 188 |
which is provided for dragonfly to download the images. |
| 189 |
|
| 190 |
```toml |
| 191 |
[[resolver.host."docker.io".mirrors]] |
| 192 |
host = "127.0.0.1:65001" |
| 193 |
insecure = true |
| 194 |
[resolver.host."docker.io".mirrors.header] |
| 195 |
X-Dragonfly-Registry = ["https://index.docker.io"] |
| 196 |
``` |
| 197 |
|
| 198 |
For more details about dragonfly as registry mirror, |
| 199 |
refer to [How to use Dragonfly With eStargz](https://d7y.io/docs/setup/integration/stargz/). |
| 200 |
|
| 201 |
## Registry-side conversion of eStargz |
| 202 |
|
| 203 |
### Harbor |
| 204 |
|
| 205 |
See the docs in Harbor: https://github.com/goharbor/acceleration-service |