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 SphereStor volume on a service and prove the data on it outlives the spherelet, through restarts and redeploys.

You need A Pro, Team or Enterprise plan, 1 GB of SphereStor quota ($0.25 a month; lesson 5.5.2) and your lab environment.

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, delete it, and remove the quota if you don't want to keep paying for it.

  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, open the Storage tab and choose New SphereStor volume. Enter Volume name notes-data and Storage size (GB) 1, and choose Create.

    You should seenotes-data in the volume list, 1 GB.

  4. Mount it at /data

    Open notes, then Settings. On the Storage card, choose Configure storage, pick notes-data, set Mount path to /data, and choose Save. Then choose Mount, and Mount in the dialog. notes restarts with the volume.

    You should seeThe Storage card shows Mounted and 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.

Keep notes at 1 spherelet: a volume attaches to one spherelet at a time.

Check your work

  • If this doesn't pass

    The mount path must be exactly /data, on the service named notes. If the Storage card says Unmounted, choose Mount.

  • 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