Multitenancy is the ability to serve multiple tenants through single clusters of microservice instances, while strictly isolating the tenants' data. In contrast to single-tenant mode, applications aren't serving end-user request immediately after deployment, but wait for tenants to subscribe. CAP has built-in support for multitenancy with the @sap/cds-mtxs package.
Uninstall the single tenant version be executing the following command:
helm uninstall bookshop-{Participant_ID}Create a new branch multitenant in your forked repo using the following command:
git checkout -b multitenantExecute the following command to make the app multitenant:
cds add mtx --for productionNote: Make sure you install the newly added dependencies by executing npm i.
-
Update values of the following keys of
saasRegistryParameters:```diff saasRegistryParameters: - xsappname: bookshop - appName: bookshop - displayName: bookshop + xsappname: bookshop-{Participant_ID} + appName: bookshop-{Participant_ID} + displayName: bookshop-{Participant_ID} ``` -
Add the
mtx-apidestination inbackendDestinationskey:```diff backendDestinations: srv-api: service: srv + mtx-api: + service: sidecar ``` -
Raise a PR to the
mainbranch of your repository and merge it. This will start the deployment workflow and upgrade your application.
Replace the content of .github/actions/deploy/action.yml with files/mt-action.yaml.
Note: Make sure you update your participant id again in the action.yml.
- Open the reCAP:Kyma subaccount and go to
Instances and Subscriptionstab. - Click on
Create. - Search for
bookshop-<participantID>and select the default plan. - Click on
Create. - Once the subscription is successful, click on
Go to Application. - You'll get an error saying,
No webpage was found for the web address: ....The web address should be of the form:https://<your-host>.c-4e4de85.stage.kyma.ondemand.com. Copy theyour-hostvalue. You'll need it in the next step. - Configure your participant id, host and release name in the
api-rule.yamlfile available in thefilesfolder of your fork. - Apply it using the following command
kubectl apply -f files/api-rule.yaml. - Open the web address.