Skip to content

Update to APIRule V2 and update packages dependencies. #23961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ primary_tag: software-product>sap-btp\, kyma-runtime
<!-- description --> Use the tenant-aware approuter application in SAP BTP, Kyma runtime.

## Prerequisites
- You have finished the tutorials [Create a Basic Node.js Application with Express Generator](basic-nodejs-application-create) and [Deploy a Node.js Application in the Kyma Runtime](deploy-nodejs-application-kyma), or cloned the repository: [btp-kyma-runtime-multitenancy-tutorial](https://github.com/SAP-samples/btp-kyma-runtime-multitenancy-tutorial) to find the source for both missions.
- You have finished the tutorials [Create a Basic Node.js Application with Express Generator](basic-nodejs-application-create) and [Deploy a Node.js Application in SAP BTP, Kyma runtime](deploy-nodejs-application-kyma), or cloned the repository: [btp-kyma-runtime-multitenancy-tutorial](https://github.com/SAP-samples/btp-kyma-runtime-multitenancy-tutorial) to find the source for both missions.

## You will learn
- What is SAP Application Router
- How to create and configure Application Router
- How to configure Destination for Application Router in Kyma Runtime
- How to configure Destination for Application Router in Kyma runtime
- How to describe Kubernetes objects for Application Router


Expand Down Expand Up @@ -45,8 +45,8 @@ cd kyma-multitenant-approuter
{
"name": "kyma_multitenant_approuter",
"dependencies": {
"@sap/xsenv": "^3",
"@sap/approuter": "^8"
"@sap/xsenv": "^5",
"@sap/approuter": "^20"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
Expand Down Expand Up @@ -77,6 +77,18 @@ In the folder `kyma-multitenant-approuter`, create a file `xs-app.json` with the
}
```

### Determine SAP BTP Subaccount Subdomain and Cluster Domain

Open your subaccount in SAP BTP cockpit. In the overview page, find the subaccount's subdomain.

Find your cluster domain in the APIServerURL field. It contains the URL in the following format:
> Example: https://api.xxxxx.kyma.ondemand.com

Your `clusterdomain` is `xxxxx.kyma.ondemand.com`.

`subdomain` and `clusterdomain` will be quoted in subsequent deployment definition.

<!-- border -->![check_subdomain_clusterdomain](./check_subdomain_clusterdomain.png)



Expand All @@ -85,7 +97,7 @@ In the folder `kyma-multitenant-approuter`, create a file `xs-app.json` with the

The destinations configuration can be provided by the `destinations` environment variable or by destination service.

In order to provide `destinations` environment variable to the approuter application, you should create a `ConfigMap` object for the approuter's reference.
In order to provide the `destinations` environment variable to the approuter application, create a `ConfigMap` object that can be referenced later.

Create a new deployment YAML file named `k8s-deployment-approuter.yaml` for the approuter app with the following content:

Expand All @@ -98,7 +110,7 @@ metadata:
data:
destinations: |
[
{"name":"dest_kyma_multitenant_node","url":"https://<subaccount-subdomain>-node.<cluster-domain>","forwardAuthToken" : true}
{"name":"dest_kyma_multitenant_node","url":"https://<subaccount-subdomain>-node.<clusterdomain>","forwardAuthToken" : true}
]
```

Expand All @@ -115,7 +127,7 @@ data:
### Define Deployment


Define the deployment object by adding the following code snippets in the file `k8s-deployment-approuter.yaml`:
Create a YAML file for the approuter app called `k8s-deployment-approuter.yaml`:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Create a YAML file for the approuter app called `k8s-deployment-approuter.yaml`:
Add the deployment object to the file `k8s-deployment-approuter.yaml`:

I guess it's the same file already created in the previous step


```YAML
---
Expand All @@ -140,6 +152,7 @@ spec:
labels:
app: kyma-multitenant-approuter-multitenancy
release: multitenancy
sidecar.istio.io/inject: "true" # Enable Istio sidecar injection on Deployment and all Pods
spec:
automountServiceAccountToken: false
imagePullSecrets:
Expand Down Expand Up @@ -237,7 +250,7 @@ spec:
app: kyma-multitenant-approuter-multitenancy
release: multitenancy
---
apiVersion: gateway.kyma-project.io/v1alpha1
apiVersion: gateway.kyma-project.io/v2
kind: APIRule
metadata:
creationTimestamp: null
Expand All @@ -246,20 +259,14 @@ metadata:
release: multitenancy
name: kyma-multitenant-approuter-multitenancy
spec:
gateway: kyma-gateway.kyma-system.svc.cluster.local
gateway: kyma-system/kyma-gateway
hosts:
- <subaccount-subdomain>-approuter.<clusterdomain> # Replace <subaccount-subdomain> with the subdomain of your subaccount, and <clusterdomain> with the domain of your Kyma cluster
rules:
- accessStrategies:
- handler: allow
methods:
- GET
- POST
- PUT
- PATCH
- DELETE
- HEAD
path: /.*
- path: /*
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]
noAuth: true
service:
host: <subaccount-subdomain>-approuter.<cluster-domain>
name: kyma-multitenant-approuter-multitenancy
port: 8080
```
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ primary_tag: software-product>sap-btp\, kyma-runtime
---

# Deploy a Multitenant Application to a Provider subaccount, Kyma Runtime
<!-- description --> Build a Node.js application into OCI image and push it into Docker registry. Based on that, deploy the application into the Kyma runtime.
<!-- description --> Build a Node.js application into OCI image and push it into Docker registry. Based on that, deploy the application into SAP BTP, Kyma runtime.

## Prerequisites
- You have a Kyma runtime environment on SAP Business Technology Platform (BTP) and the relevant command line tools. If not, please follow the tutorials [Enable SAP BTP, Kyma Runtime](cp-kyma-getting-started) and [Install the Kubernetes Command Line Tool](cp-kyma-download-cli).
- You have a Kyma runtime environment on SAP Business Technology Platform (BTP) and the relevant command line tools. If not, please follow the tutorials [Enable SAP BTP, Kyma runtime](cp-kyma-getting-started) and [Install the Kubernetes Command Line Tool](cp-kyma-download-cli).
- You have installed [Docker](https://docs.docker.com/get-started/#download-and-install-docker).
- You have [Docker Hub](https://hub.docker.com/) account.
- You have finished the tutorial [Register a Multitenant Application to the SAP SaaS Provisioning Service](register-multitenant-app-saas-provisioning-service).
Expand All @@ -27,33 +27,21 @@ primary_tag: software-product>sap-btp\, kyma-runtime

### Determine SAP BTP Subaccount Subdomain

Open your subaccount in SAP BTP cockpit. Make sure you've already enabled SAP BTP, Kyma runtime on your cluster.

Open your subaccount in the Cockpit. In the overview page, find the subdomain for your deployment.

For example:

<!-- border -->![image-20211214133316133](image-20211214133316133.png)


### Determine Kyma Cluster Domain


Find the full Kyma cluster domain in the downloaded `kubeconfig.yml` file. For example: `e6803e4.kyma.shoot.live.k8s-hana.ondemand.com`.





### Build Application to OCI Image
### Build Application as OCI Image


1. Install tool
<p> </p>
In order to run your code on the Kyma Runtime (or on any Kubernetes-based platform), you need to provide an OCI image (aka Docker image) for your application. While you are in principle free to choose your image building tool, we recommend using [Cloud Native Buildpacks (CNB)](https://buildpacks.io/).
In order to run your code on Kyma runtime (or on any Kubernetes-based platform), you need to provide an OCI image (aka Docker image) for your application. While you are in principle free to choose your image building tool, we recommend using [Cloud Native Buildpacks (CNB)](https://buildpacks.io/).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In order to run your code on Kyma runtime (or on any Kubernetes-based platform), you need to provide an OCI image (aka Docker image) for your application. While you are in principle free to choose your image building tool, we recommend using [Cloud Native Buildpacks (CNB)](https://buildpacks.io/).
In order to run your code on Kyma runtime (or on any Kubernetes-based platform), you must provide an OCI image (aka Docker image) for your application. While you are, in principle, free to choose your image-building tool, we recommend using [Cloud Native Buildpacks (CNB)](https://buildpacks.io/).

<p> </p>
The command-line tool `pack` supports providing a buildpack and your local source code and creating an OCI image from it. We are working on a process to provide recommended and supported buildpacks. In the meantime, you can use the community-supported [Paketo Buildpacks](https://paketo.io/).
<p> </p>
If you followed the tutorials [Create a Basic Node.js Application with Express Generator](basic-nodejs-application-create) and [Deploy a Node.js Application in the Kyma Runtime](deploy-nodejs-application-kyma), you have installed the command-line tool `pack`, if not, please follow this official guide: [Install Pack](https://buildpacks.io/docs/tools/pack/).
If you followed the tutorials [Create a Basic Node.js Application with Express Generator](basic-nodejs-application-create) and [Deploy a Node.js Application in SAP BTP, Kyma runtime](deploy-nodejs-application-kyma), you have installed the command-line tool `pack`. If not, please follow this official guide: [Install Pack](https://buildpacks.io/docs/tools/pack/).

For example (macOS):
```Shell / Bash
Expand All @@ -64,17 +52,19 @@ brew install buildpacks/tap/pack
<p> </p>
When we speak about repository name, we mean the combination of account and repo name that is usual with Docker Hub: `<docker-hub-account>/<repo-name>`. An example would be `tiaxu/multitenant-kyma-backend`.
<p> </p>
As you can only create one private repository in a free Docker hub account, Docker images stored in Docker hub will have different tag names so that they can be stored in one repository. Thus, addressing an image will include the tag name:`<docker-hub-account>/<repo-name>:<tag-name>`. An example would be `tiaxu/multitenant-kyma-backend:v1`.
As you can only create one private repository in a free Docker hub account, Docker images stored in Docker hub will have different tag names so that they can be stored in one repository. Thus, addressing an image will include the tag name:`<docker-hub-account>/<repo-name>:<tag-name>`. An example would be `tiaxu/multitenant-kyma-backend:v2`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
As you can only create one private repository in a free Docker hub account, Docker images stored in Docker hub will have different tag names so that they can be stored in one repository. Thus, addressing an image will include the tag name:`<docker-hub-account>/<repo-name>:<tag-name>`. An example would be `tiaxu/multitenant-kyma-backend:v2`.
As you can only create one private repository in a free Docker Hub account, Docker images stored in Docker Hub will have different tag names so that they can be stored in one repository. Thus, addressing an image will include the tag name:`<docker-hub-account>/<repo-name>:<tag-name>`. An example would be `tiaxu/multitenant-kyma-backend:v2`.

<p> </p>
In the directory `kyma-multitenant-approuter`, build the image for the approuter app from source, for example:
```Shell / Bash
pack build <docker-hub-account>/multitenant-approuter:v1 --builder paketobuildpacks/builder-jammy-full
```
In the directory `kyma-multitenant-approuter`, build the image for the approuter app from source, for example:

In the directory `kyma-multitenant-node`, build the image for the approuter app from source, for example:
```Shell / Bash
pack build <docker-hub-account>/multitenant-kyma-backend:v1 --builder paketobuildpacks/builder-jammy-full
```
```Shell / Bash
pack build <docker-hub-account>/multitenant-approuter:v1 --builder paketobuildpacks/builder-jammy-full
```
<p> </p>
In the directory `kyma-multitenant-node`, build the image for the multitenant backend app from source, for example:

```Shell / Bash
pack build <docker-hub-account>/multitenant-kyma-backend:v2 --builder paketobuildpacks/builder-jammy-full
```



Expand All @@ -92,7 +82,7 @@ docker login -u <docker-id> -p <password>

```Shell / Bash
docker push <docker-hub-account>/multitenant-approuter:v1
docker push <docker-hub-account>/multitenant-kyma-backend:v1
docker push <docker-hub-account>/multitenant-kyma-backend:v2
```

> For more details, see the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/).
Expand All @@ -103,10 +93,25 @@ docker push <docker-hub-account>/multitenant-kyma-backend:v1

### Create Namespace

If you followed the tutorials [Create a Basic Node.js Application with Express Generator](basic-nodejs-application-create) and [Deploy a Node.js Application in the Kyma Runtime](deploy-nodejs-application-kyma), you have created a namespace in Kyma dashboard called `multitenancy-ns`. If not, create a new namespace `multitenancy-ns` through Kyma dashboard or `kubectl` CLI:

If you followed the tutorials [Create a Basic Node.js Application with Express Generator](basic-nodejs-application-create) and [Deploy a Node.js Application in the Kyma Runtime](deploy-nodejs-application-kyma), you have created a namespace in the Kyma environment called `multitenancy-ns`. If not, create a new namespace through the Kyma dashboard or `kubectl` CLI, for example, called `multitenancy-ns`:

<!-- border -->![image-20220214150615225](image-20220214150615225.png)
**1.** Select the `Link to dashboard` to open Kyma dashboard.

<!-- border -->![image-20220112154735200](image-20220112154735200.png)

**2.** Create a new namespace through Kyma dashboard or `kubectl` CLI, for example, called `multitenancy-ns`:

<!-- border -->![create_namespace](create_namespace.png)


**3.** Enable Istio Sidecar Proxy Injection

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-06-12 at 07 54 22 You can enable sidecar injection during the namespace creation. Maybe it would be easier to include it in the previous step instead of editing the namespace when it's already created

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, move enable sidecar to Create Namespace step

Enabling Istio sidecar proxy injection for a namespace allows istiod to watch all Pod creation operations in this namespace and automatically inject newly created Pods with an Istio sidecar proxy.
Switch the toggle to enable Istio sidecar proxy injection. Click `Create` to finish namespace creation.

<!-- border -->![enable_ns_sidecar](enable_ns_sidecar.png)

> For more details, refer to the [Enable Istio Sidecar Proxy Injection](https://kyma-project.io/#/istio/user/tutorials/01-40-enable-sidecar-injection?id=enable-sidecar-injection-for-a-namespace)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> For more details, refer to the [Enable Istio Sidecar Proxy Injection](https://kyma-project.io/#/istio/user/tutorials/01-40-enable-sidecar-injection?id=enable-sidecar-injection-for-a-namespace)
> For more details, see [Enable Istio Sidecar Proxy Injection](https://kyma-project.io/#/istio/user/tutorials/01-40-enable-sidecar-injection?id=enable-sidecar-injection-for-a-namespace).




Expand All @@ -117,7 +122,7 @@ If you followed the tutorials [Create a Basic Node.js Application with Express G

Since the OCI image is stored in your Docker hub, you need to provide the access information to your Kyma cluster that you can pull the images from those repositories.

If you followed the tutorials [Create a Basic Node.js Application with Express Generator](basic-nodejs-application-create) and [Deploy a Node.js Application in the Kyma Runtime](deploy-nodejs-application-kyma), you have configured the credential of your Docker Hub as a Secret. If not, create a new Secret with the following command, replace the placeholder values according to your account:
If you followed the tutorials [Create a Basic Node.js Application with Express Generator](basic-nodejs-application-create) and [Deploy a Node.js Application in SAP BTP, Kyma runtime](deploy-nodejs-application-kyma), you have configured the credential of your Docker Hub as a Secret. If not, create a new Secret with the following command, replace the placeholder values according to your account:

```Shell / Bash
kubectl -n multitenancy-ns create secret docker-registry registry-secret --docker-server=https://index.docker.io/v1/ --docker-username=<docker-id> --docker-password=<password> --docker-email=<email>
Expand All @@ -135,7 +140,7 @@ imagePullSecrets:



### Deploy Application into Kyma Runtime
### Deploy Application into SAP BTP, Kyma runtime


**1.** Deploy consumed services by executing this command:
Expand All @@ -157,6 +162,16 @@ kubectl -n multitenancy-ns apply -f k8s-deployment-backend.yaml
```


### Check Application Deployment state


Launch Kyma dashboard from SAP BTP cockpit, then navigate to the `multitenancy-ns` namespace.

Go to `Workloads`, and then select `Deployments`. You will see deployments of **kyma-multitenant-approuter-multitenancy** and **kyma-multitenant-node-multitenancy** displayed, with their `Pods` statuses shown in green. At this point, your multitenant application has been deployed successfully.

<!-- border -->![deploy_multi_succeed](deploy_multi_succeed.png)





Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading