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
Copy file name to clipboardExpand all lines: from-zero-to-cap-on-kyma/the-detailed-path.md
+91-99Lines changed: 91 additions & 99 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Overview
1
+
# Detailed Path
2
2
3
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
@@ -23,33 +23,33 @@ Using this sample, you start from scratch to deploy a [CAP](https://cap.cloud.sa
23
23
- SAP Hana Cloud Instance
24
24
-[SAP Hana Cloud Instance mapped to Kyma](https://blogs.sap.com/2022/12/15/consuming-sap-hana-cloud-from-the-kyma-environment/)
25
25
26
-
## CAP Application
26
+
## Initializing CAP Application
27
27
28
-
1. Initialize the Cap Bookshop sample
28
+
1. Initialize the CAP Bookshop sample
29
29
30
-
```shell
31
-
make init
32
-
```
30
+
```shell
31
+
make init
32
+
```
33
33
34
34
The initialized application is a simple Bookshop sample where you can access Book entries using API calls.
35
35
- Data model defined in [./bookshop/db/schema.cds](./bookshop/db/schema.cds). <!-- markdown-link-check-disable-line -->
36
36
- CDS defined in [./bookshop/srv/cat-service.cds](./bookshop/srv/cat-service.cds). <!-- markdown-link-check-disable-line -->
37
37
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/).
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/).
40
40
41
41
2. Run the application locally
42
42
43
-
```shell
44
-
make run-local
45
-
```
43
+
```shell
44
+
make run-local
45
+
```
46
46
47
47
3. Access the CAP Srv at <http://localhost:4004>
48
48
4. Terminate the local running app with `^C`
49
49
50
50
## Deploying to Kyma
51
51
52
-
### Add default route for App router
52
+
### Adding the Default Route for Application Router
53
53
54
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 -->
55
55
@@ -67,14 +67,14 @@ Using this sample, you start from scratch to deploy a [CAP](https://cap.cloud.sa
67
67
}
68
68
```
69
69
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.
70
+
> [!Note]
71
+
> The standalone Application Router is used to simplify the setup and **is not a must**. It should also be possible to use the managed approuter because your CAP APIs are exposed via Fiori or UI5 applications and accessed using workzone.
72
72
73
-
### Configure environment variables
73
+
### Configuring Environment Variables
74
74
75
-
1. Set up the required environment variables:
75
+
1. Set up the required environment variables.
76
76
77
-
- In shell
77
+
- In shell
78
78
79
79
```shell
80
80
export DOCKER_ACCOUNT=<your-docker-account>
@@ -83,7 +83,7 @@ Using this sample, you start from scratch to deploy a [CAP](https://cap.cloud.sa
83
83
export CLUSTER_DOMAIN=$(kubectl get cm -n kube-system shoot-info -ojsonpath='{.data.domain}')
84
84
```
85
85
86
-
- In Windows powershell
86
+
- In Windows powershell
87
87
88
88
```powershell
89
89
$ENV:DOCKER_ACCOUNT="<your-docker-account>"
@@ -98,74 +98,69 @@ Using this sample, you start from scratch to deploy a [CAP](https://cap.cloud.sa
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.
104
104
105
105
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.
106
106
107
-
> [!Note]
108
-
> The following are system namespaces:
109
-
> -`kube-system`
110
-
> -`istio-system`
111
-
> -`kyma-system`
112
-
> It is not recommended to deploy your applications in the system namespaces.
107
+
> [!Note]
108
+
> The following are system namespaces:
109
+
> - `kube-system`
110
+
> - `istio-system`
111
+
> - `kyma-system`
112
+
> It is not recommended to deploy your applications in the system namespaces.
113
113
114
114
```shell
115
115
make create-namespace
116
116
```
117
117
118
118
3. Enable Istio injection for the namespace. Set the kubeconfig context to point to the namespace and create the Docker image pull Secret.
119
+
120
+
> Note: You will need a Docker API Key so that Kubernetes can pull the Docker images from your Docker account.
119
121
120
122
```shell
121
123
make prepare-kyma-for-deployment
122
124
```
123
125
124
-
##Deploy to Kyma runtime
126
+
### Building Docker Images
125
127
126
-
## Build Docker images
128
+
On Kyma runtime, application run as Docker containers. They require a Docker image to be created out of the application code/binaries.
127
129
128
-
On Kyma runtime, application run as docker containers. They require a docker image to be created out of the application code / binaries.
130
+
The Docker image can be stored in the Docker registry. It can be a private Docker registry where access is restricted with credentials.
129
131
130
-
The docker image can be stored on the docker registry. It can be a private docker registry where access is restricted with credentials.
132
+
This sample uses a pack to build the Docker images.
131
133
132
-
We will use pack to build the docker images.
134
+
1. Buid a Docker image and follow the logs.
133
135
134
-
- Checkout what is happening when building the docker image
135
-
136
-
```shell
137
-
make build-hana-deployer --just-print
138
-
```
136
+
```shell
137
+
make build-hana-deployer --just-print
138
+
```
139
139
140
-
You will notice that`pack` intelligently identifies how to pack the source code and create the necessary artifacts. The same is also true for Java applications.
140
+
The`pack` intelligently identifies how to pack the source code and create the necessary artifacts. The same is also truefor Java applications.
141
141
142
-
- Build and push the Hana deployer image
142
+
2. Build and push the Hana deployer image.
143
143
144
-
```shell
145
-
make build-hana-deployer
146
-
make push-hana-deployer
147
-
```
144
+
```shell
145
+
make build-hana-deployer push-hana-deployer
146
+
```
148
147
149
-
- Build and push the CAP Srv image
148
+
3. Build and push the CAP Srv image.
150
149
151
-
```shell
152
-
make build-cap-srv
153
-
make push-cap-srv
154
-
```
150
+
```shell
151
+
make build-cap-srv push-cap-srv
152
+
```
155
153
156
-
- Build and push the Approuter image
154
+
4. Build and push the Approuter image.
157
155
158
-
```shell
159
-
make build-approuter
160
-
make push-approuter
161
-
```
156
+
```shell
157
+
make build-approuter push-approuter
158
+
```
162
159
163
160
### Creating Helm Charts
164
161
165
162
Having the artifacts in place, focus to deploying the application.
166
163
167
-
First we need the configurations to tell Kyma what and how we want to deploy.
168
-
169
164
The sample uses [Helm charts](https://helm.sh/) to define the required configurations and then deploy them on the Kyma runtime.
170
165
171
166
`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.
@@ -191,80 +186,77 @@ The sample uses [Helm charts](https://helm.sh/) to define the required configura
191
186
make add-istio-destination-rule
192
187
```
193
188
194
-
### Deploy helm chart
189
+
### Deploying Helm Chart
195
190
196
-
1. Check the make command by running
191
+
1. Check the `make`command by running:
197
192
198
-
```shell
199
-
make deploy-dry-run --just-print
200
-
```
193
+
```shell
194
+
make deploy-dry-run --just-print
195
+
```
201
196
202
-
You will notice that we are overriding a various properties defined in `chart/values.yaml`. This is standard helm feature where you can override your values by specifying them in the command line. This obviates the need to modify the `values.yaml` file. Of course, you can also update the `values.yaml` directly.
197
+
The command overrides various properties defined in`chart/values.yaml`. This is a standard Helm feature that you can override your values by specifying them in the command line. This obviates the need to modify the `values.yaml` file. Of course, you can also update the `values.yaml` directly.
203
198
204
199
2. Run the command to do a dry run
205
200
206
-
```shell
207
-
make deploy-dry-run
208
-
```
201
+
```shell
202
+
make deploy-dry-run
203
+
```
209
204
210
-
Take some time to understand what all will be deployed and how does the configuration looks like.
211
-
It is interesting to notice that all these deployment configurations are auto-generated via cds.
205
+
Take some time to understand the deployment and what the configuration looks like. It is interesting to notice that all these deployment configurations are auto-generated using CDS.
212
206
213
-
**This ensures that you as a developer does not need work with the complexities of helm charts and configurations. At the same time, these pre-shipped charts follow the best practices when it comes to deploying on Kyma.**
207
+
**This ensures that you as a developer don't have to work with the complexities of Helm charts and configurations. At the same time, these pre-shipped charts follow the best practices when it comes to deploying on Kyma.**
214
208
215
-
3. Build and deploy to Kyma runtime.
216
-
217
-
```shell
218
-
make deploy
219
-
```
209
+
3. Build and deploy to the Kyma runtime.
220
210
221
-
### Verify your deployment
211
+
```shell
212
+
make deploy
213
+
```
222
214
223
-
- Check the state of the application pods. **Wait until pods are in running state.**
215
+
### Verifying the Deployment
224
216
225
-
```shell
226
-
make check-status
227
-
```
217
+
1. Check the state of the application pods. **Wait until the pods are in running state.**
228
218
229
-
- Check the hana deployer logs
219
+
```shell
220
+
make check-status
221
+
```
230
222
231
-
```shell
232
-
make check-hana-deployer-logs
233
-
```
223
+
2. Check the hana deployer logs.
234
224
235
-
- Check the logs for the CAP application
225
+
```shell
226
+
make check-hana-deployer-logs
227
+
```
236
228
237
-
```shell
238
-
make check-cap-srv-logs
239
-
```
229
+
3. Check the CAP application logs.
240
230
241
-
- Check the logs for the Approuter
231
+
```shell
232
+
make check-cap-srv-logs
233
+
```
242
234
243
-
```shell
244
-
make check-approuter-logs
245
-
```
235
+
4. Check the Application Router logs.
246
236
247
-
- Access the application via the app router URL. It will be of the form <https://bookshop-approuter-${NAMESPACE}.${KYMA_CLUSTER_DOMAIN}>
237
+
```shell
238
+
make check-approuter-logs
239
+
```
248
240
249
-
### Cleanup
241
+
5. Access the application using the Application Router URL. It should be similar to this one: <https://bookshop-approuter-${NAMESPACE}.${KYMA_CLUSTER_DOMAIN}>.
250
242
251
-
- Delete the helm chart
243
+
### Cleaning Up
252
244
253
-
```shell
254
-
make undeploy
255
-
```
245
+
1. Delete the Helm chart. This command removes all the deployed applications, service instances, and their bindings.
256
246
257
-
This will delete the helm chart. Thereby all deployed applications, service instances and their bindings will be cleaned.
247
+
```shell
248
+
make undeploy
249
+
```
258
250
259
-
- Remove the namespace and bookshop cap application folder
251
+
2. Remove the namespace and the Bookshop CAP application folder.
0 commit comments