Skip to content

Commit 78e09f1

Browse files
authored
Merge pull request #548 from mmitoraj/conn-proxy
Update the connectivity proxy sample
2 parents d35af87 + c064272 commit 78e09f1

File tree

2 files changed

+406
-107
lines changed

2 files changed

+406
-107
lines changed

connectivity-proxy/README.md

Lines changed: 101 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,142 @@
1-
## SAP Connectivity Proxy
1+
# Connectivity: Accessing a Workload in the Corporate Network or On-Premise System from SAP BTP, Kyma Runtime
22

3-
The sample demostrates the use of the SAP Cloud Connector from within SAP BTP, Kyma runtime. This includes...
3+
## Context
44

5-
- The provisioning of the Connectivity Proxy within the Kyma runtime ([SAP Help Portal link](https://help.sap.com/docs/BTP/65de2977205c403bbc107264b8eccf4b/0c035010a9d64cc8a02d872829c7fa75.html?locale=en-US)).
6-
- A sample Nodejs application is ran locally and configured in the SAP Cloud Connector to be exposed to the connected SAP BTP account.
7-
- A Serverless function is deployed within the Kyma runtime, which is configured to call the sample Nodejs application via the Connectivity Proxy.
8-
- Using a curl pod to call the sample Nodejs application via the Connectivity Proxy.
5+
If you want to access a workload in the corporate network or on-premise system from SAP BTP, Kyma runtime, you can use Connectivity Proxy from SAP BTP, Connectivity.
96

10-
### Enable the Connectivity Service Entitelment
7+
The sample demonstrates how to access workloads/APIs in the corporate network or on-premise system from SAP BTP, Kyma runtime and includes:
118

12-
In order to configure the Connectivity Proxy within the Kyma Runtime you must first make sure that the Connectivity Service Entitlement is present within your subaccount. This can be accomplished by
9+
- Adding the Connectivity Proxy module in your Kyma runtime. See [Connectivity in the Kyma Environment](https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/on-premise-connectivity-in-kyma-environment?version=Cloud).
10+
- Starting the sample Node.js application locally.
11+
- Configuring Cloud Connector to be exposed to the connected SAP BTP account.
12+
- Deploying a Serverless Function, which is configured to call the sample Node.js application via the Connectivity Proxy, in the Kyma runtime.
13+
- Using a curl Pod to call the sample Node.js application via the Connectivity Proxy.
1314

14-
- Within your global account…
15-
- Choose **Entitlements -> Entity Assignments**
16-
- Search **for Connectivity Service**
17-
- Choose **connectivity_proxy** for the plan
18-
- Choose **Add 1 Service Plan**
19-
- Choose **Save**
15+
![Cloud to On-Prem](./assets/cloud-to-on-prem.drawio.svg)
2016

21-
### Provision the Service in the Kyma Runtime
17+
## Prerequisites
2218

23-
The next step involves creating a service instance of the Connectivity Proxy and a service binding. Once the creation of the sevice binding is detected by the Kyma Control Plane, the Connectivity Proxy will be provisioned in the runtime into the namespace **kyma-system**. From within the Kyma runtime it will be accessible using the URL **connectivity-proxy.kyma-system.svc.cluster.local:20003**
19+
- SAP BTP, Kyma runtime instance
20+
- [curl](https://curl.se/)
21+
- [Kubernetes tooling](../prerequisites/README.md#kubernetes)
22+
- The service plan **connectivity_proxy** of the **connectivity** service is assigned to your subaccount as an entitlement. For more information, see [Configure Entitlements and Quotas for Subaccounts](https://help.sap.com/docs/btp/sap-business-technology-platform/configure-entitlements-and-quotas-for-subaccounts?version=Cloud).
2423

25-
- Within your desired namespace enable Istio if it is not already enabled.
24+
> [!NOTE]
25+
> For subaccounts created after February 15, 2024, this entitlement is assigned automatically.
2626
27-
```shell
28-
kubectl label namespaces <your namespace> istio-injection=enabled
29-
```
27+
- You have the Istio, SAP BTP Operator, Serverless, and Connectivity Proxy modules added. For more information, see [Adding and Deleting a Kyma Module](https://help.sap.com/docs/btp/sap-business-technology-platform/enable-and-disable-kyma-module?version=Cloud).
3028

31-
- Create the Connectivity Proxy Service Instance
29+
## Procedure
3230

33-
```shell
34-
kubectl apply -f ./k8s/connectivity-proxy-instance.yaml -n <your namespace>
35-
```
31+
### Starting the Sample Application
3632

37-
The Kyma Control Plane should now provision the Connectivity Proxy. This will generate the pod **connectivity-proxy-0** which can be found by running.
33+
1. Export the environment variable.
3834

39-
```shell
40-
kubectl get pods -n kyma-system
41-
```
35+
```bash
36+
export NS=<your namespace> # e.g. default
37+
```
4238

43-
### Configuration of the Sample Application
39+
2. Enable Istio sidecar proxy injection in your namespace.
4440

45-
To validate the setup, start the sample application included in the repo and configure it within the SAP Cloud Connector.
41+
```shell
42+
kubectl label namespaces ${NS} istio-injection=enabled
4643

47-
#### Starting the localmock application
44+
3. Start the sample Node.js application included in the repository. Clone the repository and run the following commands in the **localmock** directory:
4845

49-
After cloning the repo run the following commands in the directory **localmock**
46+
```shell
47+
npm install
48+
```
5049

51-
- Run the command
52-
```
53-
npm install
54-
```
55-
- Start the application
56-
```
57-
npm start
58-
```
50+
```shell
51+
npm start
52+
```
5953

60-
#### SAP Cloud Connector Configuration
54+
4. Download and install [Cloud Connector](https://tools.hana.ondemand.com/#cloud) and establish a connection to the **localmock** app. See [Installation](https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/installation?version=Cloud).
6155

62-
Download and install the [SAP Cloud Connector](https://tools.hana.ondemand.com/#cloud) and establish a connection to the **localmock** app. Please refer to the [help documentation](https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/e6c7616abb5710148cfcf3e75d96d596.html) for the installation steps. Make sure to also add your user to the appropiate
56+
### Configuring Cloud Connector
6357

64-
- Open the [Cloud Connector](https://localhost:8443/)
65-
- Choose the appropiate Subaccount or add an additional one by...
66-
- Choose **Add Subaccount**
67-
- Choose your Region
68-
- Provide your Subaccount ID
69-
- Provide your Subaccount User and Password
70-
- Choose Save
71-
- Verify that the subaccount is connected. Under the Actions column use the Connect this sub account option
72-
- Choose **Cloud To On-Premise**
73-
- Under the tab **ACCESS CONTROL** choose the **plus** button to add a system
74-
- Choose the Back-end Type **Non-SAP System**, choose Next
75-
- Choose the Protocol **HTTP**, choose Next
76-
- Enter the Internal Host **localhost**
77-
- Enter the Internal Port **3000**, choose Next
78-
- Enter the Virtual Host **localhost**
79-
- Enter the Virtual Port **3000**, choose Next
80-
- Choose the Principle Type **None**, choose Next
81-
- Choose Next
82-
- Choose Next
83-
- Choose the option to **Check Internal Host**, choose Finish
58+
1. Open [Cloud Connector](https://localhost:8443/).
59+
2. Choose the relevant subaccount or add a new one.
60+
3. Choose **Cloud To On-Premise**.
61+
4. Under the **ACCESS CONTROL** tab, choose the **+** button to add a system.
62+
5. Set the following configuration options:
8463

85-
At this point the **Check Result** column should display that the sample is **Reachable**. Next set the URL path policy of the sample.
64+
| Parameter | Value |
65+
|-----------|-------|
66+
| Backend Type | **Non-SAP System** |
67+
| Protocol | **HTTP** |
68+
| Internal Host | **localhost** |
69+
| Internal Port | **3000** |
70+
| Virtual Host | **localhost** |
71+
| Virtual Port | **3000** |
72+
| Principle Type | **None** |
73+
74+
6. Choose the option to **Check Internal Host** and choose **Finish**.
8675

87-
- Under **Resources Of localmock:3000** choose the **plus** button to add a resource
88-
- Enter the URL Path **/**
89-
- Choose the Access Policy **Path And All Sub-Paths**
90-
- Choose **Save**
76+
**Result**
77+
The **Check Result** column should display that the sample is **Reachable**.
9178

92-
#### Deploy the Kyma Function
79+
7. Set the URL path policy of the sample.
9380

94-
The provided sample function calls the on-premise sample application by proxing the call via the **connectivity-proxy**. Within the function code you will find this in the **proxy** object definition of the axios get call. The **cc_url** defines the url to call as was defined in the virtual host/port defined in the SAP Cloud Connector.
81+
Under **Resources Of localmock:3000** choose the **+** button to add a resource.
82+
- Enter the URL Path **/**.
83+
- Choose the Access Policy **Path And All Sub-Paths**.
84+
- Choose **Save**.
9585

96-
- Deploy the sample function and apirule found in the directory **k8s**
86+
### Deploying the Kyma Function
9787

98-
```shell
99-
kubectl apply -f function.yaml -n <your namespace>
100-
kubectl apply -f apirule.yaml -n <your namespace>
101-
```
88+
The provided sample Function calls the on-premise sample application by proxying the call via the **connectivity-proxy**. Within the `function.yaml` code you can find this in the **proxy** object definition of the **axios** get call. The **cc_url** defines the URL to call as was defined in the virtual host/port specified in Cloud Connector.
10289

103-
Open the apirule in the choosen namespace by choosing the menu option **Discovery and Network -> API Rules** and choosing the **host** of the
104-
**cc-sample** API Rule. The expected response should be similar to
90+
1. Deploy the sample Function and APIRule custom resources found in the **k8s** directory:
10591

106-
```json
107-
{
108-
"OrderNo": "19",
109-
"createdBy": "Internal Inc.",
110-
"buyer": "The Buyer Co.",
111-
"currency": { "code": "EUR" },
112-
"Items": [
113-
{ "product_ID": "943735", "quantity": 6, "title": "familiar", "price": 12 }
114-
]
115-
}
116-
```
92+
```shell
93+
kubectl -n ${NS} apply -f function.yaml
94+
kubectl -n ${NS} apply -f apirule.yaml
95+
```
11796

118-
#### Using Curl to test the connection
97+
2. Open the APIRule in your namespace. In Kyma dashboard, go to **Discovery and Network -> API Rules** and choose the **host** of the **cc-sample** APIRule. The expected response should be similar to this one:
11998

120-
Using a curl pod to call the sample Nodejs application via the Connectivity Proxy can be accomplished by
99+
```json
100+
{
101+
"OrderNo": "19",
102+
"createdBy": "Internal Inc.",
103+
"buyer": "The Buyer Co.",
104+
"currency": { "code": "EUR" },
105+
"Items": [
106+
{ "product_ID": "943735", "quantity": 6, "title": "familiar", "price": 12 }
107+
]
108+
}
109+
```
121110
122-
- Create an interactive pod with curl installed
111+
### Using curl to Test the Connection
123112
124-
```shell
125-
kubectl run curl --image=radial/busyboxplus:curl -i --tty
126-
```
113+
1. Create an interactive Pod with curl installed.
127114
128-
- Call the on premise connection by running
115+
```shell
116+
kubectl run curl --image=curlimages/curl -i --tty
117+
```
129118
130-
```
131-
curl --proxy http://connectivity-proxy.kyma-system.svc.cluster.local:20003 http://localhost:3000/orders?OrderNo=123
132-
```
119+
2. Call the on-premise connection.
133120
134-
- To escape the pod
121+
```shell
122+
curl --proxy http://connectivity-proxy.kyma-system.svc.cluster.local:20003 http://localhost:3000/orders?OrderNo=123
123+
```
135124
136-
```
137-
exit
138-
```
125+
> [!NOTE]
126+
> You can access the Connectivity Proxy service using the **connectivity-proxy.kyma-system.svc.cluster.local:20003** URL.
139127
140-
- To remove the pod
128+
3. Escape the Pod.
141129
142-
```
143-
kubectl delete pod curl
144-
```
130+
```shell
131+
exit
132+
```
145133
146-
### Principal propagation
134+
4. If you want to remove the Pod, run:
147135
148-
The topic of principal propagation is covered in [this blog](https://blogs.sap.com/2022/04/07/veridisquo.-reaching-sap-lob-destinations-with-connectivity-proxy-and-principal-propagation./) post and [this sample](../principal-prop-on-prem).
136+
```shell
137+
kubectl delete pod curl
138+
```
139+
140+
## Related Information
141+
142+
For more information on principal propagation, see the [VeridisQuo. Reaching SAP LOB destinations with connectivity proxy and principal propagation](https://blogs.sap.com/2022/04/07/veridisquo.-reaching-sap-lob-destinations-with-connectivity-proxy-and-principal-propagation./) blog post and [this sample](../principal-prop-on-prem).

0 commit comments

Comments
 (0)