Skip to content

Commit 2ec9fc8

Browse files
committed
2 parents dbd1ab6 + 9039049 commit 2ec9fc8

File tree

1 file changed

+316
-0
lines changed

1 file changed

+316
-0
lines changed

tutorials/deploy-to-kyma/deploy-to-kyma.md

Lines changed: 316 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ Kyma runs on containers. Hence, for this tutorial, you'll need an application th
252252

253253
### Build images
254254

255+
[OPTION BEGIN [Node.js]]
255256
>- Make sure you're logged in to your container registry.
256257
>
257258
>- If you're using any device with a non-x86 processor (e.g. MacBook M1/M2) you need to instruct Docker to use x86 images by setting the **DOCKER_DEFAULT_PLATFORM** environment variable using the command `export DOCKER_DEFAULT_PLATFORM=linux/amd64`. Check [Environment variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables) for more info.
@@ -501,6 +502,264 @@ Kyma runs on containers. Hence, for this tutorial, you'll need an application th
501502
502503
> In case you're using Docker Hub as your container registry, replace the placeholder `<your-container-registry>` with your Docker Hub user ID.
503504

505+
[OPTION END]
506+
[OPTION BEGIN [Java]]
507+
508+
>- Make sure you're logged in to your container registry.
509+
>
510+
>- If you're using any device with a non-x86 processor (e.g. MacBook M1/M2) you need to instruct Docker to use x86 images by setting the **DOCKER_DEFAULT_PLATFORM** environment variable using the command `export DOCKER_DEFAULT_PLATFORM=linux/amd64`. Check [Environment variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables) for more info.
511+
512+
#### Build the CAP Java and the database image
513+
514+
1. In VS Code, choose **Terminal** &rarr; **New Terminal** and run the following command:
515+
516+
```bash
517+
npm install
518+
```
519+
520+
This will install required dependencies and update the **package-lock.json** file of your project.
521+
522+
2. Create the productive CAP build for your application:
523+
524+
```bash
525+
cds build --profile production,java
526+
```
527+
528+
3. Add configuration for the managed App Router:
529+
530+
```bash
531+
cds add workzone
532+
```
533+
534+
4. Add additional configuration for the XSUAA and HANA:
535+
536+
```bash
537+
cds add xsuaa,hana --for production
538+
```
539+
540+
5. Build the CAP Java image:
541+
542+
```bash
543+
pack build <your-container-registry>/incident-management-srv:<image-version> \
544+
--path srv/target/*-exec.jar \
545+
--builder paketobuildpacks/builder-jammy-base \
546+
--publish
547+
```
548+
549+
> Make sure to replace `<your-container-registry>` with your docker server URL and keep in mind that `<image version>` should be a string.
550+
551+
> Looking for your docker server URL?
552+
553+
> The docker server URL is the same as the path used for docker login, so you can quickly check it by running the following command in your terminal:
554+
555+
> ```json
556+
> cat ~/.docker/config.json
557+
> ```
558+
559+
> In case you're using Docker Hub as your container registry, replace the placeholder `<your-container-registry>` with your Docker Hub user ID.
560+
561+
> The pack CLI builds the image that contains the build result in the **gen/srv** folder and the required npm packages by using the [Cloud Native Buildpack for Node.JS](https://github.com/paketo-buildpacks/nodejs) provided by Paketo.
562+
563+
6. Build the database image:
564+
565+
```bash
566+
pack build <your-container-registry>/incident-management-hana-deployer:<image-version> \
567+
--path db \
568+
--env BP_NODE_RUN_SCRIPTS="" \
569+
--builder paketobuildpacks/builder-jammy-base \
570+
--publish
571+
```
572+
573+
> Make sure to replace `<your-container-registry>` with the link to your container registry and keep in mind that `<image version>` should be a string.
574+
575+
> Looking for your docker server URL?
576+
577+
> The docker server URL is the same as the path used for docker login, so you can quickly check it by running the following command in your terminal:
578+
579+
> ```json
580+
> cat ~/.docker/config.json
581+
> ```
582+
583+
> In case you're using Docker Hub as your container registry, replace the placeholder `<your-container-registry>` with your Docker Hub user ID.
584+
585+
#### Prepare the UI deployer image configuration and build the image
586+
587+
1. In the VS Code terminal, navigate to the **app/incidents** folder and run the following command:
588+
589+
```bash
590+
npm install && npm run build
591+
```
592+
593+
3. Create a new file **xs-app.json** in **app/incidents/** and add the following code to it:
594+
595+
```json
596+
{
597+
"welcomeFile": "/index.html",
598+
"authenticationMethod": "route",
599+
"routes": [
600+
{
601+
"source": "^/odata/v4/processor/(.*)$",
602+
"destination": "srv-api",
603+
"authenticationType": "xsuaa"
604+
},
605+
{
606+
"source": "^/resources/(.*)$",
607+
"target": "/resources/$1",
608+
"authenticationType": "none",
609+
"destination": "ui5"
610+
},
611+
{
612+
"source": "^/test-resources/(.*)$",
613+
"target": "/test-resources/$1",
614+
"authenticationType": "none",
615+
"destination": "ui5"
616+
},
617+
{
618+
"source": "^(.*)$",
619+
"target": "$1",
620+
"service": "html5-apps-repo-rt",
621+
"authenticationType": "xsuaa"
622+
}
623+
]
624+
}
625+
```
626+
627+
> In case the **xs-app.json** already exists, replace its content with the snippet above.
628+
629+
4. Open **app/incidents/webapp/manifest.json** and remove the leading `/` from the `uri` parameter.
630+
631+
```json[10]
632+
{
633+
"_version": "1.49.0",
634+
"sap.app": {
635+
"id": "ns.incidents",
636+
"type": "application",
637+
"i18n": "i18n/i18n.properties",
638+
...
639+
"dataSources": {
640+
"mainService": {
641+
"uri": "odata/v4/ProcessorService/",
642+
"type": "OData",
643+
"settings": {
644+
"annotations": [],
645+
"localUri": "localService/metadata.xml",
646+
"odataVersion": "4.0"
647+
}
648+
}
649+
},
650+
...
651+
},
652+
...
653+
}
654+
```
655+
656+
This is needed as the dataSource URIs must be relative to the base URL, which means there is no need for a slash as the first character.
657+
658+
Check [Accessing Business Service UI](https://help.sap.com/docs/btp/sap-business-technology-platform/accessing-business-service-ui?locale=39723061bc4b4b679726b120cbefdf5a.html&q=base%20URL) for more information.
659+
660+
5. Add navigation configuration and deploy configuration to the **app/incidents/webapp/manifest.json** file:
661+
662+
```json[9-22,25-28]
663+
{
664+
"_version": "1.49.0",
665+
"sap.app": {
666+
"id": "ns.incidents",
667+
...
668+
"dataSources": {
669+
...
670+
},
671+
"crossNavigation": {
672+
"inbounds": {
673+
"incidents-display": {
674+
"semanticObject": "incidents",
675+
"action": "display",
676+
"title": "{{flpTitle}}",
677+
"subTitle": "{{flpSubtitle}}",
678+
"signature": {
679+
"parameters": {},
680+
"additionalParameters": "allowed"
681+
}
682+
}
683+
}
684+
}
685+
},
686+
...
687+
"sap.cloud": {
688+
"public": true,
689+
"service": "incidents"
690+
}
691+
}
692+
```
693+
694+
6. Create a new folder **ui-resources** in your project's root folder.
695+
696+
The HTML5 applications deployer looks for the **ui-resources** folder which has the static files of the HTML5 application.
697+
698+
7. Create a new file **package.json** inside the **ui-resources** folder and add the following code to the file:
699+
700+
```json
701+
{
702+
"name": "incident-management",
703+
"version": "0.0.1",
704+
"description": "A Fiori application.",
705+
"keywords": [
706+
"ui5",
707+
"openui5",
708+
"sapui5"
709+
],
710+
"scripts": {
711+
"start": "node node_modules/@sap/html5-app-deployer/index.js",
712+
"build:ui5": "npm run build --prefix ../app/incidents --if-present",
713+
"copyzips": "copyfiles -f ../app/*/dist/*.zip ./resources/",
714+
"package": "run-s build:ui5 copyzips"
715+
},
716+
"dependencies": {
717+
"@sap/html5-app-deployer": "^6.2.0"
718+
},
719+
"devDependencies": {
720+
"copyfiles": "^2.4.1",
721+
"npm-run-all": "^4.1.5"
722+
}
723+
}
724+
725+
```
726+
727+
8. In the VS Code terminal, navigate to the **ui-resources** folder and run the following command:
728+
729+
```bash
730+
npm install && npm run package
731+
```
732+
733+
This will build and copy the archive **nsincidents.zip** inside the **ui-resources/resources** folder.
734+
735+
9. In the VS Code terminal, navigate back to the root folder of your project:
736+
737+
```bash
738+
cd ..
739+
```
740+
741+
10. Build the UI deployer image:
742+
743+
```bash
744+
pack build <your-container-registry>/incident-management-html5-deployer:<image-version> \
745+
--path ui-resources \
746+
--builder paketobuildpacks/builder-jammy-base \
747+
--publish
748+
```
749+
750+
> Make sure to replace `<your-container-registry>` with the link to your container registry and keep in mind that `<image version>` should be a string.
751+
752+
> Looking for your docker server URL?
753+
754+
> The docker server URL is the same as the path used for docker login, so you can quickly check it by running the following command in your terminal:
755+
756+
> ```json
757+
> cat ~/.docker/config.json
758+
> ```
759+
760+
> In case you're using Docker Hub as your container registry, replace the placeholder `<your-container-registry>` with your Docker Hub user ID.
761+
[OPTION END]
762+
504763
### Add Helm chart
505764

506765
CAP provides a configurable Helm chart for Node.js applications.
@@ -609,6 +868,7 @@ CAP provides a configurable Helm chart for Node.js applications.
609868
610869
### Deploy CAP Helm chart
611870
871+
[OPTION BEGIN [Node.js]]
612872
1. Update the productive CAP build for your application:
613873
614874
```bash
@@ -660,3 +920,59 @@ CAP provides a configurable Helm chart for Node.js applications.
660920
<!-- border; size:540px ![401 error](./401-error.png) -->
661921
662922
In the next tutorial, you will access your UIs from SAP Build Work Zone, standard edition. The SAP Build Work Zone, standard edition will trigger the authentication flow to provide the required token to access the service.
923+
924+
[OPTION END]
925+
[OPTION BEGIN [Java]]
926+
927+
1. Update the productive CAP build for your application:
928+
929+
```bash
930+
cds build --profile production,java
931+
```
932+
933+
2. Run the following command to create a namespace:
934+
935+
```bash
936+
kubectl create namespace incident-management
937+
kubectl label namespace incident-management istio-injection=enabled
938+
```
939+
940+
3. Make sure your SAP HANA Cloud instance is running. Free tier HANA instances are stopped overnight.
941+
942+
> Your SAP HANA Cloud service instance will be automatically stopped overnight, according to the server region time zone. That means you need to restart your instance every day before you start working with it.
943+
>
944+
> You can either use SAP BTP cockpit or the terminal in the SAP Business Application Studio to restart the stopped instance:
945+
>
946+
> ```bash
947+
> cf update-service incident-management -c '{"data":{"serviceStopped":false}}'
948+
> ```
949+
950+
3. Deploy using the Helm command:
951+
952+
```bash
953+
helm upgrade --install incident-management --namespace incident-management ./gen/chart \
954+
--set-file xsuaa.jsonParameters=xs-security.json
955+
```
956+
957+
This installs the Helm chart from the **chart** folder with the release name **incident-management** in the namespace **incident-management**.
958+
959+
> With the ***helm upgrade --install*** command you can install a new chart as well as upgrade an existing chart.
960+
961+
The outcome of installation looks like this:
962+
963+
<!-- border; size:540px --> ![Deployed app](./deployedapp.png)
964+
965+
<!-- 6. Enter the route displayed for **srv** in your browser. -->
966+
967+
<!-- border; size:540px ![Depoyed app route](./deployedapp-route.png) -->
968+
969+
<!-- You see the CAP start page: -->
970+
971+
<!-- border; size:540px ![CAP start page](./cap-start-page.png) -->
972+
973+
<!-- 4. When you choose the **Incidents** service entity, you will see an error message. -->
974+
975+
<!-- border; size:540px ![401 error](./401-error.png) -->
976+
977+
In the next tutorial, you will access your UIs from SAP Build Work Zone, standard edition. The SAP Build Work Zone, standard edition will trigger the authentication flow to provide the required token to access the service.
978+
[OPTION END]

0 commit comments

Comments
 (0)