Code Monkey home page Code Monkey logo

kubeedge-web-demo's Introduction

KubeEdge Web Demo

Firstly the users input kubeedge to get the web app link, and then the users click the link to enter the web app page, choose the music and click the button Play in the web page, at last the expected track is pushed to the edge node and the track is played on the speaker connected to the edge node.

Prerequisites

Hardware Prerequisites

  • RaspBerry PI (RaspBerry PI 3 has been used for this demo). The RaspBerry PI is also the edge node to which the speaker will be connected.

  • A speaker for playing the music.

Software Prerequisites

  • A running Kubernetes cluster.

  • KubeEdge 0.3.0 See instructions on how to setup KubeEdge.

    Note:

    when you setup edgecore on the RaspBerry PI, Please set the mqtt mode into 2 in this line, and replace 0.0.0.0 with your Kubernetes master ip address in this line.

  • In order to control the speaker and play the expected track, we need to manage the speaker connected to the RaspBerry PI. KubeEdge allows us to manage devices using Kubernetes custom resource definitions. The design proposal is here. Apply the CRD schema yamls available here using kubectl.

Steps to run the demo

Clone demo code

$ git clone https://github.com/edisonxiang/kubeedge-web-demo

Create the device model and device instance for the speaker

With the Device CRD APIs now installed in the cluster, we create the device model and instance for the speaker using the yaml files.

$ cd $GOPATH/src/github.com/edisonxiang/kubeedge-web-demo/kubeedge-web-app/deployments/
$ kubectl create -f kubeedge-speaker-model.yaml
$ kubectl create -f kubeedge-speaker-instance.yaml

Run KubeEdge Web App

The KubeEdge Web App runs in a VM on cloud. It can be deployed using a Kubernetes deployment yaml.

$ cd $GOPATH/src/github.com/edisonxiang/kubeedge-web-demo/kubeedge-web-app/deployments/
$ kubectl create -f kubeedge-web-app.yaml

Build PI Player App

Cross-complie the PI Player App which will run on the RaspBerry PI and play the expected track.

$ cd $GOPATH/src/github.com/edisonxiang/kubeedge-web-demo/pi-player-app/
$ export GOARCH=arm
$ export GOOS="linux"
$ export GOARM=6
$ export CGO_ENABLED=1
$ export CC=arm-linux-gnueabi-gcc
$ go build -o pi-player-app main.go

Run PI Player App

Make sure the MQTT broker is running on the RaspBerry PI. Copy the PI Player App binary to the RaspBerry PI and run it. The App will subscibe to the $hw/events/device/speaker-01/twin/update/document topic and when it receives the expected track on the topic, it will play it on the speaker. At last, you need to copy the music files into the folder /home/pi/music/ on the RaspBerry PI. The music file name is like .mp3, for example: 1.mp3

The PI Player App will issue the omxplayer to play music, please make sure the omxplayer is installed on the RaspBerry PI. If not, please see the following link to setup omxplayer.

https://raspberry-projects.com/pi/software_utilities/media-players/omxplayer

$ ./pi-player-app

Play music by visiting WeChat Subscription Account

  • Visit to the WeChat Subscription Account.

  • Input kubeedge to get the web app link and click the link.

  • Choose the music you want to play, and then click the button Play. The track info is pushed to the RaspBerry PI and the music is played on the speaker.

  • Click the button stop to stop the music, the music is stopped on the speaker.

kubeedge-web-demo's People

Contributors

edisonxiang avatar fisherxu avatar kevin-wangzefeng avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.