This sample provides a Node.js CAP Service application service to demonstrate how to:
- Create a development Namespace in the Kyma runtime.
- Configure and build an CAP Service Docker image.
- Deploy the CAP Service in the Kyma runtime which includes:
- A Deployment of the CAP Service.
- An API to expose the service externally.
- Node.js
- ui5 cli
- cds sdk
- SAP BTP, Kyma runtime instance
- Docker
- Docker Hub
- kubectl configured to use the
KUBECONFIG
file downloaded from the Kyma runtime. - kubelogin, remane it to
kubectl-oidc_login.exe
Optionals:
- VS Code plugins: SAP CDS Language Support, SAP Fiori tools - Extension Pack
- SQLite, VS Code sqltools
It contains these folders and files, following our recommended project layout:
File or Folder | Purpose |
---|---|
app/ |
content for UI frontends goes here |
db/ |
your domain models and data go here |
docker/ |
Dockerfile |
k8s/ |
kubernetes deployment files |
srv/ |
your service models and code go here |
package.json |
project metadata and configuration |
README.md |
this getting started guide |
- Open a new terminal and run
cds watch
- (in VS Code simply choose Terminal > Run Task > cds watch)
- Start adding content, for example, a db/schema.cds.
- Learn more at https://cap.cloud.sap/docs/get-started/.
-
Clone the project.
git clone https://github.com/h-best-sap/sap-cap-on-kyma-kt-202306.git
-
Inside the directory, run:
cd sap-cap-on-kyma-kt-202306 npm i
-
Verify the CAP tools install by running
## npm i -g @sap/cds-dk cds
-
Deploy the DB schemas to you local
sqlite
databasecds deploy --to sqlite
-
Run the app using the command
cds watch
The application loads at http://localhost:4004
. admin service endpoints use alice
as default username, not need password.
-
Build
## docker build -t huahouye/sap-cap-on-kyma-kt-202306 -f docker/Dockerfile . docker build -t <your-docker-id>/sap-cap-on-kyma-kt-202306 -f docker/Dockerfile .
-
Run the image locally:
## docker run -p 4004:4004 huahouye/sap-cap-on-kyma-kt-202306:latest --name sap-cap-on-kyma-kt-202306 docker run -p 4004:4004 <your-docker-id>/sap-cap-on-kyma-kt-202306:latest --name sap-cap-on-kyma-kt-202306
-
Push the image to your Docker repository:
docker login ## docker push huahouye/sap-cap-on-kyma-kt-202306 docker push <your-docker-id>/sap-cap-on-kyma-kt-202306
-
Create a new
dev
Namespace:kubectl create namespace dev kubectl label namespaces dev istio-injection=enabled
-
Apply the Resources:
kubectl -n dev apply -f ./k8s/deployment.yaml kubectl -n dev apply -f ./k8s/apirule.yaml
-
Use the APIRule to open the application:
https://sap-cap-on-kyma-kt-202306.{cluster-domain}