You need csph signed in, with your lab project and environment as defaults (lesson 5.1.1).
Deploy the sample API
csph deploy --image quay.io/computesphere/learn-sample-api:1.0.0 --name sample-api --port 8080Its
GET /helloreturns theGREETINGvariable and whetherAPI_KEYis set, never the key itself.You should seecsph prints Running and your sample-api URL.
See the defaults
curl https://<your-sample-api-url>/hello{"api_key_set":false,"message":"Hello, world"}You should seeJSON with api_key_set false and message Hello, world.
Add the variable and the secret
Open
sample-api, go to Settings, and in Environment variables choose Edit on the General tab. AddGREETING=Hello from ComputeSphere, Save, and choose Save only. On the Secrets tab, choose Edit, addAPI_KEYwith a made-up value, Save, and choose Save & redeploy: one rollout applies both.read -s LAB_API_KEY && export LAB_API_KEY # type a made-up key, then Enter csph services variables set GREETING="Hello from ComputeSphere" --service <service-id> csph services secrets set API_KEY="$LAB_API_KEY" --service <service-id>Each command redeploys.
csph services listshows the service ID.You should seesample-api stays Running while the new version rolls out. Give it a minute before the next step.
Call it again
Once it's Running:
curl https://<your-sample-api-url>/hello{"api_key_set":true,"message":"Hello from ComputeSphere"}You should seeJSON with api_key_set true and message Hello from ComputeSphere.
See what others can see
Back in Settings, compare the two tabs.
csph services secrets list --service <service-id>prints the secret's name and nothing else.You should seeThe variable's value in full; the secret as its name and dots.
Check your work
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
You chose Save only and didn't redeploy afterwards. Choose Redeploy on sample-api. Restart isn't enough (lesson 5.4.2).
If this doesn't pass
Still Hello, world: the value is saved but not running yet, so redeploy. No answer at all: read the deploy log (lesson 5.1.3).