opack-cloud documenation, and image deletion on clean
This commit is contained in:
42
README.md
42
README.md
@@ -87,6 +87,7 @@ Then, `make opack-clean` will remove the VM, but not the vagrant box (in order t
|
||||
### Overrides Example
|
||||
|
||||
In this example, we will demonstrate how to use overrides in **skz-opack** to create an OpenBSD *-current* virtual machine named "run-current" with 4 CPUs and 1GB of RAM.
|
||||
|
||||
```make
|
||||
OPACK_TARGET= run-current
|
||||
OPACK_SYS_VERSION= snapshots
|
||||
@@ -96,7 +97,7 @@ OPACK_SYS_MEMORY= 1024
|
||||
include path/to/src/opack.mk
|
||||
|
||||
all: opack
|
||||
vagrant ssh -c "uname -a; sysctl kern.version"
|
||||
vagrant ssh -c "uname -a; sysctl -n kern.version"
|
||||
```
|
||||
|
||||
In this Makefile:
|
||||
@@ -106,18 +107,47 @@ In this Makefile:
|
||||
- **OPACK_SYS_CPU** allocates 4 CPUs to the VM.
|
||||
- **OPACK_SYS_MEMORY** assigns 1GB of RAM to the VM.
|
||||
|
||||
Making "opack" a dependency target of "all" will ensure **skz-opack** operates before any command in the "all" target. Try it with `make all` !
|
||||
Making *opack* a dependency target of *all* will ensure **skz-opack** operates before any command in the *all* target. Try it with `make all` !
|
||||
|
||||
Once the "opack" target dependency is finished, the VM is running and the system kernel version is outputted. This example showcases how to customize and run **skz-opack** for your specific needs.
|
||||
Once the *opack* target dependency is finished, the VM is running and the system kernel version is outputted. This example showcases how to customize and run **skz-opack** for your specific needs.
|
||||
|
||||
### GCE example
|
||||
|
||||
TODO
|
||||
Before using this example, you need to prepare the cloud environment:
|
||||
1. [Create a GCP project](https://cloud.google.com/resource-manager/docs/creating-managing-projects) and declare its name by overriding `OPACK_GCE_PROJECT`.
|
||||
2. [Create a service account](https://cloud.google.com/iam/docs/service-accounts-create) and [obtain its key](https://cloud.google.com/iam/docs/keys-create-delete), which path should be declared with `OPACK_GCE_JSON_KEY`.
|
||||
3. [Create a GCS Bucket](https://cloud.google.com/storage/docs/creating-buckets) and declare its name with 'OPACK_GCE_BUCKET' (defaults to `OPACK_GCE_PROJECT`).
|
||||
4. Enable the [Cloud Ressource Manager API](https://console.cloud.google.com/marketplace/product/google/cloudresourcemanager.googleapis.com) in order for the service account to use it with its key.
|
||||
|
||||
```make
|
||||
OPACK_TARGET= testopack-cloud
|
||||
OPACK_SYS_VERSION= snapshots
|
||||
OPACK_SYS_DISK_SIZE= 10000
|
||||
|
||||
OPACK_GCE_PROJECT= testopack
|
||||
OPACK_GCE_JSON_KEY= testopack-342b60ffed47.json
|
||||
|
||||
OPACK_AUTODISKLABEL_FILE= $(shell realpath ./autodisklabel)
|
||||
|
||||
include ../../src/opack.mk
|
||||
|
||||
all: opack-cloud
|
||||
ssh -i $(OPACK_SYS_SSH_PRIVATE_KEY) \
|
||||
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||
$(OPACK_SYS_USER)@$(shell cat opack-cloud) \
|
||||
"sysctl -n kern.version; uptime;" 2> /dev/null
|
||||
```
|
||||
|
||||
Here, a custom [disklabel](https://man.openbsd.org/disklabel#AUTOMATIC_DISK_ALLOCATION) path is used (see its [source](./examples/cloud/autodisklabel)).
|
||||
|
||||
Alongside the disk size which is increased to 10GB (corresponding to the GCP allocation for `e2-micro` instance), OpenBSD *-current* is used.
|
||||
|
||||
Once `opack-cloud` is finished, the VM is up and running in your GCP project. Upon calling `opack-clean`, the VM instance and its boot image will be destroyed.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- To enable debug mode, you can declare 'OPACK_DEBUG=yes' either in your Makefile or at runtime with: 'OPACK_DEBUG=yes make opack'.
|
||||
- Overrides should happen before the include of "opack.mk".
|
||||
- Overrides should happen **before** the include of `opack.mk`.
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -125,7 +155,7 @@ TODO
|
||||
|
||||
`OPACK_SYS_USER` can become *root* using the `doas` command.
|
||||
|
||||
The `autodisklabel` used for this project is flat, so partitions don't benefit from *nodev*, *nosuid* and *wxallowed* protections.
|
||||
The default `autodisklabel` used for this project is flat, so partitions don't benefit from *nodev*, *nosuid* and *wxallowed* protections.
|
||||
|
||||
### Code structure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user