Skip to content

Commit

Permalink
03: update image instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
katilp committed Oct 16, 2024
1 parent dd2fd97 commit 8a45951
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
21 changes: 10 additions & 11 deletions episodes/03-disk-image-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,16 @@ Writing superblocks and filesystem accounting information: done
## Mount the disk
```
kati@vm-work ~ $ sudo mkdir -p /mnt/disks/img
kati@vm-work ~ $ sudo mount -o discard,defaults /dev/sdb /mnt/disks/img
kati@vm-work ~ $ sudo chmod a+w /mnt/disks/img
$ sudo mkdir -p /mnt/disks/img
$ sudo mount -o discard,defaults /dev/sdb /mnt/disks/img
$ sudo chmod a+w /mnt/disks/img
```
## Configure docker and pull the image
Modify the docker config file to store data in the mounted disk
Add a line `"data-root": "/mnt/disks/img"` to the docker config file `/etc/docker/daemon.json` so that docker stores data in the mounted disk. The file becomes:
```
$ cat /etc/docker/daemon.json
{
"live-restore": true,
"log-opts": {
Expand All @@ -159,34 +158,34 @@ $ cat /etc/docker/daemon.json
}
```
Remember the comma before the line that you add!
Remember the comma before the line that you added! I made the mistake, you do not have to...
Restart the docker service
```
sudo systemctl restart docker
```
Pull the images that you need
Pull the images that you need. In the example workflow we use three of them (in addition to a tiny python image), so we pull:
```
docker pull ghcr.io/katilp/pfnano-image-build:main

docker pull cernopendata/cernopendata-client

docker pull rootproject/root:latest
```
After the pull is ready, you can see them with:
```
kati@vm-work ~ $ docker image ls
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
rootproject/root latest 34eb35079484 4 weeks ago 2.76GB
cernopendata/cernopendata-client latest f690d7308889 7 weeks ago 282MB
ghcr.io/katilp/pfnano-image-build main d95521bc96a9 11 months ago 32.1GB
```
Exit from the VM and stop it
Exit from the VM with `exit` and stop it
```
gcloud compute instances stop vm-work
Expand Down
25 changes: 19 additions & 6 deletions episodes/03-disk-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ gcloud projects add-iam-policy-binding <PROJECT_ID> --member serviceAccount:<PRO
gcloud projects add-iam-policy-binding <PROJECT_ID> --member serviceAccount:<PROJECT_NR>@cloudbuild.gserviceaccount.com --role roles/compute.admin
```

In addition, on the storage side, the compute service account needs write access to the bucket for the logs. Add it with

```bash
gcloud storage buckets add-iam-policy-binding gs://<BUCKET_FOR_LOGS>/ --project=<PROJECT_ID> --member=serviceAccount:<PROJECT_NR>[email protected] --role=roles/storage.objectCreator
```
### Application login

You need to create a credential file to run the script:
Expand Down Expand Up @@ -138,7 +133,25 @@ Run the script with
go run ./cli --project-name=<PROJECT_ID> --image-name=pfnano-disk-image --zone=europe-west4-a --gcs-path=gs://<BUCKET_FOR_LOGS> --disk-size-gb=50 --container-image=ghcr.io/katilp/pfnano-image-build:main --timeout 100m
```

For the moment, for a new project created for testing these instructions, this fails. Investigating...
:::::::::::::::::::::::::::::::::::::::::: spoiler

### Error: Quota exceeded?

Failure with errors of type

```
Code: QUOTA_EXCEEDED
Message: Quota 'N2_CPUS' exceeded.
```

are due to requested machine type no being available in the requested zone. Nothing to do with you quota.

Try in a different region or with a different machine type. You can give them as parameters e.g. `--zone=europe-west4-a --machine-type=e2-standard-4`

Note that the bucket for logs has to be in the same region so you might need to create another one. Remove the old one with `gcloud storage rm -r gs://<BUCKET_FOR_LOGS>`.

::::::::::::::::::::::::::::::::::::::::::::::::


## Costs

Expand Down

0 comments on commit 8a45951

Please sign in to comment.