Skip to content

Kubernetes

Edge Xpert on Kubernetes allows you to manage the containers that run the services.

Default Configuration

The default configuration demonstrates the basic functionality of the Edge Xpert platform, as deployed in Kubernetes.

This default configuration runs the following containers:

  • redis
  • mqtt-broker
  • core-metadata
  • core-data
  • core-command
  • device-virtual
  • xpert-manager

Overall Design

The Edge Xpert license is used by the containers by way of a secret. This means that the Edge Xpert license is encoded in base64 before being transmitted to, and used by, containers.

To simplify the deployment of containers, the ConfigMap, Service and Deployment configuration for a container are specified in the container\'s deployment file. This creates a central point where all details related to the container can be found.

The deployment file for device-virtual contains ConfigMap to configure the container\'s internal configuration.toml file. This is retained to show how straightforward configuration is, and to help in troubleshooting.

Persistent volumes and persistent volume claims have individual files in their own folder. This makes deployment easier and reduces errors where a claim is created before a volume.

All persistent volumes are regarded as temporary on the host. When the host restarts, the volumes are deleted. For this reason, persistent volumes are mounted inside a /tmp path on the host to highlight this limitation.

Set Up a Secret

If you are running this example, your license key must be set up as a secret in Kubernetes. The Edge Xpert license used on the local machine to create the secret must use the same filename as that specified in the YAML deployment files.

To set up a secret called license, complete the following steps:

  1. Open a terminal

  2. Enter the following command, replacing </path/to/your/license/file> with the path to the Edge Xpert license file on your machine:

    kubectl create secret generic license --from-file=</path/to/your/license/file>
    

  3. Update the YAML file to use the same filename as that used when creating the secret

    For example, if your license is called license.lic, the YAML file must include the following:

    - mountPath: /edgexpert/licenses/license.lic
      name: license
      subPath: license.lic
    

Apply Persistent Volumes

To apply persistent volumes, complete the following steps:

  1. Open a terminal
  2. Navigate to the root directory of the sample deployment files: /usr/share/edgexpert/examples/deployment/kubernetes
  3. Enter the following command:

    kubectl apply -f pv
    

  4. Enter the following command:

    kubectl apply -f pvc
    

Note

In the example commands above, pv and pvc are folders. If you prefer, you can apply each file individually.

Apply Deployment Files

To apply a deployment file, complete the following steps:

  1. Open a terminal
  2. Navigate to the root directory of the sample deployment files: /usr/share/edgexpert/examples/deployment/kubernetes
  3. Enter the following command, replacing <deployments/core-data-deployment.yaml> with the name of the deployment folder and file that you want to apply:
    kubectl create -f <deployments/core-data-deployment.yaml>
    

IOTech recommends that you apply the deployment files in the following order:

  1. redis
  2. mqtt-broker
  3. core-metadata
  4. core-data
  5. core-command
  6. device-virtual
  7. xpert-manager

Alternatively, you can deploy all files by specifying only the folder using the following command, replacing deployments with the name of the deployment folder that you want to apply:

kubectl create -f deployments

Note

Deploying all files in this way can produce non-deterministic results. IOTech recommends that this method is scripted with sleep signals added between deployments.

Edge Xpert Manager with Kubernetes

To access Edge Xpert Manager, you must expose the xpert-manager service from the Kubernetes cluster to the localhost address.

Note

This example is based on a local Kubernetes cluster running with minikube. The command minikube service <service name> --url will be used in the following steps to get a URL to connect to a service.

To access Edge Xpert Manager, complete the following steps:

  1. Open a terminal and enter the following command:

    minikube service xpert-manager --url
    
    This command creates a route to the xpert-manager service deployed with type NodePort and returns a URL similar to the following:
    http://127.0.0.1:65031
    
    Note that the port number is dynamically assigned by minikube.

  2. Open a web browser and enter the URL obtained in step 1 in the Address Bar of your web browser. The Edge Xpert Manager Login page displays.

  3. Enter admin in the Username text box

  4. Enter admin in the Password text box

  5. Select the Login button

After logging in, the Devices pane displays. On the Device pane you can do the following:

  • View the metadata for the virtual devices by selecting the View Device (i) icon from the Action column for the device
  • Read device data by selecting the Control Device (speedometer) icon from the Action column for the device, then selecting a command from the Command List and hitting the Execute button.
  • Write device data by selecting the Control Device (speedometer) icon from the Action column for the device, then selecting a command from the Command List, switching to Set Command tab, entering a new value and hitting the Execute button.

To view the readings from the device, select READINGS from the main menu.