Connecting Cloud Foundry and MindSphere

November 12, 2019

As part of getting to know Siemens MindSphere we are looking at their offering for developing applications. On MindSphere it is possible to publish applications on a Platform-as-a-Service powered by Cloud Foundry.

Setup Cloud Foundry

To get started with Cloud Foundry Applications on MindSphere you have to be the original administrator of MindSphere or he has to provide the required permission on Cloud Foundry to you. This requires you to be added to the MindSphere tenant. To get the required permissions you have to first login once with the following command:

cf login -a https://api.cf.{region}.{mindsphere-domain} --sso

After that the OrgManager can assign the required roles (SpaceDeveloper) with the command

cf set-org-role {username} {orgname} {role}
cf set-space-role {username} {orgname} {spacename} {role}

Incase there is no space you need to create one with the command

cf create-space {spacename}

If the setup is done you are able to login and select the organization and space

cf target -o {orgname} -s {spacename}

Simple Static Page on Cloud Foundry

  1. Create a folder with three files inside called index.html, manifest.yml and Staticfile
  2. Add to the manifest.yml the following content
---
applications:
  - name: <your_application_name>
    instances: 1
    random-route: true
    path: .
    memory: 64M
  1. Fill the index.html with your static content like the following
<head></head>
<body>
  <h1>Simple Static Page on MindSphere with Cloud Foundry</h1>
</body>
  1. Then inside the folder run the command cf push to start the deployment of the static page using the static buildpack. In the output of the command can see your Cloud Foundry url which would we similar to the following <your_application_name>-<random>-<random>.apps.<region>.<mindsphere-domain>.

  2. Now login to MindSphere and enter the Developer Cockpit.

  3. There create a new application, it should look similar to the one below:Create Application in MindSphere

  4. Enter as the Cloud Foundry Url the one from above and press the + sign. As the path use /** and press add. Then enter a name and a version in the remaining fields and save.

  5. The last step is to register the just created application. Since we are not using any MindSphere api we do not need to assign any roles.

  6. In the created application there should be now a application URL visible to access the static page. It should be similar to the following scheme https://<tenant_name>-<your_application_name>-<tenant_name>.<region>.<mindsphere_domain>/

  7. Navigating to the Url the page should look similar to Static Page on MindSpherePreview

MindSphere Developer Cockpit

The Developer Cockpit is used to manage your applications on MindSphere. To access the Developer Cockpit a subscription to the MindAccess Developer Plan is needed as well as the Developer or DeveloperAdmin Role on MindSphere. Inside the Developer Cockpit there a three interfaces. The Dashboard which shows all your applications and their current state of development. Applications in MindSphere follow a lifecycle which is split up into the different plans MindSphere has to offer:

  1. Developer Plan
    1. Develop the application locally
    2. Implement the application in the Developer Cockpit
    3. Test the application in the development system
    4. Assign the application to operators
    5. Send application to Application Repository
  2. Operator Plan
    1. Download the application from Application Repository
    2. Deploy the application to productive system
    3. Set a route to the tenant
    4. Publish application to MindSphere Store
    5. Provision the application in a customer Launchpad
  3. IoT Value Plan
    1. Make a subscription from the MindSphere Store
    2. Access application via Launchpad

Under the Promoted Apps tab are your applications listed which are ready for operation. In the Authorization Management tab you can assign MindSphere Api Roles to your application specific roles and manage the scopes.

Accessing MindSphere Data using Roles and Scopes

To access data from MindSphere an application needs to have the correct MindSphere Api Role. The required MindSphere Api Role depends on the data the applications wants to use. There are Roles for read and write access. The MindSphere Concept Page has a List of MindSphere Roles. The MindSphere Api Roles can be assigned to application roles. An application can have a maximum of 5 roles and requires one role. If a application is created in the developer cockpit two standart roles, namely admin and user are created.

Summary

In this post you learned how to publish an application via Cloud Foundry on MindSphere and got a short introduction to the Developer Cockpit.

About the author: Joachim Spalink

Software-Engineering Student working part-time at mimacom.

Comments
Join us