Lab: configure without rebuilding

Verified lab · 30 min · Path challenge

Path challengeApplication foundations

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

Goal: Deploy a service from the console, give it a variable and a secret, and prove the running app sees both without a new build.

You need A ComputeSphere account, and a project called learn with an environment called lab.

Setting these up
  • Account: sign up at console.computesphere.com. Sign-up asks for a card; the first 14 days are a free trial.
  • Project and environment: open Projects, choose New project and name it learn. Open it, choose New environment and name it lab.

Lesson 5.1.1, Set up, has both in more detail. You don't need csph: everything here happens in the console.

You'll deploy a ready-made sample app. Its GET /hello returns the GREETING variable and whether API_KEY is set, never the key itself.

  1. Start a web service

    Open Projects, then learn, and choose New service, then Web Service. Set Service name to sample-api and pick the lab environment.

    You should seeThe new service form, with sample-api as its name and lab as its environment.

  2. Point it at the sample app

    Under Configuration, choose Container image, set Image name to quay.io/computesphere/learn-sample-api:1.0.0 and keep Public. Under Networking, set Port to 8080; the console suggests 80.

    You should seeThe image name filled in, Public selected and Port 8080.

  3. Deploy it

    Leave Variables empty. Under Size selection, keep Spherelets at 1; the service runs as a Flex spherelet. Choose Deploy, then View service in the Deployment complete dialog.

    You should seeA Deployment complete dialog, then sample-api Running with its URL at the top of the page.

  4. See the defaults

    Open your URL with /hello on the end.

    {"api_key_set":false,"message":"Hello, world"}
    

    You should seeJSON with api_key_set false and message Hello, world.

  5. Save the variable, not yet applied

    In sample-api, open Settings. Under Environment variables, choose Edit, then Add variable: GREETING with a greeting of your own. Choose Save, then Save only. Reload /hello.

    Check yourself

    The variable is saved. Why does /hello still say Hello, world?

    You should seeGREETING listed on the General tab, and /hello still says Hello, world.

  6. Add the secret and redeploy

    Switch to the Secrets tab, choose Edit, then Add secret: API_KEY = demo-not-a-real-key-0000. Choose Save, then Save & redeploy: one redeploy applies both. No build runs; the same image starts with new values. The status stays Running, because the new copy starts before the old one stops.

    You should seeAPI_KEY on the Secrets tab with its value hidden, and sample-api still Running.

  7. Call it again

    Reload /hello.

    {"api_key_set":true,"message":"<your greeting>"}
    

    You should seeJSON with api_key_set true and your greeting.

Check your work

  • If this doesn't pass

    Names are exact. If it landed in another environment, delete it and create it again in lab.

  • If this doesn't pass

    Names are case-sensitive. GREETING belongs on the General tab, API_KEY on the Secrets tab.

  • If this doesn't pass

    If you chose Save only both times, nothing was applied. Save any change with Save & redeploy, or choose Redeploy at the top of the service page.

  • If this doesn't pass

    Still Hello, world: redeploy. No answer at all: check the Port is 8080 in Settings, and read the service's deploy log under Logs.