An open source alternative to AWS RDS, Cloud SQL.
The idea is simple. Spinup creates multiple containers through docker-compose. Spinup can be deployed anywhere. System requirements are Go and docker-compose. Once this issue has been fixed then you don't need to have Go installed. It can run on Digital Ocean droplet, Azure Compute, Oracle Compute, Raspberry Pi etc.
We are currently using Github Authentication. We should be able to support other authentication methods.
Currently we only support Postgres dbms, but we should be able to support other open source databases like MySQL, MariaDB etc.
To get started with Spinup on Linux:
- Run the installation script using the command below:
bash < <(curl -s https://raw.githubusercontent.com/spinup-host/spinup/main/scripts/install-spinup.sh)
- Add the Spinup installation directory (default is
$HOME/.local/spinup
) to your shell PATH to use Spinup from your terminal. - Start the Spinup servers (both API and frontend) by running:
spinup start
- (Optional) If you want to use Github Authentication, create a project in github. Next, export the project's client ID and Secret as environment variables
export CLIENT_ID=<GITHUB_CLIENT_ID>
export CLIENT_SECRET=<GITHUB_CLIENT_SECRET>
- (Optional) You can change the API_KEY value using enviornment variable. Default value is
spinup
export SPINUP_API_KEY=<YOUR_API_KEY>
To create a private key
visi@visis-MacBook-Pro spinup % openssl genrsa -out /${SPINUP_PROJECT_DIR}/app.rsa 4096
Generating RSA private key, 4096 bit long modulus
...++
...................++
e is 65537 (0x10001)
To create a public key
visi@visis-MacBook-Pro spinup % openssl rsa -in /${SPINUP_PROJECT_DIR}/app.rsa -pubout > /${SPINUP_PROJECT_DIR}/app.rsa.pub
writing RSA key
Create a config.yaml file
common:
ports: [
5432, 5433, 5434, 5435, 5436, 5437
]
architecture: amd64
projectDir: <PROJECT_DIR>
client_id: <CLIENT_ID>
client_secret: <CLIENT_SECRET>
api_key: <API_KEY> //if not using github authentication
To run spinup
go run main.go
We use JWT for verification. You need to have a private and public key that you can create using OpenSSL:
On another terminal you can start the dash to access the backend.
To check the API endpoint:
curl -X POST http://localhost:4434/createservice \
-H "Content-Type: application/json" \
-H "Authorization: Bearer reaplaceyourtokenhere" \
--data '{
"userId": "viggy28",
"db": {
"type": "postgres",
"name": "localtest",
"username": "spinup",
"password": "spinup",
"memory": 6000, //In Megabytes
"cpu": 2
},
"version": {"maj":9,"min":6}
}'
Once you created a cluster, you can connect using psql or any other postgres client
visi@visis-MacBook-Pro ~ % psql -h localhost -U postgres -p <port>
Password for user postgres:
psql (9.6.18, server 13.3 (Debian 13.3-1.pgdg100+1))
WARNING: psql major version 9.6, server major version 13.
Some psql features might not work.
Type "help" for help.
postgres=# \dt
- URL
/githubAuth
- Method:
POST
- Data Params
{
"code": "githubcode"
}
-
Success Response:
- Code: 200
- Content:
{"login":"","avatar_url":"","name":"","token":""}
-
Error Response:
-
Code: 404 NOT FOUND
Content:
{ error : "User doesn't exist" }
OR
-
Code: 401 UNAUTHORIZED
Content:
{ error : "You are unauthorized to make this request." }
-
- URL
/altauth
- Method:
POST
x-api-key: <API_KEY>
-
Success Response:
- Code: 200
- Content:
{Valid Api Key}
-
Error Response:
-
Code: 401 UNAUTHORIZED
Content:
{ error : "error validating api key" }
-
/createservice
- Creates a new database service. Only Postgres databases are supported at the moment
Bearer <GITHUB_TOKEN>
x-api-key: <API_KEY>
POST
userId=[String]
: GitHub username of the user.(Necessary only if using github authentication)version=[Object]
: Preferred database version. It must have the following properties:maj=[Integer]
: Database major version. E.g for Postgres:9.6, the value here is 9.min=[Integer]
: Database major version. E.g for Postgres:9.6, the value here is 6.
db=[Object]
: A JSON object describing the properties of the database to be created. The properties are:type=[String]
: Type of the database service to be created. Onlypostgres
is supported for now.name=[String]
: Name of the database servicemonitoring=[String]
: Optional. Must be either ofenable
ordisable
when present. When enabled, it turns on prometheus metrics for the database on port 9187.
{
"userId": "viggy28",
"db": {
"type": "postgres",
"name": "localtest",
"monitoring": "enable"
},
"version": {
"maj": 9,
"min": 6
}
}
Code: 200
Code: 500 INTERNALSERVER ERROR
/cluster?cluster_id=<CLUSTER_ID>
- Fetches specific details of a service or cluster
GET
Bearer <GITHUB_TOKEN>
x-api-key: <API_KEY>
cluster_id=[String]
: ID of the cluster to be retrieved.
200:
{
"data": {
"cluster_id": "a130e42a09f4\n",
"id": 2,
"name": "localtest",
"port": 5432,
"username": "localtest"
}
}
404:
{
"message": "no cluster found with matching id"
}
- URL
/jwt?data=replaceme
- Method:
GET
- Success Response:
- Code: 200
- Content:
{jwtofreplaceme}