Working with Local Instances of SAP Commerce Cloud and Project "Kyma"
Please note: these instructions are only applicable to "Kyma" 1.3.0 and later - they will not work with earlier versions. You will also require SAP Commerce Cloud version 1905 or later.
SAP Cloud Platform Extension Factory is the cloud-native application extensibility framework for the SAP C/4HANA Suite, powered by open-source project "Kyma". It allows you to extend and customize your SAP C/4HANA solutions in a quick and modern way, using serverless computing and microservice architectures. One of the key components of the SAP Cloud Platform Extension Factory runtime is the Application Connector which provides a mechanism to simplify the connection between external systems and "Kyma" in a secure manner.
Once the initial connection has been established, the registration of the external Events and APIs of the external system takes place. The Events and APIs are then available within the "Kyma" Service Catalog. The SAP Cloud Platform Extension Factory Integration Module for SAP Commerce Cloud provides features that registers Events and APIs from SAP Commerce Cloud to SAP Cloud Platform Extension Factory. The one-click integration allows you to connect the SAP Commerce Cloud platform to the Application Connector.
Sometimes you may not have access to cloud-based instances of either SAP Commerce Cloud or "Kyma" - for example, you may want to prototype something quickly on your local machine. This articles outlines the steps you need to take in order to successfully connect a local SAP Commerce Cloud instance with a local "Kyma" runtime.
Table of Contents
- The Challenges
- Connecting the Two Systems Together
Installing and running a local instance of "Kyma" is a great way to learn about its key features and to begin to explore the possibilities of using it for side-by-side extension of the SAP C/4HANA Suite. If you want to connect it to a locally-running instance of SAP Commerce Cloud, there are a couple of extra steps you'll need to take before you can start using the events and APIs from SAP Commerce Cloud in your "Kyma" lambdas and microservices.
This article assumes that you have successfully installed a local instance of SAP Commerce Cloud 1905 that includes the SAP Cloud Platform Extension Factory Integration Module, as detailed in this SAP Help document.
It also assumes that you have successfully installed "Kyma" (at least version 1.3.0) on your local machine using Minikube as per the "Kyma" installation instructions. In particular, make sure you follow the post installation step regarding adding the "Kyma" self-signed certificate to your OS trusted certificates.
There are two principle challenges you will face when trying to connect a local SAP Commerce Cloud instance with a local "Kyma" instance:
- How your "Kyma" instance running inside Minikube can resolve the DNS of your local SAP Commerce Cloud instance
- How "Kyma" and SAP Commerce Cloud will trust each other given that both by default use a self-signed TLS certificate
For the first issue, we need to determine an IP address that "Kyma" can use to connect to your local SAP Commerce Cloud, and use that IP address in the required property in your SAP Commerce Cloud local.properties file.
For the second issue, we need to import the "Kyma" self-signed certificate into the trusted certificate storage of our programming environment (SAP Commerce Cloud / Java) and then override the default configuration settings of some of the "Kyma" components to allow for what would otherwise be treated as an "insecure" connection.
Connecting the Two Systems Together
1. Determine a DNS Value for SAP Commerce Cloud that Works Within Minikube
You first need to determine the IP address that your Minikube cluster will use to contact your local SAP Commerce Cloud instance - "Kyma" needs this in order to retrieve and register the SAP Commerce Cloud events and APIs within the "Kyma" Service Catalog:
You are looking for the default via IP address - this is typically 192.168.64.1:
Add this IP address to your /path/to/commerce/hybris/config/local.properties file in the format shown in the following example:
You can read more about this DNS resolution mechanism at nip.io.
Also make sure the apiregistryservices.events.exporting property is set to true, otherwise your local SAP Commerce Cloud instance won't export any events even if they are triggered:
2. Import "Kyma" Certificate and Override Defaults to Allow Insecure Connections
a. Import the "Kyma" server certificate into the local trust store
As per the "Kyma" documentation, to access the Application Connector on a local deployment of "Kyma", you must add the "Kyma" server certificate to the trusted certificate storage of your programming environment. For example, to access the Application Connector from a Java environment, run this command to add the "Kyma" server certificate to the default Java trust store:
If you are only interested in working with "Kyma" from a local SAP Commerce Cloud instance, a better option is to add the "Kyma" server certificate to the SAP Commerce Cloud-specific developer trust store that is configured in /path/to/hybris/bin/platform/resources/advanced.properties:
To add the "Kyma" server certificate to this trust store, run this command:
You also then need to add the following properties to your /path/to/commerce/hybris/config/local.properties:
b. Override "Kyma" defaults to disable TLS verification
As per the "Kyma" documentation:
To provide maximum security, the Application Connector uses TLS protocol with Client Authentication enabled. As a result, whoever wants to connect to the Application Connector must present a valid client certificate, which is dedicated to a specific Application (App). In this way, the traffic is fully encrypted and the client has a valid identity.
By default, a local version of SAP Commerce Cloud will use a self-signed certificate, and therefore be treated as untrusted by the Application Connector in "Kyma". To get around this issue, we can disable the SSL certificate verification in the communication between "Kyma" and your local SAP Commerce Cloud by patching two of the "Kyma" components - the Application Registry and the Application Gateway.
Execute the following commands using the Kubernetes CLI tool kubectl.
First patch the Application Registry:
Wait until the pod restarts:
Create a new Application in "Kyma" to represent your local Commerce Cloud instance as shown below. Wait until its status is SERVING.
You now need to patch the Application Gateway that is created when you create this Application in "Kyma". Replace <APPLICATION_NAME> with whatever you called your Application when you created it in the previous step:
Wait until the pod restarts:
Now you can follow the standard SAP Commerce Cloud - "Kyma" pairing process, as documented here.
You should see the following entries in your SAP Commerce Cloud console as it requests and retrieves the certificate from "Kyma":
Your SAP Commerce Cloud console should then show the server registering its events and APIs with "Kyma", and "Kyma" reply with response code 200:
Once the registration process has completed, you should see all the registered SAP Commerce Cloud events and APIs in your "Kyma" Application:
The following are some sample error messages you might see while trying to connect your local SAP Commerce Cloud instance with a local "Kyma" instance:
This article has introduced you to the steps you need to take to connect a local instance of SAP Commerce Cloud with a local "Kyma" runtime. You can now explore the possibilities of side-by-side extensibility for SAP Commerce Cloud by introducing new functionality and innovation without having to do in-app customizations.
For more information about using SAP Cloud Platform Extension Factory with the SAP C/4HANA Suite, please see the following references:
- Articles about SAP Cloud Platform Extension Factory on blogs.sap.com
- SAP C/4HANA Foundation Overview playlist on enable.cx.sap.com
- SAP Cloud Platform Extension Factory enablement videos on enable.cx.sap.com
- Project "Kyma" website