Share this:

SAP Customer Experience recently held a two-day Hackathon event across four locations worldwide. Teams from Munich, Gliwice, Montreal and Boulder buckled up to compete in a Kyma meets CCv2 hackathon event. But before all of this got underway, we held a Cloud Labs series that was geared to prepare some of our developers that had never worked with either of Kyma or CCv2.
This Cloud Lab blog post will cover Kyma Meets CCv2: an intense 2-hour walk-through of an engineer’s journey pimping CCV2 deployment with Kyma Lambdas.
On the way we will:

  • Cover several Kyma features including: Portal, Lambdas, Eventing, Tracing, Debugging,
  • Use the CCV2 Accelerator to generate order.created events.
  • Use Docker, Kubectl to deploy to Kyma’s Kubernetes Cluster.

If you are new to Docker and Kubernetes, you might want to work through the first CloudLab beforehand. You can also find earlier Cloud Labs series here.


Developers that took part in the Kyma-CCv2 Hackathon required their own set of pages (environments) to work on. We provided each team with their own SAPCommerceCloudEnvironment. Each team was also given a unique KymaPortal (a.k.a Extension Factory Lab Preview) together with a unique Storefront. Finally, the teams were given access to Kyma Docs.

The Goal

“I want to intercept the order processing logic in my Storefront, so that I can persist the order delivery addresses, and ultimately see a graphical overview showing where all my orders are being delivered to, updated in real time. And when a new order is made, I want to see it pop up on the map.” Something like this:


Graphical Overview of what will happen:

These overviews show where the various pieces of this implementation fit together. And may help as a reference point as you go along

One perspective of the open space


Another perspective

The overall plan of attack

The big picture

  1. Deploy an Order CRUD Service
  2. Tell Kyma to listen for Events
  3. Enable EC OCC Commerce Webservices v2
  4. Write a Lambda
  5. Deploy a front end
Point your kubectl to your Kyma Cluster

Kyma deployments can be done via the KymaPortal, and also via kubectl. The KymaPortal makes it easy to point our kubectl to our Kyma cluster.

  • Your KymaPortal contains a kubectl configuration file to point your local kubectl to your Kyma cluster, which you should download:  KymaPortal> Workspace | Administration | Download config and save to <somePath>/kubeconfig.
  • Point your kubectl to your Kyma cluster: Terminal> export KUBECONFIG=<somePath>/kubeconfig
  • To confirm kubectl is now pointing to your Kyma space, run Terminal> kubectl get namespaces and ensure you can see your Kyma environment stage in the list of names
Explore the orders-cloudlab4 Service

To persist and list the Orders made in the storefront, we will deploy and use the GO REST service orders-cloudlab4. This offers a simple RESTful CRUD interface, for persisting Orders, where each Order includes the fields:
orderId e.g. 11854638GU110615ELIN54ZS
total e.g. 123.45
postalCode e.g. BN44 / 80636
town e.g. Brighton / Munich
The source code for this service is on github at 

To view the service’s api open swagger and pass in orders-cloudlab4’s URL:

Deploy orders-cloudlab4 to your Kyma Cluster

We can deploy the orders-cloudlab4 service using our KymaPortal or, as in this case, using kubectl:

  • Terminal> kubectl apply -f -n stage
  • Confirm your pod has started:
    KymaPortal> Workspace | Stage | OPERATION | Pods
    and ensure the orders-cloudlab4 status is green, and therefore running in your cluster.
  • Confirm your service has started:
    KymaPortal> Workspace | Stage | OPERATION | Services
    and ensure the orders-cloudlab4 status is green, and therefore running in your cluster
Expose your orders-cloudlab4 API so that it can be accessed from the outside world
  • KymaPortal> Workspace | Stage | OPERATION | Services | orders-cloudlab4 | + Expose API
  • Provide the Host stage
  • Leave Secure API unchecked
  • Save the Settings.
  • You will now see the URL of the exposed API under
    KymaPortal> Workspace | Stage | OPERATION | Services | orders-cloudlab4 | HOSTNAME,
    something like https://stage.<kymaEnvironmentName>
    Confirm the orders-cloudlab4 is now accessible (note: use https not http)
  • Chrome> https://stage.<kymaEnvironmentName>
    should show the api.yaml of the orders-cloudlab4
  • Chrome> https://stage.<kymaEnvironmentName>
    should show a (currently empty) list of orders (“[]”)
Confirm orders-cloudlab4 is working

Test that you can post and see orders in your orders-cloudlab4:

“orderId”: “11854638GU110615ELIN54ZQ”,
“namespace”: “kyma-components”,
“total”: 1234.56,
“postalCode”: “BN44”,
“town”: “Brighton”

  • Use that JSON to construct a curl command to post to your orders-cloudlab4, for example
    terminal>curl -H “Content-Type: application/json” -d ‘{“orderId”:”11854638GU110615ELIN54ZQ”,”namespace”: “kyma-components”,”total”: 1234.56,”postalCode”: “BN44″,”town”: “Brighton”}’ https://stage.<kymaEnvironmentName>
  • List the persisted orders and confirm you see the one just posted:
    terminal> curl https://stage.<kymaEnvironmentName>

This means that your orders-cloudlab4 service:

  • is successfully exposed and reachable from the outside world
  • is successfully persisting orders
Allow consumption of EC Events by your Kyma Environment

