Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a25204f2f
|
|||
52b414f60f
|
|||
3fc83eefe6
|
|||
a58959a316
|
|||
2c21ab00a0
|
|||
d66483cdf3
|
|||
ecceb5baa3
|
|||
c505c525f8
|
|||
3595bf251d
|
|||
1f078aa2a2
|
|||
490bbb2ded
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"mqtt": {
|
"mqtt": {
|
||||||
"broker": "mqtt://emqx01-anonymous-cluster-internal.broker.svc.cluster.local:1883",
|
"broker": "mqtt://emqx01-anonymous-cluster-internal.broker.svc.cluster.local:1883",
|
||||||
|
"username": "archiver",
|
||||||
"tlsEnable": "false"
|
"tlsEnable": "false"
|
||||||
},
|
},
|
||||||
"includeTopics": [
|
"includeTopics": [
|
||||||
|
@ -23,6 +23,8 @@ spec:
|
|||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: ma-db-cred
|
name: ma-db-cred
|
||||||
|
- secretRef:
|
||||||
|
name: ma-mqtt-cred
|
||||||
- configMapRef:
|
- configMapRef:
|
||||||
name: ma-conf
|
name: ma-conf
|
||||||
|
|
||||||
|
@ -3,21 +3,20 @@
|
|||||||
|
|
||||||
|
|
||||||
ARG1=$1
|
ARG1=$1
|
||||||
NAMESPACE=`cat namespace`
|
|
||||||
IMAGE_NAME=$FORGE_NAME/$CI_REPO
|
IMAGE_NAME=$FORGE_NAME/$CI_REPO
|
||||||
|
|
||||||
DEPLOYMENT_DIR=$PWD/deployment
|
DEPLOYMENT_DIR=$PWD/deployment
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pushd $DEPLOYMENT_DIR > /dev/null
|
pushd $DEPLOYMENT_DIR
|
||||||
|
|
||||||
./roll-db-credential.sh
|
NAMESPACE=`cat namespace`
|
||||||
|
|
||||||
kubectl create configmap ma-conf \
|
kubectl create configmap ma-conf \
|
||||||
--from-literal=MA_CONF="`cat config.json`" \
|
--from-literal=MA_CONF="`cat config.json`" \
|
||||||
--dry-run=client \
|
--dry-run=client \
|
||||||
--o yaml \
|
-o yaml \
|
||||||
--save-config | \
|
--save-config | \
|
||||||
kubectl apply -f - -n $NAMESPACE
|
kubectl apply -f - -n $NAMESPACE
|
||||||
|
|
||||||
@ -26,4 +25,4 @@ cat deploy-yml.tmpl | \
|
|||||||
kubectl apply -f - -n $NAMESPACE
|
kubectl apply -f - -n $NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
popd /dev/null
|
popd
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
export PGUSER=`kubectl get secret -n database timescaledb -o jsonpath="{.data.superuser-username}" | base64 --decode`
|
. ~/Workspace/mykubernetesenv/ENVDB1
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
DATABASE=ma
|
DATABASE=ma
|
||||||
LOGIN=ma
|
LOGIN=ma
|
||||||
PASSWORD=`openssl rand -base64 24`
|
PASSWORD=`openssl rand -base64 24`
|
||||||
NAMESPACE=`cat namespace`
|
NAMESPACE=`cat namespace`
|
||||||
|
|
||||||
|
|
||||||
psql <<EOF
|
psql <<EOF
|
||||||
do
|
do
|
||||||
\$\$
|
\$\$
|
||||||
@ -32,7 +29,7 @@ kubectl create secret generic ma-db-cred \
|
|||||||
--from-literal=PGUSER="$LOGIN" \
|
--from-literal=PGUSER="$LOGIN" \
|
||||||
--from-literal=PGPASSWORD="$PASSWORD" \
|
--from-literal=PGPASSWORD="$PASSWORD" \
|
||||||
--from-literal=PGDATABASE="$DATABASE" \
|
--from-literal=PGDATABASE="$DATABASE" \
|
||||||
--from-literal=PGHOST="timescaledb.database.svc.cluster.local" \
|
--from-literal=PGHOST="database.database1.svc.cluster.local" \
|
||||||
--from-literal=PGSSLMODE="require" | \
|
--from-literal=PGSSLMODE="require" | \
|
||||||
kubectl apply -f - -n $NAMESPACE
|
kubectl apply -f - -n $NAMESPACE
|
||||||
|
|
@ -7,7 +7,7 @@ import "time"
|
|||||||
//import "net/url"
|
//import "net/url"
|
||||||
import "ma/mqtt"
|
import "ma/mqtt"
|
||||||
//import "ma/config"
|
//import "ma/config"
|
||||||
import "ma/counter"
|
//import "ma/counter"
|
||||||
import "ma/database"
|
import "ma/database"
|
||||||
|
|
||||||
var dbh *database.DatabaseHandle
|
var dbh *database.DatabaseHandle
|
||||||
@ -29,8 +29,7 @@ func InputArchiver() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleMessage(message database.Message) {
|
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)
|
dbh.StoreMessage(&message)
|
||||||
counter.S("Stored")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,9 @@ func StartMqttClient() {
|
|||||||
if token := mqttClient.Connect(); token.Wait() && token.Error() != nil {
|
if token := mqttClient.Connect(); token.Wait() && token.Error() != nil {
|
||||||
log.Fatalf("Unable to connect to broker %s, error %s", broker, token.Error())
|
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)
|
go outputDispatcher(mqttClient)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user