use client keys in k8s
This commit is contained in:
parent
b7c2a75a68
commit
73a6fa1e47
1 changed files with 2 additions and 4 deletions
6
db/db.go
6
db/db.go
|
@ -20,7 +20,6 @@ func Connect() error {
|
|||
}
|
||||
|
||||
var username = "nobody"
|
||||
var password string
|
||||
|
||||
u, err := user.Current()
|
||||
if err == nil {
|
||||
|
@ -28,12 +27,11 @@ func Connect() error {
|
|||
}
|
||||
if os.Getenv("COCKROACH_USER") != "" {
|
||||
username = os.Getenv("COCKROACH_USER")
|
||||
password = os.Getenv("COCKROACH_PASS")
|
||||
}
|
||||
|
||||
dsn := fmt.Sprintf("postgresql://%s:%s@localhost:26257/cycore?sslmode=disabled", username, password)
|
||||
dsn := fmt.Sprintf("postgresql://%s@localhost:26257/cycore?sslmode=disabled", username)
|
||||
if os.Getenv("KUBERNETES_SERVICE_HOST") != "" {
|
||||
dsn = fmt.Sprintf("postgresql://%s:%s@cockroachdb-public.db:26257/cycore?sslmode=require&sslrootcert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt", username, password)
|
||||
dsn = fmt.Sprintf("postgresql://%s@cockroachdb-public.db:26257/cycore?sslmode=require&sslrootcert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt&sslcert=/cockroach-certs/cert&sslkey=/cockroach-certs/key", username)
|
||||
}
|
||||
if os.Getenv("DSN") != "" {
|
||||
dsn = os.Getenv("DSN")
|
||||
|
|
Loading…
Reference in a new issue