Skip to content

Commit 1c3b637

Browse files
committed
Sample CAP Multi tenancy
1 parent feb45be commit 1c3b637

24 files changed

Lines changed: 6894 additions & 0 deletions

cap-multitenancy-sample/README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Overview
2+
3+
![mt-bookshop](./assets/bookshop-mt.png)
4+
5+
## Reference
6+
7+
- [CAP Documentation](https://cap.cloud.sap/docs/get-started/)
8+
- [CAP Multitenancy](https://cap.cloud.sap/docs/guides/multitenancy/)
9+
- [Deploy to Kyma](https://cap.cloud.sap/docs/guides/deployment/to-kyma)
10+
11+
## Prerequisites
12+
13+
- [SAP BTP, Kyma runtime instance](../prerequisites/README.md#kyma)
14+
15+
> [!Note]
16+
> If you're using an SAP BTP trial account, use a subaccount that supports SAP Hana Cloud. At the time of creating the sample (September 2025), SAP Hana Cloud is available in the US, but not in Singapore.
17+
18+
- [Docker](../prerequisites/README.md#docker)
19+
- [Kubernetes tooling](../prerequisites/README.md#kubernetes)
20+
- Kubectl configured to the namespace where you want to deploy the application
21+
- [Pack](../prerequisites/README.md#pack)
22+
- [NodeJS 22 or higher](https://nodejs.org/en/download/)
23+
- [SAP CAP](../prerequisites/README.md#sap-cap)
24+
- SAP Hana Cloud Instance
25+
26+
> [!Note]
27+
> If you're using an SAP BTP trial account, make sure your subaccount location supports SAP Hana Cloud.
28+
29+
- Entitlement for `hdi-shared` plan for Hana cloud service in your SAP BTP subaccount.
30+
- [SAP Hana Cloud Instance mapped to Kyma](https://blogs.sap.com/2022/12/15/consuming-sap-hana-cloud-from-the-kyma-environment/)
31+
32+
## Initial setup
33+
34+
- **Navigate to bookshop-external directory**.
35+
36+
> Note: All subsequent commands should be run from this directory.
37+
38+
```shell
39+
cd bookshop-external
40+
```
41+
42+
### Running the application locally
43+
44+
- Start sidecar
45+
46+
```shell
47+
cds watch mtx/sidecar
48+
```
49+
50+
- In another terminal, start CAP app
51+
52+
```shell
53+
cds watch --profile local-multitenancy
54+
```
55+
56+
- Run the commands from a new terminal to add tenants. Run the following commands or use [test.rest](./test.rest)
57+
58+
```shell
59+
cds subscribe t1 --to http://localhost:4005 -u yves:
60+
cds subscribe t2 --to http://localhost:4005 -u yves:
61+
```
62+
63+
- Get data for both users
64+
65+
```shell
66+
http http://localhost:4004/odata/v4/catalog/Books -a alice:
67+
http http://localhost:4004/odata/v4/catalog/Books -a erin:
68+
```
69+
70+
## Deploy to Kyma
71+
72+
- Update the following in [bookshop-external/chart/values.yaml](bookshop-external/chart/values.yaml)
73+
74+
- `global.domain`: your kyma domain
75+
- `global.imagePullSecret.name`: your docker pull secret name if images are pulled from private registry
76+
- `global.image.registry`: your docker registry server
77+
78+
- Update the following in [bookshop-external/containerize.yaml](bookshop-external/containerize.yaml)
79+
- `repository`: your docker registry server
80+
81+
- Build the docker images and deploy the helm chart to Kyma
82+
83+
```bash
84+
cds build --production
85+
cds up -2 k8s
86+
```
87+
88+
## Verify
89+
90+
- Simulate the subscribe flow by subscribing from a different subaccount in the same Global account in BTP cockpit.
91+
92+
- Access the subscribed application.
93+
94+
## Cleanup
95+
96+
- Unsubscribe the tenant from the BTP cockpit.
97+
- Undelloy the helm chart
98+
99+
```bash
100+
helm del --wait --timeout=10m bookshop-external
101+
```
102+
103+
## Troubleshooting
104+
105+
- Helm command to upgrade / install / reinstall the chart
106+
107+
```bash
108+
helm upgrade --install bookshop-external ./gen/chart --wait --wait-for-jobs --timeout=10m --set-file xsuaa.jsonParameters=xs-security.json
109+
```
301 KB
Loading

cap-multitenancy-sample/assets/bookshop-mt.svg

Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Getting Started
2+
3+
Welcome to your new project.
4+
5+
It contains these folders and files, following our recommended project layout:
6+
7+
File or Folder | Purpose
8+
---------|----------
9+
`app/` | content for UI frontends goes here
10+
`db/` | your domain models and data go here
11+
`srv/` | your service models and code go here
12+
`package.json` | project metadata and configuration
13+
`readme.md` | this getting started guide
14+
15+
16+
## Next Steps
17+
18+
- Open a new terminal and run `cds watch`
19+
- (in VS Code simply choose _**Terminal** > Run Task > cds watch_)
20+
- Start adding content, for example, a [db/schema.cds](db/schema.cds).
21+
22+
23+
## Learn More
24+
25+
Learn more at https://cap.cloud.sap/docs/get-started/.

0 commit comments

Comments
 (0)