Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable postgres as the backend of vault #87

Merged
merged 2 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion deployments/with-creds/vault/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# Setup

1. Clone [vault-helm](https://github.com/hashicorp/vault-helm) into charts/vault-helm and checkout the version referenced in `requirements.yaml`
1. ~Clone [vault-helm](https://github.com/hashicorp/vault-helm) into charts/vault-helm and checkout the version referenced in `requirements.yaml`~
1. We have a forked version of [vault-helm](https://github.com/concourse/vault-helm). Which has something special for the postgres backend. Please keep using this version until it gets merged back to `vault-helm` chart.
1. `vault-nci` and `vault` are alive at the same time so far. `vault` may decommission in the future after `vault-nci` is all set.
1. How to deploy `vault-nci`
1. `git clone https://github.com/concourse/vault-helm` to the `charts` (hush-house/deployments/with-creds/vault/charts) directory.
1 `ln -s vault vault-nci`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm this seems like a transitory step that has been used during development 🤔

do you plan to have the deployment named after vault-nci or `vault? I guess the former?

(just because if the latter , then we wouldn't really need #102 as the name of the service and namespace wouldn't change)

if you feel like the transition is good (checked via the scripts that ensure that we got the data transferred well), I'd say these steps aren't needed - we should have in this repo just the final configuration that reflect the environment 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've manually back-upped the /vault/data again to make the process more safe if we only keep the vault instance. Anyway the PVC is still attached to vault we could switch back to the FS backend anytime.

I agree.

1. `make creds-vault-nci`
1. `make deploy-vault-nci`. If you get the error `app-name has no deployed releases`, delete the deployment with the command `helm delete --purge vault-nci --tls`, then try again.
1. Verify
1. You should be able to login in to the container with the command `kubectl exec -it -n vault-nci vault-nci-0 /bin/sh`
1. `export VAULT_SKIP_VERIFY=true`
1. `vault status`.
```
Key Value
--- -----
Recovery Seal Type shamir
Initialized true
Sealed false
Total Recovery Shares 5
Threshold 3
Version 1.2.4
Cluster Name vault-cluster-1c5d79f5
Cluster ID 2d6904b1-04ff-xxxx-xxxx-01fc92f15795
HA Enabled false
```
1. `vault list /concourse/main`. You should see those credentials.

2 changes: 2 additions & 0 deletions deployments/with-creds/vault/templates/vault-tls-secret.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ data:
vault.crt: {{ default "" .Values.vault.crt | b64enc | quote }}
vault.key: {{ default "" .Values.vault.key | b64enc | quote }}
{{- end }}
vault.ip: {{ default "" .Values.vault.ip | b64enc | quote }}
vault.secret: {{ default "" .Values.vault.secret | b64enc | quote }}
8 changes: 4 additions & 4 deletions deployments/with-creds/vault/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ vault:
tls_client_ca_file = "/vault/userconfig/vault-server-tls/vault.ca"
}

storage "file" {
path = "/vault/data"
storage "postgresql" {
connection_url = "host=%VAULT_IP% port=5432 user=atc password=%VAULT_SECRET% sslkey=/home/vault/vault-server-tls/vault.key sslcert=/home/vault/vault-server-tls/vault.crt sslrootcert=/home/vault/vault-server-tls/vault.ca dbname=vault"
}

seal "gcpckms" {
key_ring = "vault-helm-unseal-kr"
crypto_key = "vault-helm-unseal-key"
key_ring = "vault-helm-unseal-kr-nci"
crypto_key = "vault-helm-unseal-key-nci"
}
35 changes: 35 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,38 @@ resource "google_kms_crypto_key" "vault-helm-unseal-key" {
prevent_destroy = true
}
}

# gkms key for vault-nci unseal
# Concourse deployment.
#
resource "google_kms_key_ring" "keyring-nci" {
name = "vault-helm-unseal-kr-nci"
location = "global"
}

# crypto key for vault-nci unseal
# Concourse deployment.
#
resource "google_kms_crypto_key" "vault-helm-unseal-key-nci" {
name = "vault-helm-unseal-key-nci"
key_ring = google_kms_key_ring.keyring-nci.self_link

lifecycle {
prevent_destroy = true
}
}

# Creates the CloudSQL Postgres database to be used by the `vault`
# Concourse deployment.
#
module "vault-database" {
source = "./database"

name = "vault"
cpus = "4"
disk_size_gb = "10"
memory_mb = "5120"
region = "${var.region}"
zone = "${var.zone}"
max_connections = "100"
}
25 changes: 25 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,31 @@ output "ci-database-private-key" {
value = "${module.ci-database.private-key}"
}

# vault database outputs
output "vault-database-ip" {
value = "${module.vault-database.ip}"
}

output "vault-database-ca-cert" {
sensitive = true
value = "${module.vault-database.ca-cert}"
}

output "vault-database-password" {
sensitive = true
value = "${module.vault-database.password}"
}

output "vault-database-cert" {
sensitive = true
value = "${module.vault-database.cert}"
}

output "vault-database-private-key" {
sensitive = true
value = "${module.vault-database.private-key}"
}

output "hush-house-address" {
value = "${google_compute_address.hush-house.address}"
}
Expand Down