fix
This commit is contained in:
12
deployment/install.sh
Executable file
12
deployment/install.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
NAMESPACE=$(cat namespace)
|
||||
~/Workspace/MyKubernetesEnv/tools/create-namespace.sh $NAMESPACE
|
||||
|
||||
./roll-db-credential.sh
|
||||
|
||||
kubectl -f install.yml -n $NAMESPACE apply
|
||||
|
||||
kubectl apply -f - -n $NAMESPACE
|
||||
|
36
deployment/install.yml
Normal file
36
deployment/install.yml
Normal file
@ -0,0 +1,36 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: cemmetering
|
||||
data:
|
||||
MQTT_BROKER: "emqx01-anonymous-cluster-internal.broker.svc.cluster.local"
|
||||
MQTT_PORT: "1883"
|
||||
PGDATABASE: "cem_monitoring_berresheim"
|
||||
PGHOST: "timescaledb.database.svc.cluster.local"
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: cemmetering
|
||||
labels:
|
||||
app: cemmetering
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cemmetering
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: cemmetering
|
||||
spec:
|
||||
containers:
|
||||
- name: cemmetering
|
||||
image: wollud1969/cemmetering-preprocessor:1.0.0
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: cemmetering
|
||||
- secretRef:
|
||||
name: cemmetering-db-cred
|
||||
|
||||
|
1
deployment/namespace
Normal file
1
deployment/namespace
Normal file
@ -0,0 +1 @@
|
||||
berresheim
|
33
deployment/roll-db-credential.sh
Executable file
33
deployment/roll-db-credential.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ~/Workspace/MyKubernetesEnv/ENVDB
|
||||
|
||||
DATABASE=cem_monitoring_berresheim
|
||||
LOGIN=cem_preprocessor
|
||||
PASSWORD=`openssl rand -base64 24`
|
||||
NAMESPACE=`cat namespace`
|
||||
|
||||
psql <<EOF
|
||||
do
|
||||
\$\$
|
||||
begin
|
||||
if not exists (SELECT * FROM pg_user WHERE usename = '$LOGIN') then
|
||||
CREATE USER $LOGIN WITH PASSWORD '$PASSWORD';
|
||||
else
|
||||
ALTER USER $LOGIN WITH PASSWORD '$PASSWORD';
|
||||
end if;
|
||||
end
|
||||
\$\$
|
||||
;
|
||||
commit;
|
||||
EOF
|
||||
|
||||
kubectl create secret generic cemmetering-db-cred \
|
||||
--dry-run=client \
|
||||
-o yaml \
|
||||
--save-config \
|
||||
--from-literal=PGUSER="$LOGIN" \
|
||||
--from-literal=PGPASSWORD="$PASSWORD" | \
|
||||
kubectl apply -f - -n $NAMESPACE
|
||||
|
||||
|
Reference in New Issue
Block a user