Learning paths / Deploy on ComputeSphere / Data: databases and storage

Lab: data survives a redeploy

Verified lab · 25 min · Module 5, lesson 4 of 530 min left in this module

Module 5 · Data: databases and storageLesson 4 of 5

Self-checked for now. Automatic checking arrives with sign-in; until then, tick off each item under Check your work yourself.

Goal: Mount a SphereFiles volume on a service and prove the data on it outlives the spherelet, through restarts and redeploys.

You need Your lab environment, in US East or EU (Sweden), on any plan. The Files 10 GB volume you create adds $2.50 a month to your bill while you keep it (lesson 5.5.2).

About the notes app

It keeps one note in /data/note.txt. POST /note saves the request body there; GET /note returns it. It listens on port 8080.

In the curl commands, -X POST sends a POST request instead of a GET, and --data "…" is the body it sends.

When you're done, unmount the volume and delete it if you don't want to keep paying for it. Lab 6.8.4 uses it again.

  1. Deploy the notes app

    csph deploy --image quay.io/computesphere/learn-notes:1.5.0 --name notes --port 8080
    

    It runs on the defaults: Flex, 1 spherelet.

    You should seecsph prints Running and your notes URL.

  2. See the problem first

    curl -X POST --data "before restart" https://<your-notes-url>/note
    curl https://<your-notes-url>/note
    

    Restart notes (below), give it a minute, and read the note again. A restart replaces the spherelet the same way a redeploy with changes does, so it's the quickest way to test what survives. The old spherelet answers until the new one is ready. The note was on the old spherelet's own filesystem.

    Open notes, choose Restart, then Restart again in the dialog.

    You should seeThe note comes back, then after the restart the reply is empty.

  3. Create a volume

    In your lab environment's options menu, choose Storage management. Under SphereFiles volumes, choose New volume. Enter Name notes-data, pick Files 10 GB, and choose Create volume.

    On Hobby, an environment can have one volume. If this one already has another, delete that first or use it instead.

    You should seenotes-data in the SphereFiles volumes list, Files 10 GB.

  4. Mount it at /data

    Choose Open on notes-data. Under Mounts, choose Add mount, choose notes under Service, set Mount path to /data, and choose Mount volume. notes restarts its spherelet to pick up the volume.

    You should seeUnder Mounts: notes, Mount path /data.

  5. Save a note on the volume

    Use a value only you would write, such as your initials and today's date:

    curl -X POST --data "sk 2026-09-27" https://<your-notes-url>/note
    

    You should seeNo error from curl.

  6. Restart, then read it back

    Restart notes as in step 2 and give it a minute. Then:

    curl https://<your-notes-url>/note
    

    Check yourself

    The restart replaced the spherelet, just as in step 2. Why is the note still there this time?

    You should seeYour note, exactly as you saved it.

The volume isn't tied to one spherelet. Scale notes to 2 and both spherelets read the same /data/note.txt.

Check your work

  • If this doesn't pass

    The mount path must be exactly /data, on the service named notes. Open notes-data in Storage management and check its Mounts.

  • If this doesn't pass

    An empty reply usually means the note was saved before the volume was mounted. Save it again (step 5) and restart. If the URL doesn't answer, check notes is Running and read its deploy log.

In the docs