We want our Kyma Environment to see events sent by our EC Environment. To do this:

  • Create a binding between your Kyma environment and your remote EC Environment
    KymaPortal> Workspace | Stage | Overview | Show All Remote Environments | ec-default | + Create Binding | stage | OK
  • List the events available for you to hook into, including
    cart.abandoned, order.completed, order.pickedup, order.paymentfailed:
    KymaPortal> Workspace | Stage | SERVICE CATALOG | Catalog | EC Events v1
  • Allow your Kyma Environment to consume these events
    KymaPortal> Workspace | Stage | SERVICE CATALOG | Catalog | EC Events v1 | Add to your Environment | Create Instance
  • Confirm the service ec-all-events has status RUNNING:
    KymaPortal> Workspace | SERVICE CATALOG | Instances

Enable the Kyma service EC OCC Commerce Webservices v2 in your Kyma Portal

Review the EC OCC Commerce Webservices v2 API, in particular the GET orders API.

  • KymaPortal> Workspace | Stage | SERVICE CATALOG | Catalog | EC OCC Commerce Webservices v2 | Orders | GET/{baseSiteId}/orders/{code} 

This is the API we will be calling in our lambda. To allow that..

  • add EC OCC Commerce Webservices v2 to your Kyma environment:
    KymaPortal> Workspace | Stage | SERVICE CATALOG | Catalog | EC OCC Commerce Webservices v2 | Add to your Environment | Create Instance
  • confirm EC OCC Commerce Webservices v2 has status RUNNING :
    KymaPortal> Workspace | Stage | SERVICE CATALOG | Instances
Create and wire up a Lambda Function

Lamdbas allow us to extend EC functionality without touching the EC source code. We will write a Lambda that:

  • is written in NodeJs
  • is triggered by the order.created event,
  • reads the orderId from the the order.created event that triggered it
  • calls the EC OCC Commerce Webservices v2 to get more details about the order
  • persists this data using the orders-cloudlab4 service

To do that:

  • Create a new Lambda:
    KymaPortal> Workspace | Stage | DEVELOPMENT | Lambdas | + Add Lambda
  • Provide a name <myCoolLambdaName> and label app:<myCoolLambdaName>. This should start with a letter.
  • Click Select Function Trigger | Event Trigger | order.created
    to wire your lambda function to the order.created event.
  • Replace the code in the trigger’s textbox with this lambda.js Code

Select + Add Dependencies and add this package.json code to the Dependency TextBox


  • Associate the ec-occ-commerce-webservices-v2 web service instance with your lambda function:
    + Create Service Binding | ec-occ-commerce-webservices-v2-xxxx | Create Service Binding
  • Define the Environment Variable
    which is used in the lambda code,
  • Click + Add Variable to add this environment variable
  • Select Create to finish creating the lambda function
Watch the Log output of your orders-cloudlab4 service and your lambda
  • To see the lambda logs use:
    Terminal> kubectl -n stage logs -l app=lambda1 -c lambda1
  • To see the service logs use:
    Terminal> kubectl -n stage logs <servicepodname> orders-cloudlab4
  • You can add “-f” to the end of these to follow the log files

Invoke an Order Created Event

  • Open your storefront and simulate a purchase. Use the mock Visa Card number 4444333322221111 with any future date and any security code (more).

Verify the Lamdba was triggered

  • Confirm you see expected output in the log files.
  • Query the list of orders and confirm you see the new order appearing.
    Terminal> curl https://stage.<kymaEnvironmentName>
Show the orders in a Google Map

Now we have a list of orders, with postal codes and towns, we can write a simple NodeJS application to place those orders on a google map as they arrive.

The NodeJS source code is at
This is currently deployed on Google Cloud and expects the following URL

  •<kymaEnvironmentName> for example:
    • You should see the locations of the orders show up on the map as they are made


  • You can also deploy this to any kubernetes cluster (including local minkube) with the one liner:
    Terminal> kubectl apply -f
  • If using minikube, you can then access it with:
  • Terminal> minikube ip
    To find your minikube’s ip
  • Then replace the cluster name in the URL and open
    Chrome> http://<minikube’s ip>:30002/?kyma_env=stage&kyma_cluster=sa-hackathon-XX

Examine the Traces

  • Each Kyma has inbuilt tracing
    KymaPortal> Workspace | Stage | Administration | DIAGNOSTICS | Tracing

Lambda Dev-Test Loop

Few of us write a Lambda correctly the first time, so you will probably find yourself in a write-test-write loop. Keep in mind that when you re-save the lambda, the lambda pod will change. So a useful loop to get into is:

  1. Adjust and save the lambda
  2. Find the new lambda pod name Terminal> kubectl -n stage get pods
  3. Trigger the lambda (by for example firing the order.created event)
  4. Examine the logs on the new lambda pod Terminal> kubectl -n stage logs <lambdapodname> <myCoolLambdaName>

Debugging Services in the Kubernetes Cluster

If you dare, you can also debug a service in place using Telepresence (See our next Cloud lab)

Sharing Environments?

If you are sharing a Kyma CCV2 portal with another team, keep in mind their events may trigger your lambdas :O
Not yet know Docker, Kubectl, Google Cloud Platform?
Work through Cloud Lab 1 Taking a simple Go App through Docker and Kubernetes to Google Cloud

Share this: