Target
Continuing from the previous article on NFS file systems, the current requirement is to be able to control the applications running in the cluster. For example, if we need to run parallel cross-node program A, we need to schedule and stop the running program B. This requires building a messaging system that can perform operational tasks based on message drivers.
This requires building a messaging system that can perform message-driven operational tasks. ## Vision and Basic Architecture Design ##
Swift is set to be the next generation machine learning language for Tensorflow, see Swift for Tensorflow for current attempts to write applications in Swift. 2.
-
use the MQTT protocol to send and receive data that needs to be processed. 3. use TinyML technology to collect data.
-
using TinyML technology to collect data generated by sensors on home appliances to make the appliances smarter.
The current idea is to use RabbitMQ as the message middleware, Swift to write server-side applications to push messages, and the client needs a UI application to accept and process the corresponding message events.
Discover Node-Red
Node-Red is a process-based visual programming tool developed by IBM.
I personally find its advantages to be the speed of developing prototype IoT applications, support for Arduino, Raspberry Pi and other devices, easy to use, event-driven, native nodejs development language, and support for extensible plug-ins.
Runs on K3s
node-red.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-red
namespace: science
labels:
app: node-red
spec:
replicas: 1
selector:
matchLabels:
app: node-red
template:
metadata:
labels:
app: node-red
spec:
containers:
- name: node-red
image: $image
imagePullPolicy: Always
ports:
- containerPort: 1880
volumeMounts:
- mountPath: /data
name: data-volume
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: node-red-pvc
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: node-red-pvc
namespace: science
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 6Gi
---
apiVersion: v1
kind: Service
metadata:
name: node-red
namespace: science
spec:
selector:
app: node-red
ports:
- protocol: TCP
port: 1880
targetPort: 1880
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: node-red-ingress
namespace: science
spec:
rules:
- host: foo.bar.host
http:
paths:
- backend:
serviceName: node-red
servicePort: 1880
Run RabbitMQ On K3s
rabbitmq-conf-rabbitmq-env-configmap.yaml
apiVersion: v1
data:
RABBITMQ_DEFAULT_PASS: xxxxx
RABBITMQ_DEFAULT_USER: admin
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: "5672"
kind: ConfigMap
metadata:
name: rabbitmq-conf-rabbitmq-env
namespace: science
rabbitmq-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: rabbitmq
name: rabbitmq
namespace: science
spec:
replicas: 1
selector:
matchLabels:
app: rabbitmq
template:
metadata:
labels:
app: rabbitmq
spec:
hostname: rabbitmq
containers:
- env:
- name: RABBITMQ_DEFAULT_PASS
valueFrom:
configMapKeyRef:
key: RABBITMQ_DEFAULT_PASS
name: rabbitmq-conf-rabbitmq-env
- name: RABBITMQ_DEFAULT_USER
valueFrom:
configMapKeyRef:
key: RABBITMQ_DEFAULT_USER
name: rabbitmq-conf-rabbitmq-env
- name: RABBITMQ_HOST
valueFrom:
configMapKeyRef:
key: RABBITMQ_HOST
name: rabbitmq-conf-rabbitmq-env
- name: RABBITMQ_PORT
valueFrom:
configMapKeyRef:
key: RABBITMQ_PORT
name: rabbitmq-conf-rabbitmq-env
image: 192.168.1.114:5000/rabbitmq:3.8.5-management-alpine
ports:
- containerPort: 5672
name: port
protocol: TCP
- containerPort: 15672
name: web-port
protocol: TCP
name: rabbitmq
volumeMounts:
- mountPath: /var/lib/rabbitmq
name: rabbitmq-volume
restartPolicy: Always
volumes:
- name: rabbitmq-volume
persistentVolumeClaim:
claimName: rabbitmq-volume
rabbitmq-service.yaml
apiVersion: v1
kind: Service
metadata:
name: rabbitmq
namespace: science
labels:
app: rabbitmq
spec:
ports:
- protocol: TCP
port: 5672
targetPort: 5672
name: port
- protocol: TCP
port: 15672
targetPort: 15672
name: web-port
selector:
app: rabbitmq
rabbitmq-volume-persistentvolumeclaim.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rabbitmq-volume
namespace: science
spec:
accessModes:
- ReadWriteOnce
storageClassName: managed-nfs-storage
resources:
requests:
storage: 10Gi