|
| 1 | +# spind |
| 2 | + |
| 3 | +spind is a fast local development environment for people who build web applications that use the Kubernetes API, and for people who build Kubernetes Operators. |
| 4 | + |
| 5 | +It supports kind-based Kubernetes environments and makes clean environments fast to create, reset, and start. |
| 6 | + |
| 7 | +## Why spind? |
| 8 | + |
| 9 | +Kubernetes development and testing often need a clean Kubernetes environment. Creating that environment every time is slow. |
| 10 | + |
| 11 | +Common setup steps can take seconds or minutes: |
| 12 | + |
| 13 | +- `kind create cluster` can take about 30 seconds. |
| 14 | +- `helm install` can take several minutes. |
| 15 | +- End-to-end tests and integration tests often need a clean cluster. |
| 16 | +- CI runs can spend several minutes only preparing the environment. |
| 17 | + |
| 18 | +During development, you often create an environment, test something, break it, delete it, and create it again. That wait makes the development loop slow. |
| 19 | + |
| 20 | +spind reduces setup time from minutes to less than 1000 ms by restoring a ready VM snapshot. |
| 21 | + |
| 22 | +This makes development, manual checks, end-to-end tests, integration tests, CI, and CD faster. |
| 23 | + |
| 24 | +## How it works |
| 25 | + |
| 26 | +spind is built around microVMs and snapshots. |
| 27 | + |
| 28 | +On macOS, spind starts a small Linux VM with Virtualization.framework. On Linux, spind starts a small Linux VM with Cloud Hypervisor. |
| 29 | + |
| 30 | +The Linux VM is not a special Kubernetes system. It is a small Docker machine. You can use your normal Docker client, kind, kubectl, and helm. |
| 31 | + |
| 32 | +spind sets up the runtime VM once, then saves that ready state as a snapshot. After that, spind restores from the snapshot. This lets you start an environment where the kind cluster and Helm charts are already prepared. |
| 33 | + |
| 34 | +## Use cases |
| 35 | + |
| 36 | +- Web applications that use the Kubernetes API |
| 37 | +- Kubernetes Operator development |
| 38 | +- Local Kubernetes development with kind |
| 39 | +- Clean environments for end-to-end tests and integration tests |
| 40 | +- Faster Kubernetes environment setup in CI/CD |
| 41 | + |
| 42 | +## Install |
| 43 | + |
| 44 | +Install spind with `go install`. |
| 45 | + |
| 46 | +```sh |
| 47 | +go install github.com/suin/spind/cmd/spind@latest |
| 48 | +``` |
| 49 | + |
| 50 | +After installing, check your host dependencies. |
| 51 | + |
| 52 | +```sh |
| 53 | +spind doctor |
| 54 | +``` |
| 55 | + |
| 56 | +## Dependencies |
| 57 | + |
| 58 | +`spind doctor` checks the dependencies needed on your current host. This section gives the basic list. |
| 59 | + |
| 60 | +Common: |
| 61 | + |
| 62 | +- Go |
| 63 | +- Docker CLI |
| 64 | + |
| 65 | +macOS: |
| 66 | + |
| 67 | +- Apple Swift compiler |
| 68 | +- `codesign` |
| 69 | +- Xcode Command Line Tools |
| 70 | +- A macOS environment that supports Virtualization.framework |
| 71 | + |
| 72 | +Linux: |
| 73 | + |
| 74 | +- A Linux environment with KVM support |
| 75 | +- `/dev/kvm` |
| 76 | +- `cloud-hypervisor` |
| 77 | +- `passt` |
| 78 | +- `virtiofsd` |
| 79 | + |
| 80 | +Docker image builds need the Docker CLI. On Linux, `passt` and `virtiofsd` are also used for Docker host support, snapshot restore support, and host path sharing. |
| 81 | + |
| 82 | +## Basic usage |
| 83 | + |
| 84 | +Put `spind.yaml` in your project root. |
| 85 | + |
| 86 | +```yaml |
| 87 | +name: sample |
| 88 | +image: docker |
| 89 | +kind: true |
| 90 | +setup: |
| 91 | + - "kind create cluster" |
| 92 | + - "kubectl --context kind-kind wait node --all --for=condition=Ready --timeout=180s" |
| 93 | +``` |
| 94 | +
|
| 95 | +Start the development environment. |
| 96 | +
|
| 97 | +```sh |
| 98 | +spind up |
| 99 | +``` |
| 100 | + |
| 101 | +On the first run, spind creates a VM, runs the commands in `setup`, and saves the ready state as a snapshot. Later runs restore from that snapshot. |
| 102 | + |
| 103 | +## Development |
| 104 | + |
| 105 | +Use these commands when working on this repository. |
| 106 | + |
| 107 | +```sh |
| 108 | +task build |
| 109 | +task check |
| 110 | +task test |
| 111 | +task test:ts |
| 112 | +``` |
| 113 | + |
| 114 | +Run end-to-end tests: |
| 115 | + |
| 116 | +```sh |
| 117 | +task e2e |
| 118 | +``` |
| 119 | + |
| 120 | +## Design docs |
| 121 | + |
| 122 | +Detailed design notes are in `docs/design/`. |
| 123 | + |
| 124 | +- `docs/design/minimum-cli.md` |
| 125 | +- `docs/design/project-up.md` |
| 126 | +- `docs/design/docker-host.md` |
| 127 | +- `docs/design/kind-ready-snapshot.md` |
| 128 | +- `docs/design/snapshot.md` |
| 129 | +- `docs/design/roadmap.md` |
0 commit comments