The sample demostrates the use of the SAP Cloud Connector from within SAP BTP, Kyma runtime. This includes...
- The provisioning of the Connectivity Proxy within the Kyma runtime (SAP Help Portal link).
- A sample Nodejs application is ran locally and configured in the SAP Cloud Connector to be exposed to the connected SAP BTP account.
- A Serverless function is deployed within the Kyma runtime, which is configured to call the sample Nodejs application via the Connectivity Proxy.
- Using a curl pod to call the sample Nodejs application via the Connectivity Proxy.
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
- Within your global account…
- Choose Entitlements -> Entity Assignments
- Search for Connectivity Service
- Choose connectivity_proxy for the plan
- Choose Add 1 Service Plan
- Choose Save
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
- Within your desired namespace enable Istio if it is not already enabled.
kubectl label namespaces <your namespace> istio-injection=enabled
- Create the Connectivity Proxy Service Instance
kubectl apply -f ./k8s/connectivity-proxy-instance.yaml -n <your namespace>
The Kyma Control Plane should now provision the Connectivity Proxy. This will generate the pod connectivity-proxy-0 which can be found by running.
kubectl get pods -n kyma-system
To validate the setup, start the sample application included in the repo and configure it within the SAP Cloud Connector.
After cloning the repo run the following commands in the directory localmock
- Run the command
npm install
- Start the application
npm start
Download and install the SAP Cloud Connector and establish a connection to the localmock app. Please refer to the help documentation for the installation steps. Make sure to also add your user to the appropiate
- Open the Cloud Connector
- Choose the appropiate Subaccount or add an additional one by...
- Choose Add Subaccount
- Choose your Region
- Provide your Subaccount ID
- Provide your Subaccount User and Password
- Choose Save
- Verify that the subaccount is connected. Under the Actions column use the Connect this sub account option
- Choose Cloud To On-Premise
- Under the tab ACCESS CONTROL choose the plus button to add a system
- Choose the Back-end Type Non-SAP System, choose Next
- Choose the Protocol HTTP, choose Next
- Enter the Internal Host localhost
- Enter the Internal Port 3000, choose Next
- Enter the Virtual Host localhost
- Enter the Virtual Port 3000, choose Next
- Choose the Principle Type None, choose Next
- Choose Next
- Choose Next
- Choose the option to Check Internal Host, choose Finish
At this point the Check Result column should display that the sample is Reachable. Next set the URL path policy of the sample.
- Under Resources Of localmock:3000 choose the plus button to add a resource
- Enter the URL Path /
- Choose the Access Policy Path And All Sub-Paths
- Choose Save
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.
- Deploy the sample function and apirule found in the directory k8s
kubectl apply -f function.yaml -n <your namespace>
kubectl apply -f apirule.yaml -n <your namespace>
Open the apirule in the choosen namespace by choosing the menu option Discovery and Network -> API Rules and choosing the host of the cc-sample API Rule. The expected response should be similar to
{
"OrderNo": "19",
"createdBy": "Internal Inc.",
"buyer": "The Buyer Co.",
"currency": { "code": "EUR" },
"Items": [
{ "product_ID": "943735", "quantity": 6, "title": "familiar", "price": 12 }
]
}
Using a curl pod to call the sample Nodejs application via the Connectivity Proxy can be accomplished by
- Create an interactive pod with curl installed
kubectl run curl --image=radial/busyboxplus:curl -i --tty
- Call the on premise connection by running
curl --proxy http://connectivity-proxy.kyma-system.svc.cluster.local:20003 http://localhost:3000/orders?OrderNo=123
- To escape the pod
exit
- To remove the pod
kubectl delete pod curl
The topic of principal propagation is covered in this blog post and this sample.