Skip to main content

To MySQL

Shifu can push your data from telemetry to your MySQL

Create TelemetryService Yaml file

#telemetry_service.yaml
apiVersion: shifu.edgenesis.io/v1alpha1
kind: TelemetryService
metadata:
name: push-endpoint-1 # tag
namespace: devices
spec:
telemetryServiceEndpoint: http://telemetryservice.shifu-service.svc.cluster.local
serviceSettings:
SQLSetting:
serverAddress: 192.168.14.163:3306
secret: my-secret
dbName: shifu
dbTable: testTable2
dbtype: MySQL
  • telemetryServiceEndpoint is telemetry service endpoint address
  • serverAddress is the database address
  • secret is the name of the Secret stored your database username and password
  • dbName is the name of the database
  • dbTable is the table name of the database
  • dbType is the type of the database

Create the Secret

Create a Secret named the secret field above with the username field filled by your username and the password field filled by your password.

kubectl create secret generic mysql-secret --from-literal=username=your_username --from-literal=password=your_password -n devices
note

If you have multiple telemetry services, you can write them in one file and split them in one file using ---.

Edit Configmap Yaml file

# configmap.yaml
data:
telemetries: |
telemetries:
device_health1:
properties:
instruction: status
pushSettings:
telemetryCollectionService: push-endpoint-1 # Edit it to the name same with TelemetryService's name

Then edit the Configmap yaml file and make sure that the telemetryCollectionService value is the same as the name of the telemetry service you created in the previous step.

deploy deviceShifu again

Then you need to deploy deviceShifu again so that the telemetry will push raw data to the telemetry service and publish it to your MySQL database.