Tenants
Prerequisites
TIP
Envirnoment is configured and ready for use
- Kubernetes techops
- envirnment is configured and stable
- global database exists
if not create global database with name from vault
CREATE DATABASE <database_name>;deploy application and apply migrations on it
python manage.py migrate- domain is added to DNS's
Create client in existed namespace
Below is an example of how you can create client in ALX platform when namespace and other builds already exists.
python manage.py create_client --subdomain=<subdomain> --client_name="Tester Master" --last_name="Last Name" --first_name="First Name" --email="test@test.test"Parameters:
-subdomain-> client subdomain for should be assigned to the client. (required)`- Sample domain: subdomain.autologyx.com
-client_name-> Client display name, this name will be used to create unique client identifier as well. (required)-last_name-> Client admin user detail. (optional)-first_name-> Client admin user detail. (optional)-email-> Client admin user unique identifier. (required)
Create first client new namespace
Below is an example of how you can create client in ALX platform
- Create new namespace, vault and other required stuff.
- Create manually global database name
CREATE DATABASE <database_name>;- Deploy application on new namespace.
- Initialize global database migrations on any pod
source /vault/secrets/env
python manage.py migrate- Now we are ready to create client. Follow steps described in Create client in existed namespace
Parameters:
database_name-> global database name.`
List clients
Below is an example of how you check clients ids and statuses
python manage.py list_clientsResponse Sample:
CLIENT_ID: 1 DOMAIN: https://subdomain.domain.com STATUS: active
CLIENT_ID: 2 DOMAIN: https://subdomain2.domain.com STATUS: deactivated at: 2022-06-21 07:06:11.227451+00:00De-activate client
Below is an example of how you can de-activate client(instead of remove), something like pause
python manage.py deactivate_client --client_id=<client_id> --deactivation_purpose=<deactivation_purpose>Parameters:
--client_id-> client#id unique identifier from global database tenants_client table. (required)--deactivation_purpose-> Text. (optional)
Activate client
Below is an example of how you can activate client previously de-activated
python manage.py activate_client --client_id=<client_id>Parameters:
--client_id-> client#id unique identifier from global database tenants_client table. (required)- Edit this section
- Delete client
- Below is an example of how you can deactivate client(instead of remove)
python manage.py delete_client --client_id=<client_id>Confirmation is required.
Parameters:
--client_id-> client#id unique identifier from global database tenants_client table. (required)--noinput-> Skip confirmation for automation purposes.
Delete client
Below is an example of how you can permanently remove client.
python manage.py delete_client --client_id=<client_id>Confirmation is required.
⚠️WARNING⚠️ Client connection could be cached in this case reload application might be required!
Parameters:
--client_id-> client#id unique identifier from global database tenants_client table. (required)--noinput-> Skip confirmation for automation purposes.
Create empty client database
- If You need deliver empty database structure first follow steps described in Create client in existed namespace for any already configured dev namespace.
- Connect to database and execute dump command
PGPASSWORD=<db_pass> pg_dump -U <db_user> -h <db_host> -p <db_port> -d <db_name> > <dump_file_name>.sql- If database is dumped properly and build is not needed any more then probably Delete client might be required.
Parameters:
db_pass-> database passworddb_user-> database userdb_port-> database portdb_name-> database name