trunk
henine 3 years ago
parent ea3b937184
commit 98e5da9990

1
.gitignore vendored

@ -0,0 +1 @@
*.iml

@ -0,0 +1 @@
postgres_passsword.yaml

@ -0,0 +1,44 @@
BEGIN;
DROP TABLE IF EXISTS picc_events;
DROP TABLE IF EXISTS picc_locations;
CREATE TABLE picc_locations
(
id SERIAL PRIMARY KEY,
location_name TEXT NOT NULL
-- TODO: figure out PostGIS
);
INSERT INTO picc_locations (id, location_name)
VALUES (0, 'Unknown');
INSERT INTO picc_locations (id, location_name)
VALUES (1, 'Not Applicable');
DROP TABLE IF EXISTS picc_events;
CREATE TABLE picc_events
(
id BIGSERIAL PRIMARY KEY, -- ID
log_time TIMESTAMP with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when event was logged
event_time TIMESTAMP with time zone, -- Optional: time when event was generated, can be different than log_time
event_location integer NOT NULL references picc_locations DEFAULT 0, -- Location associated with event
-- sender text NOT NULL, -- Sender is implicit in whoever owns the endpoint
endpoint text
CONSTRAINT valid_endpoint CHECK ( endpoint ~ '^([A-Za-z0-9_-]+\.)*([A-Za-z0-9_-]+)$' ), -- Event endpoint
body jsonb NOT NULL -- Event body content
);
CREATE INDEX idx_picc_events_endpoint ON picc_events (endpoint);
-- DROP TABLE IF EXISTS mqtt;
--
-- CREATE TABLE picc_mqtt
-- (
-- id BIGSERIAL PRIMARY KEY,
-- receive_time TIMESTAMP,
-- routing_key TEXT,
-- payload TEXT
-- );
COMMIT;

@ -0,0 +1,51 @@
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
type: LoadBalancer
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
spec:
selector:
matchLabels:
app: postgres
serviceName: "postgres"
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: docker.io/postgres:13
ports:
- containerPort: 5432
name: db
env:
- name: POSTGRES_DB
value: picc
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-password
key: password
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 100Mi

@ -0,0 +1,6 @@
apiVersion: v1
kind: Secret
metadata:
name: postgres-password
data:
password: <encoded password; echo -n "password" | base64>

@ -0,0 +1 @@
rabbitmq-config.yaml

@ -0,0 +1 @@
[rabbitmq_management,rabbitmq_mqtt].

@ -0,0 +1,21 @@
loopback_users.guest = false
listeners.tcp.default = 5672
management.tcp.port = 15672
#mqtt.listeners.tcp.default = 1883
## Default MQTT with TLS port is 8883
# mqtt.listeners.ssl.default = 8883
# anonymous connections, if allowed, will use the default
# credentials specified here
#mqtt.allow_anonymous = true
#mqtt.default_user = guest
#mqtt.default_pass = guest
#mqtt.vhost = /
mqtt.exchange = mqtt
# 24 hours by default
#mqtt.subscription_ttl = 86400000
#mqtt.prefetch = 10
load_definitions = /etc/rabbitmq/rmq_schema.json

@ -0,0 +1,40 @@
{
"rabbit_version": "3.8.9",
"rabbitmq_version": "3.8.9",
"product_name": "RabbitMQ",
"product_version": "3.8.9",
"users": [
{
"name": "guest",
"password_hash": "KzhdT8G04Hon/5BEAasW4KF9NVBpwo3MIKGBs0nJjz8KLBvq",
"hashing_algorithm": "rabbit_password_hashing_sha256",
"tags": "administrator"
}
],
"vhosts": [
{
"name": "/"
}
],
"permissions": [
{
"user": "guest",
"vhost": "/",
"configure": ".*",
"write": ".*",
"read": ".*"
}
],
"policies": [],
"exchanges": [
{
"name": "mqtt",
"vhost": "/",
"type": "topic",
"durable": true,
"auto_delete": false,
"internal": false,
"arguments": {}
}
]
}

@ -0,0 +1,12 @@
{
"rabbitmq-config.yaml":
{
"apiVersion" : "v1",
"kind": "ConfigMap",
"metadata": {"name": "rabbitmq-config"},
"data": {
"enabled_plugins": importstr "etc/rabbitmq/enabled_plugins",
"rabbitmq.conf": importstr "etc/rabbitmq/rabbitmq.conf",
"rmq_schema.json": importstr "etc/rabbitmq/rmq_schema.json"
}
}}

@ -0,0 +1,53 @@
apiVersion: v1
kind: Service
metadata:
name: rabbitmq
spec:
type: LoadBalancer
selector:
app: rabbitmq
ports:
- name: amqp
port: 5672
- name: web
port: 15672
- name: mqtt
port: 1883
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: rabbitmq
labels:
app: rabbitmq
spec:
replicas: 1
selector:
matchLabels:
app: rabbitmq
template:
metadata:
labels:
app: rabbitmq
spec:
containers:
- name: rabbitmq
image: docker.io/rabbitmq:3
ports:
- containerPort: 5672
- containerPort: 15672
- containerPort: 1883
volumeMounts:
- mountPath: "/etc/rabbitmq"
name: config
volumes:
- name: config
configMap:
name: rabbitmq-config
items:
- key: "enabled_plugins"
path: "enabled_plugins"
- key: "rabbitmq.conf"
path: "rabbitmq.conf"
- key: "rmq_schema.json"
path: "rmq_schema.json"
Loading…
Cancel
Save