Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a25204f2f
|
|||
52b414f60f
|
|||
3fc83eefe6
|
|||
a58959a316
|
|||
2c21ab00a0
|
|||
d66483cdf3
|
|||
ecceb5baa3
|
|||
c505c525f8
|
|||
3595bf251d
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"mqtt": {
|
||||
"broker": "mqtt://emqx01-anonymous-cluster-internal.broker.svc.cluster.local:1883",
|
||||
"username": "archiver",
|
||||
"tlsEnable": "false"
|
||||
},
|
||||
"includeTopics": [
|
||||
|
@ -22,7 +22,9 @@ spec:
|
||||
imagePullPolicy: Always
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: ma-db-cred
|
||||
name: ma-db-cred
|
||||
- secretRef:
|
||||
name: ma-mqtt-cred
|
||||
- configMapRef:
|
||||
name: ma-conf
|
||||
name: ma-conf
|
||||
|
||||
|
@ -13,12 +13,10 @@ pushd $DEPLOYMENT_DIR
|
||||
|
||||
NAMESPACE=`cat namespace`
|
||||
|
||||
./roll-db-credentials.sh
|
||||
|
||||
kubectl create configmap ma-conf \
|
||||
--from-literal=MA_CONF="`cat config.json`" \
|
||||
--dry-run=client \
|
||||
--o yaml \
|
||||
-o yaml \
|
||||
--save-config | \
|
||||
kubectl apply -f - -n $NAMESPACE
|
||||
|
||||
|
@ -1,16 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PGUSER=`kubectl get secret -n database timescaledb -o jsonpath="{.data.superuser-username}" | base64 --decode`
|
||||
export PGHOST=`kubectl get services traefik -n system -o jsonpath="{.status.loadBalancer.ingress[0].ip}"`
|
||||
export PGPASSWORD=`kubectl get secret -n database timescaledb -o jsonpath="{.data.superuser-password}" | base64 --decode`
|
||||
export PGSSLMODE=require
|
||||
|
||||
. ~/Workspace/mykubernetesenv/ENVDB1
|
||||
|
||||
DATABASE=ma
|
||||
LOGIN=ma
|
||||
PASSWORD=`openssl rand -base64 24`
|
||||
NAMESPACE=`cat namespace`
|
||||
|
||||
|
||||
psql <<EOF
|
||||
do
|
||||
\$\$
|
||||
@ -32,7 +29,7 @@ kubectl create secret generic ma-db-cred \
|
||||
--from-literal=PGUSER="$LOGIN" \
|
||||
--from-literal=PGPASSWORD="$PASSWORD" \
|
||||
--from-literal=PGDATABASE="$DATABASE" \
|
||||
--from-literal=PGHOST="timescaledb.database.svc.cluster.local" \
|
||||
--from-literal=PGHOST="database.database1.svc.cluster.local" \
|
||||
--from-literal=PGSSLMODE="require" | \
|
||||
kubectl apply -f - -n $NAMESPACE
|
||||
|
@ -7,7 +7,7 @@ import "time"
|
||||
//import "net/url"
|
||||
import "ma/mqtt"
|
||||
//import "ma/config"
|
||||
import "ma/counter"
|
||||
//import "ma/counter"
|
||||
import "ma/database"
|
||||
|
||||
var dbh *database.DatabaseHandle
|
||||
@ -29,8 +29,7 @@ func InputArchiver() {
|
||||
}
|
||||
|
||||
func handleMessage(message database.Message) {
|
||||
log.Printf("Archiving Timestamp: %s, Topic: %s, Payload: %s", message.Time, message.Topic, message.Payload)
|
||||
// log.Printf("Archiving Timestamp: %s, Topic: %s, Payload: %s", message.Time, message.Topic, message.Payload)
|
||||
dbh.StoreMessage(&message)
|
||||
counter.S("Stored")
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,9 @@ func StartMqttClient() {
|
||||
if token := mqttClient.Connect(); token.Wait() && token.Error() != nil {
|
||||
log.Fatalf("Unable to connect to broker %s, error %s", broker, token.Error())
|
||||
}
|
||||
//log.Printf("Successfully connected to broker %s", broker)
|
||||
log.Printf("Successfully connected to broker %s", broker)
|
||||
log.Printf("Include topics: %s", config.Config.IncludeTopics)
|
||||
log.Printf("Exclude topics: %s", config.Config.ExcludeTopics)
|
||||
|
||||
go outputDispatcher(mqttClient)
|
||||
|
||||
|
Reference in New Issue
Block a user