adding some rqlite vars

This commit is contained in:
afeiszli 2021-08-18 14:55:41 -04:00
parent 9d2962a171
commit f42f81243f
7 changed files with 57 additions and 44 deletions

View file

@ -52,6 +52,7 @@ type ServerConfig struct {
DisableDefaultNet string `yaml:"disabledefaultnet"`
GRPCSSL string `yaml:"grpcssl"`
Version string `yaml:"version"`
SQLConn string `yaml:"sqlconn"`
DefaultNodeLimit int32 `yaml:"defaultnodelimit"`
Verbosity int32 `yaml:"verbosity"`
}

View file

@ -9,5 +9,6 @@ server:
agentbackend: "" # defaults to "on" or AGENT_BACKEND (if set)
clientmode: "" # defaults to "on" or CLIENT_MODE (if set)
dnsmode: "" # defaults to "on" or DNS_MODE (if set)
sqlconn: "" # defaults to "http://" or SQL_CONN (if set)
disableremoteipcheck: "" # defaults to "false" or DISABLE_REMOTE_IP_CHECK (if set)
version: "0.7.1" # version of server

View file

@ -3,7 +3,8 @@ package database
import (
"encoding/json"
"errors"
"log"
"github.com/gravitl/netmaker/servercfg"
"github.com/rqlite/gorqlite"
)
@ -25,7 +26,8 @@ var Database gorqlite.Connection
func InitializeDatabase() error {
conn, err := gorqlite.Open("http://")
//log.Println("sql conn value:",servercfg.GetSQLConn())
conn, err := gorqlite.Open(servercfg.GetSQLConn())
if err != nil {
return err
}

View file

@ -20,11 +20,25 @@ func SetDNSDir() error {
}
_, err = os.Stat(dir + "/config/dnsconfig")
if os.IsNotExist(err) {
os.Mkdir(dir+"/config/dnsconfig", 744)
os.Mkdir(dir+"/config/dnsconfig", 0744)
} else if err != nil {
PrintUserLog("","couldnt find or create /config/dnsconfig",0)
return err
}
_, err = os.Stat(dir + "/config/dnsconfig/Corefile")
if os.IsNotExist(err) {
err = SetCorefile("example.com")
if err != nil {
PrintUserLog("",err.Error(),0)
}
}
_, err = os.Stat(dir + "/config/dnsconfig/netmaker.hosts")
if os.IsNotExist(err) {
_, err = os.Create(dir + "/config/dnsconfig/netmaker.hosts")
if err != nil {
PrintUserLog("",err.Error(),0)
}
}
return nil
}

View file

@ -1,62 +1,56 @@
apiVersion: v1
kind: Service
metadata:
name: mongo
name: rqlite
labels:
name: mongo
name: rqlite
spec:
ports:
- port: 27017
targetPort: 27017
- port: 4001
targetPort: 4001
clusterIP: None
selector:
role: mongo
role: rqlite
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
name: rqlite
spec:
serviceName: "mongo"
serviceName: "rqlite"
replicas: 1
selector:
matchLabels:
role: mongo
role: rqlite
template:
metadata:
labels:
app: mongo
role: mongo
app: rqlite
role: rqlite
spec:
containers:
- name: mongo
image: mongo
env:
- name: MONGO_INITDB_ROOT_USERNAME
value: mongoadmin
- name: MONGO_INITDB_ROOT_PASSWORD
value: mongopass
securityContext:
privileged: true
- name: rqlite
image: rqlite/rqlite
ports:
- containerPort: 4001
volumeMounts:
- name: mongovol
mountPath: /data/db
- name: rqlitevol
mountPath: /rqlite/file/data
volumes:
- name: mongovol
- name: rqlitevol
persistentVolumeClaim:
claimName: mongodb-pvc
claimName: rqlite-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongodb-pvc
name: rqlite-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 7Gi
storageClassName: microk8s-hostpath
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
@ -89,6 +83,8 @@ spec:
value: "grpc.NETMAKER_BASE_DOMAIN:443"
- name: COREDNS_ADDR
value: "10.152.183.53"
- name: SQL_CONN
value: "http://rqlite-0:4001"
- name: GRPC_SSL
value: "on"
- name: SERVER_HTTP_HOST
@ -103,20 +99,10 @@ spec:
value: "off"
- name: MASTER_KEY
value: "Unkn0wn!"
- name: SERVER_GRPC_WIREGUARD
value: "off"
- name: MASTER_KEY
value: "secretkey"
- name: CORS_ALLOWED_ORIGIN
value: "*"
- name: MONGO_ADMIN
value: "mongoadmin"
- name: MONGO_PASS
value: "mongopass"
- name: MONGO_HOST
value: "mongo-0.mongo"
- name: MONGO_OPTS
value: "/?authSource=admin"
volumes:
- name: nm-pvc
persistentVolumeClaim:
@ -132,7 +118,6 @@ spec:
resources:
requests:
storage: 128Mi
storageClassName: microk8s-hostpath
---
apiVersion: v1
kind: Service
@ -288,7 +273,7 @@ metadata:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
spec:
ingressClassName: public
ingressClassName: nginx
tls:
- hosts:
- api.NETMAKER_BASE_DOMAIN
@ -314,7 +299,7 @@ metadata:
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
spec:
ingressClassName: public
ingressClassName: nginx
tls:
- hosts:
- grpc.NETMAKER_BASE_DOMAIN
@ -340,7 +325,7 @@ metadata:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
spec:
ingressClassName: public
ingressClassName: nginx
tls:
- hosts:
- dashboard.NETMAKER_BASE_DOMAIN

View file

@ -11,7 +11,6 @@ import (
"os/signal"
"strconv"
"sync"
controller "github.com/gravitl/netmaker/controllers"
"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/functions"

View file

@ -31,6 +31,7 @@ func GetServerConfig() config.ServerConfig {
cfg.AllowedOrigin = GetAllowedOrigin()
cfg.RestBackend = "off"
cfg.Verbosity = GetVerbose()
cfg.SQLConn = GetSQLConn()
if IsRestBackend() {
cfg.RestBackend = "on"
}
@ -307,3 +308,13 @@ func GetVerbose() int32 {
}
return int32(level)
}
func GetSQLConn() string {
sqlconn := "http://"
if os.Getenv("SQL_CONN") != "" {
sqlconn = os.Getenv("SQL_CONN")
} else if config.Config.Server.SQLConn != "" {
sqlconn = config.Config.Server.SQLConn
}
return sqlconn
}