Component ยท Shared or other
add-environment.sh
What it is
add-environment.sh is a shell script, in deployments/scripts of the Agent Manager repository, that the console's Create Environment command runs. The console shows the user a ready-made command with the environment name and a token. Run in a terminal that has kubectl and helm pointed at the cluster, the script creates the environment through Agent Manager, installs a ThunderID for it, then installs its gateway.
It is the move-in checklist for a new office floor: register the floor, install the door-badge system, then install the front desk, in that order.
Why it exists
A new environment needs pieces in several places: a record in Agent Manager and OpenChoreo, an identity server, and a gateway in the cluster. One idempotent script does them in the right order, and a re-run continues where an earlier run stopped.
How it works
- Step 0: it waits until Agent Manager answers on its health URL (AGENT_MANAGER_URL, default http://api.amp.localhost:8080).
- Step 1: it posts to /orgs/{org}/environments. HTTP 201 means created. HTTP 409 means the environment already exists, and the script carries on.
- Step 2: it downloads add-environment-thunder.sh and runs it, which installs the environment's own ThunderID from the upstream chart and registers its address handle with Agent Manager.
- Step 3: it runs helm upgrade --install for the gateway chart wso2-amp-api-platform-gateway-extension, with the environment's names and addresses.
- Step 4: it waits up to 180 seconds for the APIGateway resource to report Programmed.
Identity and access
It sends the bearer token it was given (AGENT_MANAGER_TOKEN) to Agent Manager. That token must be allowed to create environments (amp:environment:create). Cluster access comes from the user's own kubeconfig.
Key facts
- Required inputs
- ENV_NAME, DISPLAY_NAME, AGENT_MANAGER_TOKEN
- Optional
- IS_PRODUCTION, GATEWAY_TOPOLOGY (single or split), ORG_NAME, CHART_VERSION
- Needs
- kubectl and helm configured for the cluster
- Re-run
- Safe, with the same ENV_NAME
- Edition
- On-prem
Talks to (2)
- calls agent-manager-service (AMS) Script creates the environment; HTTP 409 is treated as already existingHTTP POST /api/v1/orgs/{org}/environments
- calls add-environment-thunder.sh Downloads and runs the env ThunderID install script when PROVISION_THUNDER is truecurl download then bash