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

View File

@ -7,6 +7,7 @@ COPY sink/ /tmp/sink
RUN \ RUN \
apk update && \ apk update && \
apk add alpine-sdk && \ apk add alpine-sdk && \
apk add libconfig-dev && \
apk add postgresql-dev && \ apk add postgresql-dev && \
cd /tmp/sink && \ cd /tmp/sink && \
make VERSION=${VERSION} make VERSION=${VERSION}
@ -25,12 +26,13 @@ ENV UPPER_BOUND="56000"
COPY --from=builder /tmp/sink/build/sink20169 /usr/local/bin/ COPY --from=builder /tmp/sink/build/sink20169 /usr/local/bin/
RUN \ RUN \
apk add --no-cache libpq apk add --no-cache libpq && \
apk add --no-cache libconfig
EXPOSE 20169/udp EXPOSE 20169/udp
USER nobody 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 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: sinkserver name: sinkserver
namespace: mainscnt
labels: labels:
app: sinkserver app: sinkserver
spec: spec:
@ -37,9 +15,11 @@ spec:
labels: labels:
app: sinkserver app: sinkserver
spec: spec:
imagePullSecrets:
- name: hottis-registry-creds
containers: containers:
- name: sinkserver - name: sinkserver
image: wollud1969/sinkserver:e5f9d3e3 image: registry.hottis.de/mainscnt/sinkserver:314b9a42
ports: ports:
- containerPort: 20169 - containerPort: 20169
protocol: UDP protocol: UDP
@ -59,7 +39,6 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: sinkserver name: sinkserver
namespace: mainscnt
labels: labels:
app: sinkserver app: sinkserver
spec: spec:
@ -70,72 +49,6 @@ spec:
- protocol: UDP - protocol: UDP
port: 20169 port: 20169
targetPort: 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) UNAME_S := $(shell uname -s)
CC = gcc CC = gcc
CFLAGS = $(shell pkg-config --cflags libpq) -I. \ CFLAGS = $(shell pkg-config --cflags libpq libconfig) -I. \
-Wall -Werror -std=c99 \ -Wall -Werror -std=c99 \
-D$(UNAME_S)=1 -DVERSION="\"$(VERSION)\"" -D$(UNAME_S)=1 -DVERSION="\"$(VERSION)\""
LDFLAGS = $(shell pkg-config --libs libpq) LDFLAGS = $(shell pkg-config --libs libpq libconfig)
TARGET = sink20169 TARGET = sink20169
all: $(BUILD_DIR)/$(TARGET) all: $(BUILD_DIR)/$(TARGET)