Skip to Content

Consume SAP BTP Services from Any Hyperscaler

Deploy an SAP Fiori application in any hyperscaler, such as Google Cloud Platform (GCP), Amazon Web Services (AWS), Alibaba Cloud or Azure, and use services from SAP BTP.
You will learn
  • How to consume SAP BTP services running from other environments
  • How to use SAP BTP APIs, Service Manager and Service Operator to consume services from other environments
LalithManokarLalithManokarJune 6, 2022
Created by
LalithManokar
November 25, 2021
Contributors
LalithManokar

Prerequisites

Deploy an SAP Fiori Application in any a hyperscaler, such as Google Cloud Platform (GCP), Amazon Web Services (AWS), Alibaba Cloud or Azure, and still take advantage of the services provided by SAP Business Technology Platform (SAP BTP).

In this tutorial, you use the fioriapp sample application to learn some best practices of setting up your Kubernetes cluster to communicate with SAP BTP so you can learn how to consume SAP BTP services from any hyperscaler.

  • Step 1

    To configure the access to your Kubernetes cluster, you have to set the KUBECONFIG environment variable to point to the location where the KUBECONFIG file you have downloaded from your Kubernetes cluster. To do that, open a command line prompt on your computer and type in the following command:

    Replace <KUBECONFIG_FILE_PATH> with the file path of the KUBECONFIG file you have downloaded, including the file name and extension.

    Open a command line prompt on your computer. In the command line screen, type in the following:

    Test the configuration by running this command:

    Shell/Bash/DOS
    Copy
    kubectl config get-contexts
    

    This should return a context from the kubeconfig file.

    CURRENTNAMECLUSTERAUTHINFONAMESPACE
    * ############-token
  • Step 2

    Cert-manager is used to set up the certificates needed for internal communication between the Kubernetes API server and the deployment of the SAP BTP service operator in your cluster. For more information about cert-manager, see cert-manager documentation.

    Open a command line prompt on your computer and type in the following command:

    Shell/Bash/DOS
    Copy
    kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.3/cert-manager.yaml
    
  • Step 3

    Consume services from a global account and a subaccount in SAP BTP.

    As subaccounts are bound to specific regions, choose or create a subaccount located close to your Kubernetes cluster to prevent latency drawbacks.

    SAP BTP service operator allows you to provision and manage service instances and service bindings of SAP BTP services so that your Kubernetes-native applications can access and use SAP BTP services from the cluster.

    1. Go to https://account.hanatrial.ondemand.com or https://account.hana.ondemand.com and log in to the SAP BTP cockpit.

    2. Choose your global account and then in the Account Explorer page, choose the tile of your subaccount.

      subaccount
    3. Choose Services > Service Marketplace, and in the Service Marketplace page, choose the Service Manager service tile.

    4. From the Service Manager page, choose Create and follow the steps in the wizard to create a service instance.

      servicemarketplace
    5. On the Basic Info step:

      • In the Service dropdown menu, select Service Manager

      • In the Plan dropdown menu, select service-operator-access

        If you can’t see this service plan, you need to entitle your subaccount to use the Service Manager service. For more information about how to entitle a service to a subaccount, see: Configure Entitlements and Quotas for Subaccounts.

      • In the Runtime Environment dropdown menu, select Other

      • In the Instance Name field, enter btpserviceoperator

    6. Choose Create.

      instancecreationfinal
    7. Choose View Instance

      clickviewinstance
    8. To create a binding for the btpserviceoperator service instance, choose Create.

      bindingcreation
    9. In the Binding Name field enter operatorbinding and choose Create.

      clickonbinding
    10. Choose View Credentials.

      bindingcredentials
    11. Copy the credential information by choosing Download or Copy JSON.

      bindinginfo

      This is an example of the binding object created with the default credentials type:

      JSON
      Copy
       {
          "clientid": "xxxxxxx",
          "clientsecret": "xxxxxxx",
          "url": "https://mysubaccount.authentication.xxx.hana.ondemand.com",
          "xsappname": "<name>",
          "sm_url": "<service_manager_URL>"
       }
      
    12. Deploy the SAP BTP service operator in the cluster using the obtained access credentials.

    Replace the release version of SAP BTP service operator, clientid, clientsecret, sm_url, url with the credentials you have copied from the service binding.

    For the list of the available SAP BTP service operator releases, see Available Releases.
    To know more about SAP BTP service operator, see Consuming SAP BTP Services in Kubernetes with SAP BTP Service Operator.

    Test the configuration by running this command

    Shell/Bash
    Copy
    kubectl get pods -n sap-btp-operator
    

    This should return the status of sap-btp-operator configuration.

    NAMEREADYSTATUSRESTARTAGE
    sap-btp-operator-##2/2Running####
  • Step 4
  • Step 5

    In the fioriapp sample application, the Destination and the SAP Authorization & Trust Management services will be consumed using the SAP BTP service operator. To use these SAP BTP services you have to create the respective service instances and service bindings. Use the createservice.yaml which will create the destination service instance with plan lite and the xsuaa service instance with plan application.

    1. The hyperscaler applications can be found in the btp-hyperscaler-extension repository. Within the repo you can find each of their Deployment files within the respective folder.

    2. Download the code by choosing the green Code button and then choosing one of the options to download the code locally.

      You can instead run the following command within your CLI at your desired folder location:

      Shell/Bash
      Copy
      git clone https://github.com/SAP-samples/btp-hyperscaler-extension
      
    3. Create your own sapfiori namespace in your Kubernetes cluster.
      Shell/Bash
      Copy
      kubectl create namespace sapfiori
      
    4. create the destination service instance with plan lite and the xsuaa service instance with plan
      application by running the below command.

      Shell/Bash
      Copy
      kubectl apply -n sapfiori -f https://raw.githubusercontent.com/SAP-samples/btp-hyperscaler-extension/master/k8s/createservice.yaml
      

      The create service file is represented as declarative YAML object which describes what you want to run inside your namespace. You can find the file at /btp-hyperscaler-extension/master/k8s/createservice.yaml.

    5. Check that the status of the service instance in your cluster by using the following command:

      Shell/Bash
      Copy
      kubectl get serviceinstances -n sapfiori
      

      This should return the status of created service instances.

      NAMEOFFERINGPLANSTATUSREADYAGE
      destination-instance-fioridestinationliteCreatedTrue##
      xsuaa-instance-fiorixsuaaapplicationCreatedTrue##

      To know more about consuming services using SAP BTP service operator Working with SAP BTP Service Operator.

  • Step 6

    To build and deploy the fioriapp sample application in your cluster, you have to create a pod, which encapsulates the container and ensures that a specified quorum of running instances is fulfilled. To do that, use the deployment.yaml.

    1. Build the docker image of the fioriapp.

      • cd btp-hyperscaler-extension/basicfioriapp

      • docker build . -t <docker-username>/fioriapp -f Dockerfile

      Replace <docker-username> with your username

    2. Push the docker image of the fioriapp to your Container Image Library.

      • docker push <docker-username>/fioriapp

      Replace <docker-username> with your username

    3. Update the docker image in the ./btp-hyperscaler-extension/k8s/deployment.yaml file. Line no 21

      • Replace <docker-username> with your username

    4. Execute the below command to deploy the application into hyperscaler.

      Shell/Bash
      Copy
      kubectl apply -n sapfiori -f https://raw.githubusercontent.com/SAP-samples/btp-hyperscaler-extension/master/k8s/deployment.yaml
      

      The deployment file is represented as declarative YAML object which describes what you want to run inside your namespace. You can find the file at /btp-hyperscaler-extension/master/k8s/deployment.yaml.

    5. Execute the following command to check the deployed application pod status

      Shell/Bash
      Copy
      kubectl get pods -n sapfiori
      

      This should return the status of deployed application.

      NAMEREADYSTATUSRESTARTAGE
      fioriapp-##-##1/1Running####
  • Step 7

    Congratulations! You have successfully completed the tutorial.

    What are all the services have been consumed using SAP BTP service operator?

Back to top