Skip to content

Commit 1729caa

Browse files
Kyma Deployment Update (#196)
Switched to Approuter based UI deployment instead of HTML5 Apps based and updated other sections. Co-authored-by: Marc Becker <[email protected]>
1 parent 8c25618 commit 1729caa

File tree

5 files changed

+281
-326
lines changed

5 files changed

+281
-326
lines changed

README.md

Lines changed: 185 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -241,57 +241,69 @@ Before you can access the UI using the (tenant-specific) URL to the bookshop(-mt
241241
- Container Registry (e.g. [Docker Hub](https://hub.docker.com/))
242242
- Command Line Tools: [`kubectl`](https://kubernetes.io/de/docs/tasks/tools/install-kubectl/), [`kubectl-oidc_login`](https://github.com/int128/kubelogin#setup), [`pack`](https://buildpacks.io/docs/tools/pack/), [`docker`](https://docs.docker.com/get-docker/), [`helm`](https://helm.sh/docs/intro/install/), [`cf`](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html)
243243
- Logged into Kyma Runtime (with `kubectl` CLI), Cloud Foundry space (with `cf` CLI) and Container Registry (with `docker login`)
244-
- `@sap/cds-dk` >= 6.0.1
244+
- `@sap/cds-dk` >= 6.6.0
245245

246246
### Add Deployment Files
247247

248-
CAP tooling provides your a Helm chart for deployment to Kyma.
248+
CAP tooling provides you a Helm chart for deployment to Kyma.
249249

250-
Add the CAP Helm chart with the required features to this project:
250+
For single tenant deployment, replace the `requires` section in _`.cdsrc.json`_ with:
251251

252-
```bash
253-
cds add helm
254-
cds add hana
255-
cds add xsuaa
256-
cds add html5-repo
252+
```
253+
"requires": {
254+
"auth": {
255+
"kind": "xsuaa"
256+
},
257+
"approuter": {
258+
"kind": "cloudfoundry"
259+
},
260+
"db": {
261+
"kind": "hana-cloud"
262+
}
263+
},
257264
```
258265

259-
#### Helm chart configuration
266+
For multi tenant deployment, replace the `requires` section in _`.cdsrc.json`_ with:
260267

261-
This project contains a pre-configured configuration file `values.yaml`, you just need to do the following changes in this file:
268+
```
269+
"requires": {
270+
"multitenancy": true,
271+
"extensibility": true,
272+
"toggles": true,
273+
"auth": {
274+
"kind": "xsuaa"
275+
},
276+
"approuter": {
277+
"kind": "cloudfoundry"
278+
}
279+
},
280+
```
262281

263-
- `<your-container-registry>` - full-qualified hostname of your container registry
264-
- `domain`- full-qualified domain name used to access applications in your Kyma cluster
282+
Add the CAP Helm chart with the required features to this project:
283+
284+
```bash
285+
cds add helm
286+
```
265287

266-
#### Use API_BUSSINESS_PARTNER Remote Service (optional)
288+
#### Use API_BUSSINESS_PARTNER Remote Service (optional, single tenant only)
267289

268290
You can try the `API_BUSINESS_PARTNER` service with a real S/4HANA system with the following configuration:
269291

270292
1. Create either an on-premise or cloud destination in your subaccount.
271293

272-
2. Add the binding to the destination service for the service (`srv`) to the `values.yaml` file:
294+
2. Add configuration required for the destination service by executing the following command.
273295

274-
```yaml
275-
srv:
276-
...
277-
bindings:
278-
...
279-
destinations:
280-
serviceInstanceName: destinations
296+
```bash
297+
cds add destination
281298
```
282299

283-
(The destination service instance is already configured)
284-
285300
3. Set the profiles `cloud` and `destination` active in your `values.yaml` file:
286301

287302
```yaml
288303
srv:
289304
...
290305
env:
291306
SPRING_PROFILES_ACTIVE: cloud,destination
292-
# TODO: To be removed after @sap/cds-dk patch
293-
CDS_ENVIRONMENT_K8S_SERVICEBINDINGS_CONNECTIVITY_SECRETSPATH: '/bindings/connectivity'
294-
CDS_ENVIRONMENT_K8S_SERVICEBINDINGS_CONNECTIVITY_SERVICE: 'connectivity'
295307
```
296308

297309
4. For on-premise only: Add the connectivity service to your Helm chart:
@@ -300,6 +312,8 @@ You can try the `API_BUSINESS_PARTNER` service with a real S/4HANA system with t
300312
cds add connectivity
301313
```
302314

315+
Note: `cds add helm` will not add configuration required to create a Connectivity Service Instance. This Service Instance should be created by the Kyma Cluster Administrator. For more information regarding configuration of Connectivity Instance, please check the [documentation](https://cap.cloud.sap/docs/guides/deployment/deploy-to-kyma#connectivity-service).
316+
303317
*See also: [API_BUSINESS_PARTNER Remote Service and Spring Profiles](#api_business_partner-remote-service-and-spring-profiles)*
304318

305319
### Prepare Kubernetes Namespace
@@ -314,78 +328,198 @@ bash ./scripts/create-container-registry-secret.sh
314328

315329
The *Docker Server* is the full qualified hostname of your container registry.
316330

317-
#### Create a HDI container and a secret
331+
#### Create a HDI container / Service Manager Instance and a Secret
332+
333+
This step is only required if you're using a BTP Trial account. If you're using a production or a free tier account then you can create HDI Container from Kyma directly by adding a [mapping to your Kyma namespace in your HANA Cloud Instance](https://blogs.sap.com/2022/12/15/consuming-sap-hana-cloud-from-the-kyma-environment/) and skip this step.
334+
335+
##### Single Tenant
318336

319337
```
320338
bash ./scripts/create-db-secret.sh bookshop-db
321339
```
322340

323-
It will create a HDI container `bookshop-db` on your currently targeted Cloud Foundry space and creates a secret `bookshop-db` with the HDI container's credentials in your current Kubernetes namespace.
341+
It will create a HDI container `bookshop-db` instance on your currently targeted Cloud Foundry space and a secret `bookshop-db` with the credentials in your current Kubernetes namespace.
324342

325-
### Build
343+
Make the following changes to your _`chart/values.yaml`_.
344+
345+
```diff
346+
srv:
347+
bindings:
348+
db:
349+
- serviceInstanceName: hana
350+
+ fromSecret: bookshop-db
351+
...
326352
327-
**Build data base deployer image:**
353+
hana-deployer:
354+
bindings:
355+
hana:
356+
- serviceInstanceName: hana
357+
+ fromSecret: bookshop-db
328358
359+
...
360+
- hana:
361+
- serviceOfferingName: hana
362+
- servicePlanName: hdi-shared
329363
```
330-
cds build --production
331364

332-
pack build $YOUR_CONTAINER_REGISTRY/bookshop-hana-deployer \
333-
--path db \
334-
--buildpack gcr.io/paketo-buildpacks/nodejs \
335-
--builder paketobuildpacks/builder:base
365+
##### Multi Tenant
366+
367+
```
368+
bash ./scripts/create-sm-secret.sh bookshop-sm
336369
```
337370

338-
(Replace `$YOUR_CONTAINER_REGISTRY` with the full-qualified hostname of your container registry)
371+
It will create a Service Manager `bookshop-sm` instance on your currently targeted Cloud Foundry space and a secret `bookshop-sm` with the credentials in your current Kubernetes namespace.
339372

373+
Make the following changes to your _`chart/values.yaml`_.
340374

341-
**Build image for CAP service:**
375+
```diff
376+
srv:
377+
bindings:
378+
service-manager:
379+
- serviceInstanceName: service-manager
380+
+ fromSecret: bookshop-sm
381+
...
342382
383+
sidecar:
384+
bindings:
385+
service-manager:
386+
- serviceInstanceName: service-manager
387+
+ fromSecret: bookshop-sm
388+
389+
...
390+
- service-manager:
391+
- serviceOfferingName: service-manager
392+
- servicePlanName: container
343393
```
344-
mvn package
394+
395+
### Build
396+
397+
```bash
398+
cds build --production
345399
```
346400

401+
**Build image for CAP service:**
402+
403+
```bash
404+
mvn clean package -DskipTests=true
347405
```
406+
407+
```bash
348408
pack build $YOUR_CONTAINER_REGISTRY/bookshop-srv \
349409
--path srv/target/*-exec.jar \
350410
--buildpack gcr.io/paketo-buildpacks/sap-machine \
351411
--buildpack gcr.io/paketo-buildpacks/java \
352412
--builder paketobuildpacks/builder:base \
353-
--env SPRING_PROFILES_ACTIVE=cloud
413+
--env SPRING_PROFILES_ACTIVE=cloud \
414+
--env BP_JVM_VERSION=17
354415
```
355416

356-
**Build HTML5 application deployer image:**
417+
(Replace `$YOUR_CONTAINER_REGISTRY` with the full-qualified hostname of your container registry)
357418

419+
**Build Approuter Image:**
420+
421+
```bash
422+
pack build $YOUR_CONTAINER_REGISTRY/bookshop-approuter \
423+
--path app \
424+
--buildpack gcr.io/paketo-buildpacks/nodejs \
425+
--builder paketobuildpacks/builder:base \
426+
--env BP_NODE_RUN_SCRIPTS=""
427+
```
428+
429+
**Build database deployer image (single tenant only):**
430+
431+
```bash
432+
pack build $YOUR_CONTAINER_REGISTRY/bookshop-hana-deployer \
433+
--path db \
434+
--buildpack gcr.io/paketo-buildpacks/nodejs \
435+
--builder paketobuildpacks/builder:base \
436+
--env BP_NODE_RUN_SCRIPTS=""
358437
```
359-
bash ./scripts/build-ui-image.sh
438+
439+
**Build sidecar image (multi tenant only):**
440+
441+
```bash
442+
pack build $YOUR_CONTAINER_REGISTRY/bookshop-sidecar \
443+
--path mtx/sidecar/gen \
444+
--buildpack gcr.io/paketo-buildpacks/nodejs \
445+
--builder paketobuildpacks/builder:base \
446+
--env BP_NODE_RUN_SCRIPTS=""
360447
```
361448

362449
### Push container images
363450

364451
You can push all the container images to your container registry, using:
365452

453+
```bash
454+
docker push $YOUR_CONTAINER_REGISTRY/bookshop-srv
455+
456+
docker push $YOUR_CONTAINER_REGISTRY/bookshop-approuter
366457
```
367-
docker push $YOUR_CONTAINER_REGISTRY/bookshop-hana-deployer
368458

369-
docker push $YOUR_CONTAINER_REGISTRY/bookshop-srv
459+
#### Single Tenant
370460

371-
docker push $YOUR_CONTAINER_REGISTRY/bookshop-html5-deployer
461+
```bash
462+
docker push $YOUR_CONTAINER_REGISTRY/bookshop-hana-deployer
372463
```
373464

374-
### Deployment
465+
#### Multi Tenant
375466

467+
```bash
468+
docker push $YOUR_CONTAINER_REGISTRY/bookshop-sidecar
469+
```
470+
471+
### Configuration
472+
473+
Make the following changes in the _`chart/values.yaml`_ file.
474+
475+
1. Change value of `global.domain` key to your cluster domain.
476+
477+
2. Replace `<your-cluster-domain>` in `xsuaa.parameters.oauth2-configuration.redirect-uris` with your cluster domain.
478+
479+
3. Replace `<your-container-registry>` with your container registry.
480+
481+
4. Make the following change to add backend destinations required by Approuter.
482+
483+
```diff
484+
- backendDestinations: {}
485+
+ backendDestinations:
486+
+ backend:
487+
+ service: srv
488+
+ mtx-api:
489+
+ service: srv
376490
```
377-
helm upgrade bookshop ./chart --install -f values.yaml
491+
492+
5. Add your image registry secret created in [Create container registry secret](#create-container-registry-secret) step.
493+
494+
```diff
495+
global:
496+
domain: null
497+
- imagePullSecret: {}
498+
+ imagePullSecret:
499+
+ name: container-registry
378500
```
379501

380-
### Access the UI
502+
### Deployment
503+
504+
Deploy the helm chart using the following command:
505+
506+
#### Single Tenant
507+
508+
```bash
509+
helm install bookshop ./chart --set-file xsuaa.jsonParameters=xs-security.json
510+
```
381511

382512
Before you can access the UI you should make sure to [Setup Authorizations in SAP Business Technology Platform](#setup-authorizations-in-sap-business-technology-platform).
383513

384-
1. Create a Launchpad Service subscription in the BTP Cockpit
385-
2. Go to **HTML5 Applications**
386-
3. Start any of the HTML5 applications
514+
Click on the approuter url logged by the `helm install` to access the UI.
515+
516+
#### Multi Tenant
517+
518+
```bash
519+
helm install bookshop ./chart --set-file xsuaa.jsonParameters=xs-security-mt.json
520+
```
387521

388-
Additionally, you can add the UIs to a Launchpad Service site like it is described in in the last two steps of [this tutorial](https://developers.sap.com/tutorials/btp-app-kyma-launchpad-service.html#9aab2dd0-18ea-4ccd-bc44-24e87c845740).
522+
In case of multi tenant, you'll have to subscribe to the application from a different subaccount. You can follow the steps mentioned [here](https://cap.cloud.sap/docs/guides/deployment/as-saas#subscribe) to access the application.
389523
390524
## Setup Authorizations in SAP Business Technology Platform
391525

scripts/build-ui-image.sh

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)