In this CodeLab, you will prepare SAP Cloud Platform to deploy your application. You will also set up the Continuous Delivery Toolkit of the SAP Cloud SDK in Google Kubernetes Engine. Then, you will test, check code qualities, and deploy your application in SAP Cloud Platform using the prepared toolkit.

What you'll learn

Before you can deploy the application in SAP Cloud Platform, you need to prepare the SAP Cloud Platform account:

Create service instances for S/4HANA connectivity

Firstly, create an instance of the destination service to connect to SAP S/4HANA (or mock) system. For that, in the cloud platform cockpit on the level of your development space choose Services -> Service Marketplace in the left menu and choose the destination service from the catalog. Instantiate the service with all the default parameters. Give the name my-destination to your instance.

Secondly, create an instance of the Authorization and Trust Management service. In the Service Marketplace, choose the Authorization and Trust Management service and instantiate it with the default parameters. Give the name my-xsuaa to your service instance.

Configure your SAP S/4HANA endpoint

Next, you will create a destination endpoint to connect to an SAP S/4HANA system. You can find the configuration of the destination endpoints on the level of your subaccount:

Choosing Connectivity -> Destinations in the left menu. Then, you can create a new destination endpoint by choosing New Destination.

For the S/4HANA connectivity, create the destination with the following parameters.

Name: ErpQueryEndpoint

Type: HTTP

URL: https://odata-mock-server-daring-emu.cfapps.eu10.hana.ondemand.com

Proxy type: Internet

Authentication: NoAuthentication

Now, you are ready to deploy our application in SAP Cloud Platform, Cloud Foundry. You will do it using the Continuous Delivery Toolkit that is also testing the application and ensures the code quality in the next steps.

Use the credentials provided by one of the instructors to log into the Google Cloud Platform console.

Alternatively, you can use your own trial Google Cloud Platform account.

Once there, use the menu on the top left corner to navigate a new Kubernetes cluster from the Kubernetes Engine menu.

Click Create cluster.

Change the Zone to one of the available zones in Europe (e.g. europe-west1-b) Change Machine type to use 2 vCPUs.

Click on Create. This will create a cluster named cluster-1 with 3 nodes. The creation of the cluster might take a few minutes. Once it's created, you should see it in your cluster overview.

Click Connect next to the cluster name. This opens a dialogue. Click Run in Cloud Shell. This opens a browser-based shell and you can open the connection from here.

Once the Cloud Shell is open, press Enter.

SAP Cloud SDK CI/CD Toolkit makes use of a pre-configured Jenkins to run the Continuous Delivery Pipeline. Next, you will start the Jenkins server with auto-scaling capabilities on our Kubernetes cluster. Thanks to the helm package manager tool, setting up the Jenkins on your Kubernetes cluster is super simple.

In order to make the installation even more convenient, the installation is wrapped in a small setup_jenkins shell script.

To run it, execute the below commands in the cloud shell that is open. The setup_jenkins script will execute a helm command with custom values. This will create the service account that is required to run the Jenkins and agents along with the services to cater internal and external traffic to Jenkins.

wget -O setup_jenkins https://raw.githubusercontent.com/SAP/cloud-s4-sdk-book/google-next/cx-server/setup_jenkins
chmod 700 setup_jenkins
./setup_jenkins

Copy the command in the instructions to fetch the password in case you need it later.

Keep a note of the password.

The Jenkins that you have deployed is preconfigured with the libraries and the plugins that are required to execute the SAP Cloud SDK Pipeline. In order to examine the deployment status, please navigate to Workloads menu and please wait until the deployment status turns to green. This will take a few minutes.

Unlike the standalone Jenkins instance, the Jenkins instance which is deployed on the Kubernetes cluster gives us the flexibility to scale it based on the load. In addition, Kubernetes will ensure the availability of the service by regular health check of the containers.

Once the setup is completed, it is time to build our first application with SAP Cloud SDK Pipeline. Navigate to Services menu under Kubernetes Engine and click on the endpoint of the LoadBalancer service.

Login to Jenkins

Now you should see the Jenkins login page, which looks like the screenshot below:

In the login screen please key-in admin as the user. Use the password you copied from the log:

Once the login is successful you will see a Jenkins dashboard.

Set up credentials for tests and deployment

You need to create two different credentials: cf-deploy to be used for the deployment in SAP Cloud Platform and S4HANA for the execution of integration tests.

In the initial Jenkins screen, choose Credentials.

Choose global to create global credentials.

Choose Add credentials.

Firstly, create credentials for the SAP Cloud Platform deployment.

Secondly, create SAP S/4HANA credentials that will be used for running integration tests. As the mock server does not require authorization, you can put any values in the username and password in this case.

Your credentials page should now look as follows:

You can now go back to WebIDE and find the file pipeline_config.yml that configures different pipeline stages. As you can see, S4HANA credentials are referenced in stage integrationTests and cf-deploy credentials are used during the productionDeployment stage.

In case you are using the productive SAP Cloud Platform account, provided by instructors, you do not need to make any changes to this file. Otherwise, make sure to put the parameters of your SAP Cloud Platform account, where the application should be deployed in the stage productionDeployment, specifying the correct org, space, and apiEndpoint.

These screenshots give you a hint how to find this information required for the deployment:

If you are using the productive accounts provided by the instructors, open the file mta.yaml and change the name of the application there according to the number provided by your instructors. This will avoid collisions of names with other participants during the deployment.

If you have changed the file, do not forget to push this change to GitHub before continuing to the next step.

Update Jenkins

Before you can use Jenkins, the image needs some updates. Go into manage Jenkins and click Correct

Select all and click Download and install after restart

In the next screen, click Restart Jenkins when installation is complete

Log in again. Go back into Manage Jenkins and click Manage plugins.

Look for Pipeline Utility Steps, select it and choose Install without restart

Create Jenkins job

Once the required credentials are created, you can create a new Jenkins job to start the build of the project that you have in your GitHub repository.

Click on create new jobs. In the following page enter a name of your choice for the item name field. Choose a Multibranch Pipeline. Click on OK.

In the following page, choose the source location. For this demo, you have created an example application that you can make use of. Please select Git from the dropdown in Add source option.

Provide the URL of your cloned repository as the location for the Project Repository. Note, that you can look up the URL of your repository in GitHub, as shown in the screenshot:

Save the configuration.

Congratulations! You have successfully setup your CI/CD infrastructure on Google Kubernetes Engine and started building the application from your repository using SAP Cloud SDK Pipeline.

You can check the status of the pipeline execution in the Jenkins dashboard. Navigate to Jenkins dashboard and click on the Open Blue Ocean in the left hand side of the menu.

To switch to classic view of the Jenkins dashboard from Blue ocean view, you can click on the Go to Classic button on the right hand side.

If the build is successful, you will see the green pipeline:

So, if the stage Production Deployment is green, you can now go to your account in SAP Cloud Platform and see the deployed application.

Go to the URL under "Application Routes" and add "/address-manager" to the URL. You should now be able to see the business partner coming from S/4HANA system.