Skip to content

Commit

Permalink
Merge pull request #237 from intelops/commmondb
Browse files Browse the repository at this point in the history
Updated the qt in capten
  • Loading branch information
vramk23 authored Jun 7, 2024
2 parents 53c7b03 + e52fe65 commit 9c8ad0b
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/conf/credentials/clickhouse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespaces:
- platform
credentialEntity: clickhouse
credentialIdentifier: clickhouse-admin
credentialType: clickhouse-password
credentialType: "clickhouse-password"
userName: "admin"


8 changes: 8 additions & 0 deletions apps/conf/credentials/qt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: quality-trace-db
secretName: quality-trace-db
namespaces:
- quality-trace
credentialEntity: qt
credentialIdentifier: qt-password
credentialType: qt-password
userName: "tracetest"
2 changes: 1 addition & 1 deletion apps/conf/kad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RepoName: "kad"
RepoURL: "https://kube-tarian.github.io/kad"
Namespace: "capten"
ReleaseName: "kad"
Version: "1.0.5"
Version: "1.0.6"
CreateNamespace: true
PrivilegedNamespace: true
APIEndpoint: https://captenagent.{{.DomainName}}
Expand Down
2 changes: 1 addition & 1 deletion apps/conf/monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RepoName: "tools"
RepoURL: "https://kube-tarian.github.io/helmrepo-supporting-tools"
Namespace: "observability"
ReleaseName: "monitoring"
Version: "0.1.18"
Version: "0.1.21"
CreateNamespace: true
PrivilegedNamespace: true
OverrideValues:
Expand Down
4 changes: 3 additions & 1 deletion apps/conf/quality-trace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ RepoName: "quality-trace"
RepoURL: "https://intelops.github.io/quality-trace"
Namespace: "quality-trace"
ReleaseName: "quality-trace"
Version: "1.0.2"
Version: "1.0.5"
CreateNamespace: true
APIEndpoint: https://quality-trace.{{.DomainName}}
OverrideValues:
DomainName: "{{.DomainName}}"
qtSecretName: "{{ .qtSecretName }}"
postgresSecretName: "{{ .postgresSecretName }}"
2 changes: 1 addition & 1 deletion apps/conf/values/kubviz-agent_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ container_bridge:
hosts:
- "containerbridge.{{.DomainName}}"
kuberhealthy:
enabled: true
enabled: false
clusterName: "capten-controlplane"
resources:
limits:
Expand Down
13 changes: 13 additions & 0 deletions apps/conf/values/quality-trace_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@ otelCollector:
endpoint: quality-trace.quality-trace.svc.cluster.local:4317
otlp/signoz:
endpoint: signoz-otel-collector.observability.svc.cluster.local:4317
postgresql:
enabled: false
externalPostgresql:
host: postgresql.platform.svc.cluster.local
existingSecret:
name: "{{ .postgresSecretName }}"
passwordKey: admin-password
qualitytrace:
database: "tracetest"
username: "tracetest"
existingSecret:
name: "{{ .qtSecretName }}"
passwordKey: password
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
Expand Down
32 changes: 24 additions & 8 deletions pkg/agent/store_cred.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"encoding/pem"
"fmt"


random "math/rand"
"os"
"path/filepath"
Expand Down Expand Up @@ -49,6 +48,7 @@ var (

postgresSecretNameVar = "postgresSecretName"
clickhouseSecretNameVar = "clickkhouseSecretName"
qtSecretNameVar = "qtSecretName"
)

func StoreCredentials(captenConfig config.CaptenConfig, appGlobalValues map[string]interface{}) error {
Expand Down Expand Up @@ -341,6 +341,27 @@ func storeCredentials(captenConfig config.CaptenConfig, appGlobalValues map[stri
}
appGlobalValues[clickhouseSecretNameVar] = config.SecretName

case "qt-password":

dbkey := map[string]string{
"username": config.UserName,
}
err := generateAndStoreDBPassword(vaultClient, config, "password", dbkey)
if err != nil {
return fmt.Errorf("error while getting and storing password: %v", err)
}

secretKeyMapping := map[string][]string{
"username": {"username"},
"password": {"password"},
}

err = configureSecret(captenConfig, vaultClient, config, secretKeyMapping, nil, serviceCredentailType)
if err != nil {
return fmt.Errorf("error while configuring secret: %v", err)
}
appGlobalValues[qtSecretNameVar] = config.SecretName

case "temporal-password":
temporaldbuserkey := map[string]string{
"username": config.UserName,
Expand Down Expand Up @@ -382,7 +403,6 @@ func storeCredentials(captenConfig config.CaptenConfig, appGlobalValues map[stri
"password": {"admin-password", "password"},
}


err = configureSecret(captenConfig, vaultClient, postgresconfig, secretKey, secretPropertiesMapping, serviceCredentailType)
if err != nil {
return err
Expand All @@ -408,12 +428,11 @@ func putCredentialInVault(vaultClient vaultcredpb.VaultCredClient, config types.

func configureCosignKeysSecret(captenConfig config.CaptenConfig, vaultClient vaultcredpb.VaultCredClient, config types.CredentialAppConfig) error {


secretKeyMapping := map[string][]string{
"cosign.key": {"cosign.key"},
"cosign.pub": {"cosign.pub"},
}

return configureSecret(captenConfig, vaultClient, config, secretKeyMapping, nil, genericCredentailType)
}

Expand All @@ -423,7 +442,6 @@ func configureNatsSecret(captenConfig config.CaptenConfig, vaultClient vaultcred
secretKeyMapping := map[string][]string{
secretPath: {"token"},
}


return configureSecret(captenConfig, vaultClient, config, secretKeyMapping, nil, genericCredentailType)
}
Expand All @@ -441,8 +459,6 @@ func generatePassword() string {
return string(password)
}



func generateAndStoreDBPassword(vaultClient vaultcredpb.VaultCredClient, config types.CredentialAppConfig, passwordKey string, credential map[string]string) error {
_, err := vaultClient.GetCredential(context.Background(), &vaultcredpb.GetCredentialRequest{
CredentialType: serviceCredentailType,
Expand Down Expand Up @@ -541,7 +557,7 @@ func configureSecret(captenConfig config.CaptenConfig, vaultClient vaultcredpb.V
SecretPathData: secretPathData,
DomainName: "capten.svc.cluster.local:8200",
}

_, err = vaultClient.ConfigureVaultSecret(context.Background(), request)
if err != nil {
return fmt.Errorf("failed to configure vault secret: %v", err)
Expand Down

0 comments on commit 9c8ad0b

Please sign in to comment.