You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this sample, we will start from scratch / zero to deploying an[CAP](https://cap.cloud.sap/docs/) NodeJS application on Kyma runtime.
3
+
Using this sample, you start from scratch to deploy a[CAP](https://cap.cloud.sap/docs/) NodeJS application on SAP BTP, Kyma runtime.
4
4
5
5

6
6
7
-
- You will create a sample Node.JS based CAP application (Bookshop)
8
-
-Using cds, you will create the necessary artifacts and configurations required to deploy on Kyma.
9
-
-Last, but not least, you will deploy and verify your running CAP application on SAP BTP, Kyma runtime.
7
+
- You create a sample NodeJS-based CAP application, namely the Bookshop.
8
+
-You use Core Data Services (CDS) to create the necessary artifacts and configurations required to deploy the application on Kyma.
9
+
-You deploy and verify your running CAP application on SAP BTP, Kyma runtime.
10
10
11
-
> Note: For simplification most of the commands have been defined using the [Makefile](Makefile). In case you want to understand what the actual command is, run `make <command> --just-print`
11
+
> [!Note]
12
+
> For simplification most of the commands are defined using the [Makefile](Makefile). If you want to understand what the actual command is, run `make <command> --just-print`.
12
13
13
14
## Prerequisites
14
15
@@ -24,177 +25,180 @@ In this sample, we will start from scratch / zero to deploying an [CAP](https://
24
25
25
26
## CAP Application
26
27
27
-
- Initialize the Cap Bookshop sample
28
+
1. Initialize the CAP Bookshop sample.
28
29
29
-
```shell
30
-
make init
31
-
```
30
+
```shell
31
+
make init
32
+
```
32
33
33
-
Let's take a minute to inspect our cap application. It is a simple Bookshop sample where you can access Book entries via API calls.
34
+
The initialized application is a simple Bookshop sample where you can access Book entries using API calls.
35
+
- Data model defined in [./bookshop/db/schema.cds](./bookshop/db/schema.cds). <!-- markdown-link-check-disable-line -->
36
+
- CDS defined in [./bookshop/srv/cat-service.cds](./bookshop/srv/cat-service.cds). <!-- markdown-link-check-disable-line -->
34
37
35
-
- Data model defined in [./bookshop/db/schema.cds](./bookshop/db/schema.cds)<!-- markdown-link-check-disable-line -->
36
-
- Core Data Service defined in [./bookshop/srv/cat-service.cds](./bookshop/srv/cat-service.cds)<!-- markdown-link-check-disable-line -->
38
+
> [!NOTE]
39
+
> CAP promotes getting started with minimal upfront setup, based on convention over configuration, and a grow-as-you-go approach, adding settings and tools later on, only when you need them. For more information, see [Introduction to CAP](https://cap.cloud.sap/docs/about/).
37
40
38
-
Directly from CAP website, *CAP promotes getting started with minimal upfront setup, based on convention over configuration, and a grow-as-you-go approach, adding settings and tools later on, only when you need them.*
41
+
2. Run the application locally.
39
42
40
-
- Run the application locally
43
+
```shell
44
+
make run-local
45
+
```
41
46
42
-
```shell
43
-
make run-local
44
-
```
47
+
3. Access the CAP Srv at <http://localhost:4004>.
48
+
4. Terminate the local running app with `^C`.
45
49
46
-
- Access the CAP Srv at <http://localhost:4004>
47
-
- Terminate the local running app with `^C`
50
+
## Deploying to Kyma
48
51
49
-
##Deploy to Kyma
52
+
### Adding the Default Route for Application Router
50
53
51
-
### Add default route for App router
54
+
1. Update the [bookshop/app/router/xs-app.json](bookshop/app/router/xs-app.json) to add a default route for the app router. This is required to access the CAP application via the URL. The end json should look as below: <!-- markdown-link-check-disable-line -->
52
55
53
-
- Update the [bookshop/app/router/xs-app.json](bookshop/app/router/xs-app.json)<!-- markdown-link-check-disable-line -->
54
-
to add a default route for the app router. This is required to access the CAP application via the URL. The end json should look as below:
56
+
```json
57
+
{
58
+
"welcomeFile": "/odata/v4/catalog/Books",
59
+
"routes": [
60
+
{
61
+
"source": "^/(.*)$",
62
+
"target": "$1",
63
+
"destination": "srv-api",
64
+
"csrfProtection": true
65
+
}
66
+
]
67
+
}
68
+
```
55
69
56
-
```json
57
-
{
58
-
"welcomeFile": "/odata/v4/catalog/Books",
59
-
"routes": [
60
-
{
61
-
"source": "^/(.*)$",
62
-
"target": "$1",
63
-
"destination": "srv-api",
64
-
"csrfProtection": true
65
-
}
66
-
]
67
-
}
68
-
```
70
+
> [!Note]
71
+
> The standalone Application Router is used to simplify the setup and **is not a must**. It should be also possible to use the managed approuter because your CAP APIs are exposed via Fiori or UI5 applications and accessed using workzone.
69
72
70
-
> Note: The standalone approuter is being used for a simpler sample and **is not a must**. It should be possible to use the managed approuter as well as have you CAP APIs being exposed via Fiori or UI5 applications and accessed using workzone.
1. Do a basic check to see if the cluster is reachable. Running any of the basic commands such as `kubectl cluster-info` or `kubectl get pods` or `kubectl get namespaces` successfully should confirm that. If an error occurs, check your kubeconfig file and ensure that it is correctly set up to point to your Kyma cluster. Also, check if the cluster was provisioned successfully in the SAP BTP cockpit under your subaccount.
97
100
98
-
- Let's do a basic check to see if the cluster is reachable. Running any of the basic commands such as `kubectl cluster-info` or `kubectl get pods` or `kubectl get namespaces` successfully should confirm that. If an error occurs, please check your kubeconfig file and ensure that it is correctly set up to point to your Kyma cluster. Also check if the cluster was provisioned successfully in the SAP BTP Cockpit under your subaccount.
101
+
2. Create a namespace. You can skip this step if you already have a namespace. You can use any non-system namespace of your choice to deploy the sample application.
99
102
100
-
- Let's do a bit of groundwork before we deploy our Helm Chart. In Kyma/Kubernetes, the workloads and required configurations will be deployed in namespaces.
103
+
> [!Note]
104
+
> The following are system namespaces:
105
+
> - `kube-system`
106
+
> - `istio-system`
107
+
> - `kyma-system`
108
+
> It is not recommended to deploy your applications in the system namespaces.
101
109
102
-
- We will create a namespace. You can skip this step if you already have a namespace. You can use any non-system namespace of your choice to deploy the sample application.
110
+
```shell
111
+
make create-namespace
112
+
```
103
113
104
-
> Note: system namespaces are such as `kube-system`, `istio-system`, `kyma-system` etc. It is not recommended to deploy your applications in these namespaces.
114
+
3. Enable Istio injection for the namespace. Set the kubeconfig context to point to the namespace and create the Docker image pull Secret.
105
115
106
-
```shell
107
-
make create-namespace
108
-
```
116
+
```shell
117
+
make prepare-kyma-for-deployment
118
+
```
109
119
110
-
- Now let's enable Istio injection for the namespace. Set the kubeconfig context to point to the namespace and create the docker image pull secret.
120
+
### Creating Helm Charts
111
121
112
-
```shell
113
-
make prepare-kyma-for-deployment
114
-
```
115
-
116
-
### Create Helm chart
117
-
118
-
Now that we have our artifacts in place, lets shift our focus to deploying the application.
122
+
Having the artifacts in place, focus to deploying the application.
119
123
120
124
First we need the configurations to tell Kyma what and how we want to deploy.
121
125
122
-
We will use [Helm Charts](https://helm.sh/) to define the required configurations and then deploy them on Kyma runtime.
126
+
The sample uses [Helm charts](https://helm.sh/) to define the required configurations and then deploy them on the Kyma runtime.
123
127
124
-
`cds` can intelligently inspect what all is defined in your cap application and generate the necessary configurations (Helm charts) to deploy it on Kyma runtime.
128
+
`cds` can intelligently inspect what is defined in your CAP application and generate the necessary configurations (Helm charts) to deploy the application on Kyma runtime.
125
129
126
-
- Create Helm chart
130
+
1. Create a Helm chart.
127
131
128
-
```shell
129
-
make create-helm-chart
130
-
```
132
+
```shell
133
+
make create-helm-chart
134
+
```
131
135
132
-
Now take a moment to understand the generated Helm chart in the [chart](./bookshop/chart) directory. <!-- markdown-link-check-disable-line -->
136
+
Take a moment to understand the generated Helm chart in the [chart](./bookshop/chart) directory. <!-- markdown-link-check-disable-line -->
133
137
134
-
Helm chart Structure will look as below. The full helm chart will be automatically generated by `cds` under `gen` folder.
135
-

138
+
The Helm chart structure should look as below. The full Helm chart is automatically generated by `cds` under the `gen` folder.
136
139
137
-
- [bookshop/chart/Chart.yaml](bookshop/chart/Chart.yaml) contains the details about the chart and all its dependencies. <!-- markdown-link-check-disable-line -->
138
-
- [bookshop/chart/values.yaml](bookshop/chart/values.yaml) <!-- markdown-link-check-disable-line --> contains all the details to configure the chart deployment. You will notice that it has sections for `hana deployer`, `cap application` as well as required `service instances` and `service bindings`
140
+

139
141
140
-
- Add Istio destination rule for approuter. Please check the [approuter documentation](https://www.npmjs.com/package/@sap/approuter) for details about `PLATFORM_COOKIE_NAME` configuration.
142
+
- [bookshop/chart/Chart.yaml](bookshop/chart/Chart.yaml) contains the details about the chart and all its dependencies.<!-- markdown-link-check-disable-line -->
143
+
- [bookshop/chart/values.yaml](bookshop/chart/values.yaml) <!-- markdown-link-check-disable-line --> contains all the details to configure the chart deployment. You will notice that it has sections for`hana deployer`, `cap application` as well as required `service instances` and `service bindings.`
141
144
142
-
```shell
143
-
make add-istio-destination-rule
144
-
```
145
+
2. Add Istio Destination Rule for the Application Router. Please check the [Approuter documentation](https://www.npmjs.com/package/@sap/approuter) for details about the `PLATFORM_COOKIE_NAME` configuration.
145
146
146
-
- Update the [bookshop/chart/values.yaml](bookshop/chart/values.yaml) <!-- markdown-link-check-disable-line -->
147
-
to add the environment variables for the **approuter section** that is used for cookie.
147
+
```shell
148
+
make add-istio-destination-rule
149
+
```
148
150
149
-
```yaml
150
-
health:
151
-
liveness:
152
-
path: /
153
-
readiness:
154
-
path: /
155
-
env:
156
-
PLATFORM_COOKIE_NAME: KYMA_APP_SESSION_ID # This is the cookie name used by the approuter to store session information
157
-
```
151
+
3. Update the [bookshop/chart/values.yaml](bookshop/chart/values.yaml) to add the environment variables for the **approuter section** that is used for cookies. <!-- markdown-link-check-disable-line -->
158
152
159
-
### Build and deploy
153
+
```yaml
154
+
health:
155
+
liveness:
156
+
path: /
157
+
readiness:
158
+
path: /
159
+
env:
160
+
PLATFORM_COOKIE_NAME: KYMA_APP_SESSION_ID # This is the cookie name used by the approuter to store session information
161
+
```
160
162
161
-
- Add containerize
163
+
### Building and Deploying
162
164
163
-
```shell
164
-
make add-containerize
165
-
```
165
+
1. Add containerize.
166
166
167
-
- Build and deploy to Kyma runtime
167
+
```shell
168
+
make add-containerize
169
+
```
168
170
169
-
```shell
170
-
make cds-build-deploy
171
-
```
171
+
2. Build and deploy to Kyma runtime.
172
172
173
-
### Verify your deployment
173
+
```shell
174
+
make cds-build-deploy
175
+
```
174
176
175
-
- Access the application via the app router URL. It will be of the form <https://bookshop-approuter-${NAMESPACE}.${KYMA_CLUSTER_DOMAIN}>
177
+
### Verifying the Deployment
176
178
177
-
### Cleanup
179
+
To verify your deployment, access the application using the app router URL. It should be similar to this one: <https://bookshop-approuter-${NAMESPACE}.${KYMA_CLUSTER_DOMAIN}>.
178
180
179
-
- Delete the helm chart. This will delete the helm chart. Thereby all deployed applications, service instances and their bindings will be cleaned.
181
+
### Cleaning Up
180
182
181
-
```shell
182
-
make undeploy
183
-
```
183
+
1. Delete the Helm chart. Deleting the Helm chart you remove all the deployed applications, service instances, and their bindings.
184
184
185
-
- Remove the namespace and bookshop cap application folder
185
+
```shell
186
+
make undeploy
187
+
```
186
188
187
-
```shell
188
-
make cleanup
189
-
```
189
+
2. Remove the namespace and the Bookshop CAP application folder.
190
+
191
+
```shell
192
+
make cleanup
193
+
```
190
194
191
195
## Detailed Path
192
196
193
-
For following the detailed path where you build the artifacts and deploy them step by step, please refer to [the detailed path](./the-detailed-path.md).
197
+
For more information on the built artifacts and deploying them step by step, see [Detailed Path](./the-detailed-path.md).
@@ -209,8 +213,6 @@ Latest verified on following CAP version.
209
213
| @sap/eslint-plugin-cds | 3.2.0 |
210
214
| Node.js | v22.11.0 |
211
215
212
-
## Takeaway
213
-
214
-
*CAP supports grow-as-you-go model. Once you have familiarized yourself with CAP basics, you can go further and add capabilities such as authentication, multitenancy, extensibility, messaging and many more.*
216
+
## Related Information
215
217
216
-
You can explore CAP further on <https://cap.cloud.sap/docs/>
0 commit comments