Installation Using Vault
This guide covers an installation of Testkube utilizing Vault's sidecar injector, but we also support customers utilizing the secrets operator or the CSI provider.
Throughout this guide:
- The examples will assume that your Vault has a v2
key-value secrets engine mounted at
kv/. - The specified Helm values will be from the root of the specified chart.
- Configurations that will need to be replaced with actual values can be
identified by the use of
<>. - Secret values are masked with
*characters.
Dex
Dex is the identity provider for Testkube and its configuration could contain sensitive information.
Start by storing the Dex config at kv/dex/config:
{
"config": "********"
}
The value of the config field would be a Dex
config as shown below, but customized for your needs:
logger:
level: debug
format: json
storage:
type: kubernetes
config:
inCluster: true
issuer: <idp url>
enablePasswordDB: true
staticPasswords:
- email: "admin@testkube.com"
# bcrypt hash of the string "password": $(echo password | htpasswd -BinC 10 admin | cut -d: -f2)
hash: "$2a$10$2b2cU8CPhOTaGrs1HRQuAueS7JTT5ZHsHSzYiFPm1leZck7Mc8T4W"
username: "admin"
userID: "4761be60-0ae4-45e6-a21d-2196e911e010"
Create a Vault policy to allow reading of the Dex config:
path "kv/data/dex/config" {
capabilities = ["read"]
}
Create a service account, vault-dex, then bind it to a Vault role, dex, which
has the above policy attached to it.
In the testkube-enterprise chart configure the following values to properly
inject and consume the secret Dex config:
dex:
serviceAccount:
create: false
name: "vault-dex"
podAnnotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/secret-volume-path: /etc/dex
vault.hashicorp.com/role: 'dex'
vault.hashicorp.com/agent-inject-secret-config.yaml: kv/dex/config
vault.hashicorp.com/agent-inject-template-config.yaml: |
{{`{{- with secret "kv/dex/config" }}{{ .Data.data.config }}{{ end -}}`}}
configSecret:
create: false
use: false
createCustom: false
name: ""
Minio
Minio is the default object storage for Testkube used to store logs and artifacts.
Store the root username and password to kv/minio/credentials:
{
"root_password": "********",
"root_user": "********"
}
Create a Vault policy to allow reading of the Minio credentials:
path "kv/data/minio/credentials" {
capabilities = ["read"]
}
Create a service account, vault-minio, then bind it to a Vault role, minio, which
has the above policy attached to it.
In the testkube-enterprise chart configure the following values to properly
inject and consume the secret Minio credentials:
minio:
auth:
useCredentialsFiles: true
useSecret: false
serviceAccount:
create: false
name: "vault-minio"
automountServiceAccountToken: true
podAnnotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/secret-volume-path: /opt/bitnami/minio/secrets
vault.hashicorp.com/role: 'minio'
vault.hashicorp.com/agent-inject-secret-root-user: kv/minio/credentials
vault.hashicorp.com/agent-inject-secret-root-password: kv/minio/credentials
# NOTE: These templates need to be double escaped as Minio runs this through tpl.
vault.hashicorp.com/agent-inject-template-root-user: |
{{"{{"}}"{{"{{"}}"}}- with secret "kv/minio/credentials" }}{{"{{"}}"{{"{{"}}"}} .Data.data.root_user }}{{"{{"}}"{{"{{"}}"}} end -}}
vault.hashicorp.com/agent-inject-template-root-password: |
{{"{{"}}"{{"{{"}}"}}- with secret "kv/minio/credentials" }}{{"{{"}}"{{"{{"}}"}} .Data.data.root_password }}{{"{{"}}"{{"{{"}}"}} end -}}
Control Plane
The control plane exposes the central API for the agents and the dashboard. The worker service is a part of the control plane which performs long-running tasks such as processing artifacts.
Depending on your needs the control plane might need the following secrets to be injected from a Vault:
- License key
- License file (only for offline licenses)
- Minio credentials
- Private certificate authority (CA) certificate
To keep this guide simple we will have one service account for both components of the control plane (API and worker service) which will need to have access to the Vault secrets, but to enforce the principle of least privilege one could create individual service accounts and policies for each component.
Start by creating a service account, vault-control-plane, for the control
plane. Bind the service account to a Vault role, control_plane.
Online License
Create a secret kv/control-plane/license with the license key:
{
"key": "********",
}
To the control_plane role, add a policy that allows reading the above secret:
path "kv/data/control-plane/license" {
capabilities = ["read"]
}
In the testkube-enterprise chart configure the following values to properly
inject and consume the secret license key:
testkube-cloud-api:
enterpriseLicenseKeyPath: /etc/testkube/secrets/license.key
serviceAccount:
name: vault-control-plane
podAnnotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: 'control_plane'
vault.hashicorp.com/secret-volume-path-license.key: /etc/testkube/secrets
vault.hashicorp.com/agent-inject-secret-license.key: kv/control-plane/license
vault.hashicorp.com/agent-inject-template-license.key: |
{{`{{- with secret "kv/control-plane/license" }}{{ .Data.data.key }}{{ end -}}`}}