1.0.0 • Published 7 years ago

iotpcs v1.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

Build Issues Gitter

Azure IoT PCS CLI Overview

Command Line Interface for deploying an IoT pre-configured solution into a user's subscription.

This CLI has the ability to deploy two configurations of PCS solutions:

  1. Basic - deploys all resources to a single VM.
  2. Enterprise - deploys resources using Azure Container Service and Kubernetes across multiple VMs.

Dependencies

The command line interface depends on:

  • nodejs used as the runtime for the CLI. Please install node before attempting a deployment.

Basic

The purpose of the basic deployment is to demo the capabilities of the system and requires minimal setup, deploying all resources to a single VM.

Basic deployment provisions following resources:

  1. Azure IoT Hub
  2. Azure Cosmos DB
  3. Azure Storage
  4. Single instance of Azure Virtual Machine with Docker Extension

At the end of deployment, Remote Monitoring WebApp and all the microservices are ready for demo pursposes.

Enterprise

The Enterprise deployment offers a production ready deployment that can be scaled up or down as needed. It uses Azure Container Service and Kubernetes for orchestration. It also requires some manual steps in running commands through different CLIs like az and kubectl in addition to pcs.

Enterprise deployment provisions following resources:

  1. Azure IoT Hub
  2. Azure Cosmos DB
  3. Azure Container Service which also provisions following:
    1. Azure Storage
    2. Three instances of Azure Virtual Machine with Docker

How to use the CLI

CLI setup

  1. Clone the project
  2. From a command prompt run:
    • npm install
    • npm start
    • npm link

Basic Deployment

Deploy Azure Resources

  1. If you haven't logged in with your Azure account from the command prompt run pcs login.
  2. Run either pcs or pcs -t remotemonitoring -s basic. These are equivalent in that they will both deploy a basic deployment (i.e. a deployment to a single VM).
  3. Follow the on-screen prompts
  4. The results of the deployment will be saved to a file named output.json

Verify the Web UI and Microservices are deployed

Click on the link that is shown in the output window, it will take you to the Remote Monitoring WebApp

Enterprise Deployment

Dependendencies

Important \ \ Make sure the path of az and kubectl are set in environment variables. You should be able to type 'az' or 'kubectl' in console window and see the help content.

Deploy Azure Resources

  1. pcs -t remotemonitoring -s enterprise
  2. Follow the on-screen prompts
  3. The results of the deployment will be saved to a file named {deployment-name}-output.json

Sample output format:

"resourceGroup" : {
    "type": "string",
    "value": "{myResourceGroupName}"
},
"iotHubHostName": {
    "type": "string",
    "value": "{myIoTHubHostName}"
},
"iotHubConnectionString": {
    "type": "string",
    "value": "{HostName={hubname}.azure-devices.net;
    SharedAccessKeyName={policy type};SharedAccessKey={Access Key};}"
},
"documentDBConnectionString" : {
    "type": "string",
    "value": "{AccountEndpoint={URI};AccountKey={Key};}"
}

Important \ \ To create a service principal, you must have permissions to register an \ application with your Azure Active Directory(AAD) tenant, and to assign \ the application to a role in your subscription. To see if you have the \ required permissions, check in the Portal.

Create a Container Service for Kubernetes

  1. az login
  2. az account set --subscription {subscriptionId } from step 3 of Deploy Azure Resources
  3. az acs create -n {myClusterName} -d {myDNSPrefix} -g {resouceGroup} -t kubernetes --generate-ssh-keys where resouceGroup from step 3 of Deploy Azure Resources
  4. az acs kubernetes get-credentials -g {myResorceGroupName} -n {myClusterName} --ssh-key-file {path to ssh key file to use}

Deploy Docker images through Kubernetes

To verify access test with kubectl get nodes

  1. kubectl create -f .\remotemonitoring\scripts\nginx-ingress-controller.yaml
  2. Go to your resource group on portal.azure.com and set up friendly DNS name for Public IP address that got created in step 3 of Create a Container Service for Kubernetes. It will start with {myClusterName}. To confirm match the IP address with "LoadBalancer Ingress" by running kubectl describe svc nginx-ingress
  3. Add actual values in the ConfigMap section in file all-in-one.yaml and deployment-configmap.yaml. Values to replace will be of format "{...}". Some examples below.
    • {DNS} with value from step 2
    • {IoT Hub connection string}
    • {DocumentDB connection string}
  4. kubectl create -f .\remotemonitoring\scripts\all-in-one.yaml

Important \ \ If your account doesn't have the Azure Active Directory (AAD) and subscription permissions to create a service principal, then the command generates an error similar to Insufficient privileges to complete the operation. \ Also, when using --generate-ssh-keys, if one key already exists at ~/.ssh/id_rsa then it will be used.

Verify the Web UI and Microservices are deployed

  1. Click on the link that is shown in the output window, it will take you to the Remote Monitoring WebApp
  2. Go to {DNS}/hubmanager/v1/status to see HubManager microservice status
  3. Go to {DNS}/devices/v1/status to see Devices microservice status

Configuration

Kubernetes Dashboard

To view Kubernetes dashboard, run the following command, which will start a local web proxy for your cluster (it will start a local server at http://127.0.0.1:8001/ui):

az acs kubernetes browse -g {myResourceGroupName} -n {myClusterName} --ssh-key-file {path to ssh file}

CLI Options

To get help run pcs -h or --help \ To get the version run pcs -v or --version

Feedback

Please enter issues, bugs, or suggestions as GitHub Issues here: https://github.com/Azure/pcs-cli/issues.

Related