Connecting to Services
This feature is currently in beta and only available through nctl. Cockpit support is not yet implemented.
Deploio applications can connect to On-Demand Services such as databases and key-value stores by declaring service references on the application. Nine automatically injects the connection credentials as environment variables into the app at runtime.
Under the hood, Nine automatically creates and manages an encrypted ServiceConnection in the target service's project. No manual networking setup is required.
Supported Services
The following service types can be referenced from a Deploio application:
Add a Service Reference
Each service reference requires a destination (the service to connect to).
- Cockpit
- nctl
When creating a new application, use --service with the format name=kind/target-name:
nctl create application my-app \
--git-url=https://github.com/example/app.git \
--service cache=keyvaluestore/my-kvs
To add a service to an existing application:
nctl update application my-app \
--service cache=keyvaluestore/my-kvs
To remove a service reference:
nctl update application my-app \
--delete-service cache
Injected Environment Variables
Once the service references are configured, Nine injects the connection details as environment variables into every instance of the application. Variables follow this naming format:
NINE_<SERVICE_TYPE>_<NAME>_<KEY>
For example, connecting to a Key-Value Store prod and a MySQL Database prod produces variables such as:
NINE_KEYVALUESTORE_PROD_URL=redis://...
NINE_MYSQLDATABASE_PROD_URL=mysql://...
The exact variable names and available keys depend on the service type.