Skip to content

Commit 9710d0b

Browse files
committed
Merge branch 'main' of https://github.com/cap-js/docs
2 parents 4d40af8 + e8f4922 commit 9710d0b

File tree

7 files changed

+256
-288
lines changed

7 files changed

+256
-288
lines changed

guides/deployment/to-kyma.md

Lines changed: 31 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Deploying apps on the SAP BTP Kyma Runtime requires two main artifact types:
6868

6969
The following diagram illustrates the deployment workflow:
7070

71-
![A CAP Helm chart is added to your project. Then you build your project as container images and push those images to a container registry of your choice. As last step the Helm chart is deployed to your Kyma resources, where service instances of SAP BTP services are created and pods pull the previously created container images from the container registry.](assets/deploy-kyma.drawio.svg)
71+
![A CAP Helm chart is added to your project. Then you build your project as container images and push those images to a container registry of your choice. As a last step the Helm chart is deployed to your Kyma cluster, where service instances of SAP BTP services are created and pods pull the previously created container images from the container registry.](assets/deploy-kyma.drawio.svg)
7272

7373

7474
## Prerequisites {#prerequisites}
@@ -79,9 +79,8 @@ The following diagram illustrates the deployment workflow:
7979
+ Install [Docker Desktop or Docker for Linux](https://docs.docker.com/get-docker/)
8080
+ Download and install the following command line tools:
8181
+ [`kubectl` command line client](https://kubernetes.io/docs/tasks/tools/) for Kubernetes
82-
+ [`pack` command line tool](https://buildpacks.io/docs/tools/pack/)
82+
+ [`pack` command line tool](https://buildpacks.io/docs/for-platform-operators/how-to/integrate-ci/pack/)
8383
+ [`helm` command line tool](https://helm.sh/docs/intro/install/)
84-
+ [`ctz` command line tool](https://www.npmjs.com/package/ctz)
8584
+ Make sure your SAP HANA Cloud is [mapped to your namespace](https://community.sap.com/t5/technology-blogs-by-sap/consuming-sap-hana-cloud-from-the-kyma-environment/ba-p/13552718#toc-hId-569025164)
8685
+ Ensure SAP HANA Cloud is accessible from your Kyma cluster by [configuring trusted source IPs](https://help.sap.com/docs/HANA_CLOUD/9ae9104a46f74a6583ce5182e7fb20cb/0610e4440c7643b48d869a6376ccaecd.html)
8786

@@ -96,34 +95,19 @@ Download the Kubernetes configuration from SAP BTP and move it to _$HOME/.kube/c
9695
SAP BTP doesn't provide a container image registry (or container repository), but you can choose from offerings of hosted open source and private container image registries, as well as solutions that can be run on premise or in your own cloud infrastructure.
9796

9897
::: tip Ensure network access
99-
10098
Verify the Kubernetes cluster has network access to the container registry, especially if hosted behind a VPN or within a restricted network environment.
101-
10299
:::
103100

104101
#### Set Up Your Cluster for a Private Container Registry
105102

106103
To use a docker image from a private repository, you need to [create an image pull secret](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) and configure this secret for your containers.
107104

108-
::: details Use this script to create the docker pull secret...
109-
110-
```sh
111-
echo -n "Your docker registry server: "; read YOUR_REGISTRY
112-
echo -n "Your user: "; read YOUR_USER
113-
echo -n "Your email: "; read YOUR_EMAIL
114-
echo -n "Your API token: "; read -s YOUR_API_TOKEN
115-
kubectl create secret docker-registry \
116-
docker-registry \
117-
"--docker-server=$YOUR_REGISTRY" \
118-
"--docker-username=$YOUR_USER" \
119-
"--docker-password=$YOUR_API_TOKEN" \
120-
"--docker-email=$YOUR_EMAIL"
121-
# The 2nd 'docker-registry' above is our default secret name.
122-
```
105+
:::info Interactive setup
106+
If a pull secret does not exist for your namespace when deploying your application, the CLI will prompt you to set up the pull secret interactively.
123107
:::
124108

125109
::: warning Assign limited permissions to the technical user
126-
It is recommended to use a technical user for this secret that has only read permission, because users with access to the Kubernetes cluster can reveal the password from the secret.
110+
For this secret, use a technical user with read-only permissions. This limits the risk, as anyone with access to the Kubernetes cluster could retrieve the password from the secret and potentially modify or publish images to the registry.
127111
:::
128112

129113
<span id="afterprivatereg" />
@@ -166,9 +150,9 @@ cds add workzone
166150
CAP provides a configurable [Helm chart](https://helm.sh/) for Node.js and Java applications, which can be added like so:
167151

168152
```sh
169-
cds add helm
153+
cds add kyma
170154
```
171-
> You will be asked to provide a Kyma domain, the secret name to pull images and your container registry name.
155+
> You will be asked to provide a Kyma cluster domain and your container registry name.
172156
173157
::: details Running `cds build` now creates a _gen_/_chart_ folder
174158

@@ -184,34 +168,47 @@ They support the deployment of your CAP service, database, UI content, and the c
184168
You can now quickly deploy the application like so:
185169

186170
```sh
187-
cds up -2 k8s
171+
cds up -2 k8s [ -n <your-namespace> ]
188172
```
189173

190174
::: details Essentially, this automates the following steps...
191175

192176
```zsh
193-
cds add helm,containerize # if not already done
177+
cds add kyma # if not already done
194178

195179
# Installing app dependencies, e.g.
196-
npm i app/browse
180+
181+
# If package-lock.json doesn't exist
182+
npm install --prefix app/browse
183+
184+
npm run build --prefix app/browse
185+
186+
# If package-lock.json doesn't exist
197187
npm i app/admin-books
198188

189+
npm run build --prefix app/admin-books
190+
199191
# If project is multitenant
200192
npm i --package-lock-only mtx/sidecar
201193

202194
# If package-lock.json doesn't exist
203195
npm i --package-lock-only
204196

197+
# Buildpack commands
198+
pack build bookshop-srv:latest --path gen/srv --builder builder-jammy-base --env BP_NODE_RUN_SCRIPTS=""
199+
pack build bookshop-html5-deployer:latest --path app/html5-deployer --builder builder-jammy-base --env BP_NODE_RUN_SCRIPTS=""
200+
205201
# Final assembly and deployment, e.g.
206-
ctz containerize.yaml --log --push
207-
helm upgrade --install bookshop ./gen/chart --wait --wait-for-jobs --set-file xsuaa.jsonParameters=xs-security.json
202+
helm upgrade --install bookshop ./gen/chart --namespace bookshop --wait --wait-for-jobs --timeout=10m
208203
kubectl rollout status deployment bookshop-srv --timeout=8m
209204
kubectl rollout status deployment bookshop-approuter --timeout=8m
210205
kubectl rollout status deployment bookshop-sidecar --timeout=8m
211206
```
212207

213208
:::
214209

210+
_This command uses checksums to detect changes in your code. If any modifications are found, it automatically triggers a rebuild. The checksums are reflected in the Docker image tags._
211+
215212
This process can take a few minutes to complete and logs output like this:
216213

217214
```log
@@ -257,24 +254,13 @@ Specify the repository where you want to push the images:
257254
...
258255
repository: <your-container-registry>
259256
```
260-
261257
:::
262258
263-
Now, we use the `ctz` build tool to build all the images:
264-
265-
```sh
266-
ctz containerize.yaml
267-
```
268-
269-
This will start containerizing your modules based on the configuration in _containerize.yaml_. After finishing, it will ask whether you want to push the images or not. Type `y` and press enter to push your images. You can also use the above command with `--push` flag to auto-confirm. If you want more logs, you can use the `--log` flag with the above command.
270-
271-
[Learn more about the `ctz` build tool.](https://www.npmjs.com/package/ctz/){.learn-more style="margin-top:10px"}
272-
273259
### Customize Helm Chart {#customize-helm-chart}
274260
275261
#### About CAP Helm Charts {#about-cap-helm}
276262
277-
The following files are added to a _chart_ folder by executing `cds add helm`:
263+
The following files are added to a _chart_ folder by executing `cds add kyma`:
278264

279265
```zsh
280266
chart/
@@ -323,7 +309,7 @@ imagePullSecret:
323309
# Kubernetes cluster ingress domain (used for application URLs)
324310
domain: <cluster-domain>
325311
326-
# Container image registry
312+
# Container image registry where to pull the image from
327313
image:
328314
registry: <registry-server>
329315
```
@@ -494,13 +480,6 @@ parametersFrom:
494480
```
495481
:::
496482

497-
The `jsonParameters` key can also be specified using the `--set file` flag while installing/upgrading Helm release. For example, `jsonParameters` for the `xsuaa` property can be defined using the following command:
498-
499-
```sh
500-
helm install bookshop ./chart \
501-
--set-file xsuaa.jsonParameters=xs-security.json
502-
```
503-
504483
> You can explore more configuration options in the subchart's directory _gen/chart/charts/service-instance_.
505484

506485
#### Configuration Options for Service Bindings
@@ -573,18 +552,18 @@ srv: # Key is the target service, e.g. 'srv'
573552

574553
Modifying the Helm chart allows you to customize it to your needs. However, this has consequences if you want to update with the latest changes from the CAP template.
575554

576-
You can run `cds add helm` again to update your Helm chart. It has the following behavior for modified files:
555+
You can run `cds add kyma` again to update your Helm chart. It has the following behavior for modified files:
577556

578-
1. Your changes of the _chart/values.yaml_ and _chart/Chart.yaml_ will not be modified. Only new or missing properties will be added by `cds add helm`.
557+
1. Your changes of the _chart/values.yaml_ and _chart/Chart.yaml_ will not be modified. Only new or missing properties will be added by `cds add kyma`.
579558
2. To modify any of the generated files such as templates or subcharts, copy the files from _gen/chart_ folder and place it in the same level inside the _chart_ folder. After the next `cds build` executions the generated chart will have the modified files.
580559
3. If you want to have some custom files such as templates or subcharts, you can place them in the _chart_ folder at the same level where you want them to be in _gen/chart_ folder. They will be copied as is.
581560

582561
### Extend
583562

584-
Instead of modifying consider extending the CAP Helm chart. Just make sure adding new files to the Helm chart does not conflict with `cds add helm`.
563+
Instead of modifying consider extending the CAP Helm chart. Just make sure adding new files to the Helm chart does not conflict with `cds add kyma`.
585564

586565
::: tip Consider Kustomize
587-
A modification-free approach to change files is to use [Kustomize](https://kustomize.io/) as a [post-processor](https://helm.sh/docs/topics/advanced/#post-rendering) for your Helm chart. This might be usable for small changes if you don't want to branch-out from the generated `cds add helm` content.
566+
A modification-free approach to change files is to use [Kustomize](https://kustomize.io/) as a [post-processor](https://helm.sh/docs/topics/advanced/#post-rendering) for your Helm chart. This might be usable for small changes if you don't want to branch-out from the generated `cds add kyma` content.
588567
:::
589568

590569

0 commit comments

Comments
 (0)