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 itlab.
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.
Start a web service
Open Projects, then
learn, and choose New service, then Web Service. Set Service name tosample-apiand pick thelabenvironment.You should seeThe new service form, with sample-api as its name and lab as its environment.
Point it at the sample app
Under Configuration, choose Container image, set Image name to
quay.io/computesphere/learn-sample-api:1.0.0and keep Public. Under Networking, set Port to8080; the console suggests 80.You should seeThe image name filled in, Public selected and Port 8080.
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.
See the defaults
Open your URL with
/helloon the end.{"api_key_set":false,"message":"Hello, world"}You should seeJSON with api_key_set false and message Hello, world.
Save the variable, not yet applied
In
sample-api, open Settings. Under Environment variables, choose Edit, then Add variable:GREETINGwith a greeting of your own. Choose Save, then Save only. Reload/hello.Check yourself
You should seeGREETING listed on the General tab, and /hello still says Hello, world.
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.
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.