cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

IoT Tech Tips

Sort by:
This post is part of the series Forced Root Cause Monitoring via Mashups and Modal Popups To not feel lost or out of context, it's recommended to read the main post first. Create Entities   AlertStateDefinition   Create a new StateDefinition called "rcp_AlertStateDefinition" In the State Information tab, select Apply State: Numeric from the list on the right hand side Create a new State: Less than or equal to "1" Display Name: "Something good" Style: a new custom style with text color #f5b83d (orange) Create a new State: Less than or equal to "2" Display Name: "Something bad" Style: a new custom style with text color #f55c3d (red) Create a new State: Less than or equal to "3" Display Name: "Something ugly" Style: a new custom style with text color #ad1f1f (red) with a Font Bold Edit the "Default" State Set the Style: a new custom style with text color #36ad1f (green) We will not use this style, but in case we need a default configuration it will blend into the color schema Save the StateDefinition ValueStream   Create a new ValueStream called "rcp_ValueStream" (choose a default ValueStream, not a RemoteValueStream) Save the ValueStream AlertThing   Create a new Thing called "rcp_AlertThing" Based on a Generic Thing Base Thing Template Using the rcp_ValueStream Value Stream In the Properties and Alerts tab create the following Properties Name: "trigger" Base Type: BOOLEAN With a Default Value of "false" Check the "Persistent" checkbox Name: "selectedReason" BaseType: NUMBER Check the "Persistent" checkbox Check the "Logged" checkbox Advanced Settings: Data Change Type: ALWAYS In the Services tab create a new Service Name: "clearTrigger" No Inputs and no Outputs Service code me.trigger = false; When this service is executed, it will set the trigger Property to false Click Done to complete the Service creation Save the Thing    
View full tip
Disclaimer: The scripts and content published here are provided solely as a courtesy to PTC customers. Each script is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the PTC be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the scripts, including any software vulnerabilities.     Hi developers,   Ready to deploy ThingWorx containers on Kubernetes using Helm?   Let's get started using the steps below from Luis, one of our awesome software developers.   Before you dive too far in, please note that the following instructions assume you have downloaded the Docker scripts from our downloads portal and followed the instructions to build and publish the ThingWorx Docker images to your own Docker registry; they also assume that you have a working Kubernetes cluster with sufficient resources available.   These steps are intended to be used as a deployment manual and will not provide in-depth information about Kubernetes or the Helm package manager.     To start, you'll need the following prerequisites: A working Kubernetes cluster (Minikube should also work) kubectl cli tool installed and configured (https://kubernetes.io/docs/tasks/tools/install-kubectl/) helm cli tool installed and configured (https://docs.helm.sh/using_helm/#installing-helm)   In this example, we'll use the ThingWorx platform with PostgreSQL as a persistence provider. To prepare for the deployment, start by downloading the sample Helm chart  thingworx-0.1.0.tgz  (this is zipped in the .7z file attached ). You can take a look at what is configurable in this Helm chart: $ helm inspect thingworx-0.1.0.tgz This will show you the default configuration ( values.yaml ) and instructions ( README.md ) provided within the package. In the next steps, you'll see how to override some of these values to make the deployment fit your environment.    Let's create your custom  values  file. Use your favorite text editor and create a new file that looks like the following example. Please note the comments and make the necessary adjustments.    # Uncomment the following lines if you're using a private Docker registry that requires a username and password #imageCredentials: # password: mySecretAndSecurePassword # Your Docker Registry Password here # registry: docker.example.com # Your Docker Registry FQDN here # username: myUsername # Your Docker Registry Username here registry: domain: docker.example.com # Your Docker Registry FQDN here thingworx: image: repository: thingworx-platform-postgres # Your Thingworx Docker image name tag: 8.4.0 # Your Thingworx Docker image tag # Uncomment the following lines if you have the nginx-ingres addon installed on your cluster # ingress: # enabled: true # annotations: # kubernetes: # io/ingress: # class: nginx # hosts: # - twx.k8s.example.com # A FQDN that resolves to your cluster's ingress point   Note: The default  values.yaml  file included in the chart contains default usernames and passwords that must be changed before using this chart for production purposes. To change them also include a block like the following in your   myValues.yaml. postgresql: postgresPassword: YOUR_PG_ADMIN_PASSWORD commonConf: DATABASE_ADMIN_USERNAME: YOUR_PG_ADMIN_USER TWX_DATABASE_USERNAME: YOUR_TWX_DB_USER TWX_DATABASE_PASSWORD: YOUR_TWX_DB_PASSWORD RABBITMQ_USERNAME: YOUR_RABBITMQ_USER RABBITMQ_PASSWORD: YOUR_RABBITMQ_PASSWORD Save this file as  myValues.yaml .   If you have never used Helm with your cluster before, you should run the following command. This will install/upgrade the Helm server-side component (Tiller) on your Kubernetes cluster.   $ helm init --upgrade Now, to deploy ThingWorx, run the following command. This will deploy ThingWorx into your current kube config namespace. If you want to deploy into a specific namespace use the  --namespace  or  -n  flag.   $ helm upgrade --install -f myValues.yaml thingworx-test thingworx-0.1.0.tgz Wait a few seconds and you should have ThingWorx deployed onto your Kubernetes cluster. You can use  kubectl  to check if the ThingWorx and PostgreSQL pods are ready:   $ kubectl get pods If you have an Ingress set up on your cluster, you can just open a browser and point it to the URL you created for it; if not, you can use  kubectl  to reach it:   $ kubectl port-forward service/thingworx-test-twx 8080   Leave the terminal open and point your browser to http://localhost:8080/Thingworx.   Below, you can find an example using Minikube; you can get Minikube from https://github.com/kubernetes/minikube: # Start minikube minikube start --memory 8192 --cpus 4 # Set docker env so you can use local images with minikube eval $(minikube docker-env) # Ensure that kubectl is configured for minikube minikube update-context # Pull the image from your Docker registry docker pull artifactory.rd2.thingworx.io/twxdevops/tw-platform-postgres:8.4.0-build-latest # check the Thingworx helm default values and README helm inspect thingworx-0.1.0.tgz # Create your custom values file cat << EOF > myValues.yaml # Add the content registry: domain: artifactory.rd2.thingworx.io thingworx: image: repository: twxdevops/tw-platform-postgres tag: 8.4.0-build-latest pullPolicy: IfNotPresent # this is to use the existing local image in minikube resources: requests: cpu: 1 memory: 1Gi # Make sure it can fit our Minikube VM EOF # Initialize helm and tiller helm init --upgrade # Deploy Thingworx helm upgrade --install -f myValues.yaml thingworx-test thingworx-0.1.0.tgz # Verify the deployment status helm ls # Verify that the Thingworx and PostgreSQL pods where created (check the status column) kubectl get pods # Wait until both pods are ready and use kubectl port-forward to reach the Thingworx Composer UI kubectl port-forward service/thingworx-test-twx 8080 # Open the Thingworx Composer UI in your default browser xdg-open http://localhost:8080/Thingworx # Use open instead of xdg-open if you're on macOS Here's a quick video explaining the deployment of ThingWorx Docker images on Minikube.   (view in My Videos)   Let me know your thoughts and questions below!   Stay connected, Kaya  
View full tip