The SAP HTML5 Application Repository Service for SAP BTP provides secure and performant storage space for all your web applications. In the previous posts, I explained how this service is used in the Cloud Foundry environment of SAP BTP. This makes much sense when the other components of your project run in the Cloud Foundry runtime or when there are no other components, and you don’t want to consume any runtime quota. But the situation changes when you want to run different project components in another runtime, such as the Kyma runtime. It doesn’t make much sense to use an MTA project for a “pseudo Cloud Foundry deployment” that will only create the service instances, and the “rest of the party” is going on in a different runtime. In this post, I’ll show you how to deploy any web application via the Kyma runtime. This web application can then be added to the SAP Launchpad service.
ID: managed-fiori
_schema-version: 3.2.0
version: 1.0.0
parameters:
enable-parallel-deployments: true
modules:
- name: HTML5Module
type: html5
path: HTML5Module
build-parameters:
builder: custom
commands:
- npm run build
supported-platforms: []
- name: webapp-deployer
type: com.sap.application.content
path: .
requires:
- name: managed-fiori-html5-repo-host
parameters:
content-target: true
build-parameters:
build-result: resources
requires:
- artifacts:
- HTML5Module-content.zip
name: HTML5Module
target-path: resources/
- name: managed-fiori-destination-content
type: com.sap.application.content
build-parameters:
no-source: true
requires:
- name: managed-fiori-uaa
parameters:
service-key:
name: managed-fiori-uaa-key
- name: managed-fiori-html5-repo-host
parameters:
service-key:
name: managed-fiori-html5-repo-host-key
- name: managed-fiori-destination
parameters:
content-target: true
parameters:
content:
instance:
existing_destinations_policy: update
destinations:
- Name: managed-fiori-destination-html5
ServiceInstanceName: managed-fiori-html5-repo-host
ServiceKeyName: managed-fiori-html5-repo-host-key
sap.cloud.service: cloud.service
- Name: managed-fiori-destination-uaa
Authentication: OAuth2UserTokenExchange
ServiceInstanceName: managed-fiori-uaa
ServiceKeyName: managed-fiori-uaa-key
sap.cloud.service: cloud.service
resources:
- name: managed-fiori-destination
type: org.cloudfoundry.managed-service
parameters:
service-plan: lite
service: destination
path: ./destination.json
- name: managed-fiori-html5-repo-host
type: org.cloudfoundry.managed-service
parameters:
service-plan: app-host
service: html5-apps-repo
config:
sizeLimit: 2
- name: managed-fiori-uaa
type: org.cloudfoundry.managed-service
parameters:
path: ./xs-security.json
service-plan: application
service: xsuaa
Sample project descriptor for the Cloud Foundry environment
---
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
name: kyma-destination-instance
spec:
clusterServiceClassExternalName: destination
clusterServicePlanExternalName: lite
parameters:
HTML5Runtime_enabled: true
version: "1.0.0"
---
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceBinding
metadata:
name: kyma-destination-binding
spec:
instanceRef:
name: kyma-destination-instance
An example of the service instance and service binding definition for a Kyma project
containers:
- image: ghcr.io/sap-samples/kyma-html5-app-deployer
imagePullPolicy: Always
name: html5appdeployer
volumeMounts:
- name: destination-volume
mountPath: /etc/secrets/sapcp/destination/kyma-destination-instance
readOnly: true
...
volumes:
- name: destination-volume
secret:
secretName: kyma-destination-binding
Mounting the service binding of the previous snippet to a pod
deployer
+-- resources
| +-- ui5-app
| | +-- index.html
| | +-- manifest.json
| | +-- xs-app.json
+-- package.json
+-- Dockerfile
The directory structure of the Kyma web app deployer application
manifest.json
and the xs-app.json
files. On the project root, you need the well-known package.json
file, which has a dependency on the html5-app-deployer
package:{
"name": "kyma-html5-app-deployer",
"version": "1.0.0",
"dependencies": {
"@sap/html5-app-deployer": "2.3.1"
},
"scripts": {
"start": "node node_modules/@sap/html5-app-deployer/index.js"
}
}
Dockerfile
in the application root to describe how the Docker image is built.FROM node:14-alpine
RUN mkdir -p /app && \
chown node.node /app
# Create app directory
WORKDIR /app
# Bundle app source
COPY . .
RUN npm install --production
CMD [ "npm", "start" ]
docker build -t <docker id>/kyma-html5-app-deployer
docker push <docker id>/kyma-html5-app-deployer
deployment
to the project manifest. This pod is based on the Docker image of the previous step. It not only uploads the web app to the HTML5 application repository but also creates all the needed instance-level destinations. For this, we need to mount the existing service binding via volumes. The final deployment.yaml
should look as follows:---
apiVersion: apps/v1
kind: Deployment
metadata:
name: html5appdeployer
labels:
app: html5appdeployer
spec:
replicas: 1
selector:
matchLabels:
app: html5appdeployer
template:
metadata:
labels:
app: html5appdeployer
spec:
containers:
- image: <docker id>/kyma-html5-app-deployer
imagePullPolicy: Always
name: html5appdeployer
volumeMounts:
- name: html5-repo-app-host-volume
mountPath: /etc/secrets/sapcp/html5-apps-repo/kyma-app-host-instance
readOnly: true
- name: xsuaa-volume
mountPath: /etc/secrets/sapcp/xsuaa/kyma-xsuaa-instance
readOnly: true
- name: destination-volume
mountPath: /etc/secrets/sapcp/destination/kyma-destination-instance
readOnly: true
env:
- name: SAP_CLOUD_SERVICE
value: "business.service"
volumes:
- name: html5-repo-app-host-volume
secret:
secretName: kyma-app-host-binding
- name: xsuaa-volume
secret:
secretName: kyma-xsuaa-binding
- name: destination-volume
secret:
secretName: kyma-destination-binding
Always
. This makes it easier to replace the current web app in the development process as you just need to upload the new image to the registry. In the next step, you can then remove the old pod from the cluster. Kyma will automatically start a new pod based on the most recent image. There's no need to modify the deployment itself.kubectl
CLI? If so, run the following command to trigger the deployment:kubectl apply -f deployment.yaml
https://<subaccount id>.launchpad.cfapps.eu10.hana.ondemand.com/<destination service instance ID>.businessservice.tokendisplay/index.html
https://43de072btrial.launchpad.cfapps.eu10.hana.ondemand.com/8aebc2e1-2234-4bd1-8da4-e15231138dbf.b...
ghcr.io/sap-samples/kyma-html5-app-deployer:latest
contains the following web app:You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
30 | |
18 | |
10 | |
9 | |
8 | |
8 | |
7 | |
7 | |
6 | |
6 |