Compare commits

..

No commits in common. "cacb1c0254fa8d0aacb4373d09db155999314d75" and "e5f9d3e3c892319330b6979cef4aa7a31a07eaa6" have entirely different histories.

6 changed files with 34 additions and 154 deletions

View File

@ -26,30 +26,29 @@ build:
- docker push ${HUB_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}
# deploy:
# image: registry.hottis.de/dockerized/docker-bash:latest
# stage: deploy
# tags:
# - hottis
# - linux
# - docker
# only:
# - tags
# variables:
# GIT_STRATEGY: none
# CONTAINER_NAME: sink
# script:
# - docker stop $CONTAINER_NAME || echo "container not running, never mind"
# - docker rm $CONTAINER_NAME || echo "container not existing, never mind"
# - docker run
# -d
# --network docker-server
# --ip 172.16.10.42
# -v sink_config:/etc/sink
# --name $CONTAINER_NAME
# --restart always
# $IMAGE_NAME:$CI_COMMIT_TAG
# environment:
# name: production
deploy:
image: registry.hottis.de/dockerized/docker-bash:latest
stage: deploy
tags:
- hottis
- linux
- docker
only:
- tags
variables:
GIT_STRATEGY: none
CONTAINER_NAME: sink
script:
- docker stop $CONTAINER_NAME || echo "container not running, never mind"
- docker rm $CONTAINER_NAME || echo "container not existing, never mind"
- docker run
-d
--network docker-server
--ip 172.16.10.42
-v sink_config:/etc/sink
--name $CONTAINER_NAME
--restart always
$IMAGE_NAME:$CI_COMMIT_TAG
environment:
name: production

View File

@ -7,6 +7,7 @@ COPY sink/ /tmp/sink
RUN \
apk update && \
apk add alpine-sdk && \
apk add libconfig-dev && \
apk add postgresql-dev && \
cd /tmp/sink && \
make VERSION=${VERSION}
@ -25,12 +26,13 @@ ENV UPPER_BOUND="56000"
COPY --from=builder /tmp/sink/build/sink20169 /usr/local/bin/
RUN \
apk add --no-cache libpq
apk add --no-cache libpq && \
apk add --no-cache libconfig
EXPOSE 20169/udp
USER nobody
CMD [ "/usr/local/bin/sink20169", "-v", "-d" ]
CMD [ "/usr/local/bin/sink20169", "-v" ]

View File

@ -1,30 +1,8 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
namespace: mainscnt
name: deny-all-but-dns
spec:
podSelector:
matchLabels: {}
policyTypes:
- Egress
- Ingress
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sinkserver
namespace: mainscnt
labels:
app: sinkserver
spec:
@ -37,9 +15,11 @@ spec:
labels:
app: sinkserver
spec:
imagePullSecrets:
- name: hottis-registry-creds
containers:
- name: sinkserver
image: wollud1969/sinkserver:e5f9d3e3
image: registry.hottis.de/mainscnt/sinkserver:314b9a42
ports:
- containerPort: 20169
protocol: UDP
@ -59,7 +39,6 @@ apiVersion: v1
kind: Service
metadata:
name: sinkserver
namespace: mainscnt
labels:
app: sinkserver
spec:
@ -70,72 +49,6 @@ spec:
- protocol: UDP
port: 20169
targetPort: 20169
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-database-sinkserver
namespace: database
spec:
podSelector:
matchLabels:
app: timescaledb
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: sinkserver
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: mainscnt
ports:
- protocol: TCP
port: 5432
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-sinkserver-database
namespace: mainscnt
spec:
podSelector:
matchLabels:
app: sinkserver
policyTypes:
- Egress
egress:
- to:
- podSelector:
matchLabels:
app: timescaledb
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: database
ports:
- protocol: TCP
port: 5432
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-sinkserver-ingress
namespace: mainscnt
spec:
podSelector:
matchLabels:
app: sinkserver
policyTypes:
- Ingress
ingress:
- from:
- ipBlock:
cidr: 0.0.0.0/0
ports:
- protocol: UDP
port: 20169

View File

@ -1,4 +0,0 @@
apiVersion: v1
kind: Namespace
metadata:
name: mainscnt

View File

@ -1,30 +0,0 @@
create sequence device_s;
CREATE TABLE device_t (
id integer DEFAULT nextval('device_s') NOT NULL,
deviceid character varying(64) NOT NULL,
sharedsecret character varying(31) NOT NULL,
location character varying(128) NOT NULL,
active boolean DEFAULT false NOT NULL,
contact character varying(128),
flaky boolean DEFAULT false NOT NULL,
CONSTRAINT device_t_sharedsecret_check CHECK ((char_length((sharedsecret)::text) = 31))
);
ALTER TABLE ONLY device_t
ADD CONSTRAINT device_t_deviceid_key UNIQUE (deviceid);
ALTER TABLE ONLY device_t
ADD CONSTRAINT device_t_pkey PRIMARY KEY (id);
CREATE TABLE mainsfrequency (
"time" timestamp without time zone NOT NULL,
host text,
location text,
freq double precision,
valid smallint DEFAULT 1 NOT NULL
);
select create_hypertable('mainsfrequency', 'time');

View File

@ -9,10 +9,10 @@ VERSION ?= $(shell git rev-parse --short=8 HEAD)
UNAME_S := $(shell uname -s)
CC = gcc
CFLAGS = $(shell pkg-config --cflags libpq) -I. \
CFLAGS = $(shell pkg-config --cflags libpq libconfig) -I. \
-Wall -Werror -std=c99 \
-D$(UNAME_S)=1 -DVERSION="\"$(VERSION)\""
LDFLAGS = $(shell pkg-config --libs libpq)
LDFLAGS = $(shell pkg-config --libs libpq libconfig)
TARGET = sink20169
all: $(BUILD_DIR)/$(TARGET)