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

Use HashiCorp Vault for OSH deployment #151

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
87e18cc
Use HashiCorp Vault for MariaDB and Keystone deployment
pratik705 Mar 13, 2024
2ac53fe
Merge branch 'main' into vault-integration
pratik705 Mar 22, 2024
5a4b807
Use HashiCorp Vault for Glance deployment
pratik705 Mar 23, 2024
1e063ca
Merge branch 'main' into vault-integration
pratik705 Mar 24, 2024
f17de43
Use HashiCorp Vault to fetch password required by MariaDB MaxScale
pratik705 Mar 24, 2024
48f89a6
Fix rootPasswordSecretKeyRef to point correct values from Vault
pratik705 Mar 24, 2024
08d9f92
Fix typo in vault/glance-admin and update mariadb-root-password vault…
pratik705 Mar 25, 2024
d5e932e
Use HashiCorp Vault for Heat deployment
pratik705 Mar 25, 2024
7eab299
Add username to the vault for Keystone and Glance Rabbitmq secret
pratik705 Mar 26, 2024
7b19a18
Revert change in the mariadb secret naming convention
pratik705 Mar 26, 2024
3c41fa6
Fix typo is vault secret path
pratik705 Mar 26, 2024
053004b
Use HashiCorp Vault for Cinder deployment
pratik705 Mar 26, 2024
39e129d
Use HashiCorp Vault for Compute Kit deployment
pratik705 Mar 26, 2024
d6e56ef
Use HashiCorp Vault for Horizon deployment
pratik705 Mar 26, 2024
c6f604d
Use HashiCorp Vault for Skyline deployment
pratik705 Mar 27, 2024
58541f7
Use HashiCorp Vault for Octavia deployment
pratik705 Mar 28, 2024
873de97
Use HashiCorp Vault for Gnocchi deployment
pratik705 Mar 28, 2024
c941292
Use HashiCorp Vault for Ceilometer deployment
pratik705 Mar 28, 2024
b74daee
Use HashiCorp Vault for PostgreSQL deployment
pratik705 Mar 28, 2024
bd1139c
Fix mariadb vaultstaticsecret name
pratik705 Mar 28, 2024
35b025f
Add example to create local user in vault
pratik705 Mar 29, 2024
21d109e
Merge branch 'main' into vault-integration
pratik705 Apr 2, 2024
33a6fd0
Update skyline-apiserver-secrets secret
pratik705 Apr 2, 2024
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
69 changes: 59 additions & 10 deletions docs/infrastructure-mariadb.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# Deploy the MariaDB Operator and a Galera Cluster

## Create secret

``` shell
kubectl --namespace openstack \
create secret generic mariadb \
--type Opaque \
--from-literal=root-password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)" \
--from-literal=password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)"
```

## Deploy the mariadb operator

If you've changed your k8s cluster name from the default cluster.local, edit `clusterName` in `/opt/genestack/kustomize/mariadb-operator/kustomization.yaml` prior to deploying the mariadb operator.
Expand All @@ -29,6 +19,65 @@ kubectl --namespace mariadb-system get pods -w

## Deploy the MariaDB Cluster

## Pre-requsites:

- Vault should be installed by following the instructions in [vault documentation](https://docs.rackspacecloud.com/vault/)
- User has access to `osh/mariadb/` path in the Vault

## Create secrets in the vault:

### Login to the vault:
cloudnull marked this conversation as resolved.
Show resolved Hide resolved

``` shell
kubectl exec -it vault-0 -n vault -- \
vault login -method userpass username=mariadb
```

### List the existing secrets from `osh/mariadb/`:

``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv list osh/mariadb
```

### Create the secrets:

- Mariadb root-password:
``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv put -mount=osh/mariadb mariadb-root-password root-password=$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-64};echo;)
```

### Validate the secrets:

``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv list osh/mariadb
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv get -mount=osh/mariadb mariadb-root-password
```

## Install mariadb cluster:

- Ensure that the `vault-ca-secret` Kubernetes Secret exists in the OpenStack namespace containing the Vault CA certificate:
```shell
kubectl get secret vault-ca-secret -o yaml -n openstack
```

- If it is absent, create one using the following command:
```shell
kubectl create secret generic vault-ca-secret \
--from-literal=ca.crt="$(kubectl get secret vault-tls-secret \
-o jsonpath='{.data.ca\.crt}' -n vault | base64 -d -)" -n openstack
```

- Deploy the necessary Vault resources to create Kubernetes secrets required by the mariadb installation:
``` shell
kubectl apply -k /opt/genestack/kustomize/mariadb-cluster/base/vault
```

### Deploy mariadb-cluster

``` shell
kubectl --namespace openstack apply -k /opt/genestack/kustomize/mariadb-cluster/base
```
Expand Down
88 changes: 69 additions & 19 deletions docs/openstack-keystone.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,79 @@

[![asciicast](https://asciinema.org/a/629802.svg)](https://asciinema.org/a/629802)

## Create secrets.
## Pre-requsites:

- Vault should be installed by following the instructions in [vault documentation](https://docs.rackspacecloud.com/vault/)
- User has access to `osh/keystone/` path in the Vault

## Create secrets in the vault:

### Login to the vault:

``` shell
kubectl exec -it vault-0 -n vault -- \
vault login -method userpass username=keystone
```

### List the existing secrets from `osh/keystone/`:

``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv list osh/keystone
```

### Create the secrets:

- Keystone RabbitMQ Password:
``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv put -mount=osh/keystone keystone-rabbitmq-password \
password=$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-64};echo;)
```

- Keystone Database Password:
``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv put -mount=osh/keystone keystone-db-password \
password=$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)
```

- Keystone Admin Password:
``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv put -mount=osh/keystone keystone-admin \
password=$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)
```

### Validate the secrets:

``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv list osh/keystone
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv get -mount=osh/keystone keystone-admin
```

## Install Keystone

- Ensure that the `vault-ca-secret` Kubernetes Secret exists in the OpenStack namespace containing the Vault CA certificate:
```shell
kubectl get secret vault-ca-secret -o yaml -n openstack
```

- If it is absent, create one using the following command:
``` shell
kubectl create secret generic vault-ca-secret \
--from-literal=ca.crt="$(kubectl get secret vault-tls-secret \
-o jsonpath='{.data.ca\.crt}' -n vault | base64 -d -)" -n openstack
```

- Deploy the necessary Vault resources to create Kubernetes secrets required by the Keystone installation:
``` shell
kubectl --namespace openstack \
create secret generic keystone-rabbitmq-password \
--type Opaque \
--from-literal=username="keystone" \
--from-literal=password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-64};echo;)"
kubectl --namespace openstack \
create secret generic keystone-db-password \
--type Opaque \
--from-literal=password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)"
kubectl --namespace openstack \
create secret generic keystone-admin \
--type Opaque \
--from-literal=password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)"
kubectl --namespace openstack \
create secret generic keystone-credential-keys \
--type Opaque \
--from-literal=password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)"
kubectl apply -k /opt/genestack/kustomize/keystone/base/vault/
```

## Run the package deployment
### Deploy Keystone helm chart

``` shell
cd /opt/genestack/submodules/openstack-helm
Expand Down
24 changes: 24 additions & 0 deletions kustomize/keystone/base/vault/keystone-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultStaticSecret
metadata:
name: keystone-admin
namespace: openstack
spec:
type: kv-v2

# mount path
mount: 'osh/keystone'

# path of the secret
path: keystone-admin

# dest k8s secret
destination:
name: keystone-admin
create: true

# static secret refresh interval
refreshAfter: 30s

# Name of the CRD to authenticate to Vault
vaultAuthRef: vault-auth
24 changes: 24 additions & 0 deletions kustomize/keystone/base/vault/keystone-db-password.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultStaticSecret
metadata:
name: keystone-db-password
namespace: openstack
spec:
type: kv-v2

# mount path
mount: 'osh/keystone'

# path of the secret
path: keystone-db-password

# dest k8s secret
destination:
name: keystone-db-password
create: true

# static secret refresh interval
refreshAfter: 30s

# Name of the CRD to authenticate to Vault
vaultAuthRef: vault-auth
24 changes: 24 additions & 0 deletions kustomize/keystone/base/vault/keystone-rabbitmq-password.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultStaticSecret
metadata:
name: keystone-rabbitmq-password
namespace: openstack
spec:
type: kv-v2

# mount path
mount: 'osh/keystone'

# path of the secret
path: keystone-rabbitmq-password

# dest k8s secret
destination:
name: keystone-rabbitmq-password
create: true

# static secret refresh interval
refreshAfter: 30s

# Name of the CRD to authenticate to Vault
vaultAuthRef: vault-auth
7 changes: 7 additions & 0 deletions kustomize/keystone/base/vault/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace: openstack
resources:
- vaultauth.yaml
- vaultconnection.yaml
- keystone-admin.yaml
- keystone-db-password.yaml
- keystone-rabbitmq-password.yaml
14 changes: 14 additions & 0 deletions kustomize/keystone/base/vault/vaultauth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultAuth
metadata:
name: vault-auth
namespace: openstack
spec:
method: kubernetes
mount: genestack
kubernetes:
role: osh
serviceAccount: default
audiences:
- vault
vaultConnectionRef: vault-connection
18 changes: 18 additions & 0 deletions kustomize/keystone/base/vault/vaultconnection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultConnection
metadata:
namespace: openstack
name: vault-connection
spec:
# required configuration
# address to the Vault server.
address: https://vault.vault.svc.cluster.local:8200
# optional configuration
# HTTP headers to be included in all Vault requests.
# headers: []
# TLS server name to use as the SNI host for TLS connections.
# tlsServerName: ""
# skip TLS verification for TLS connections to Vault.
skipTLSVerify: false
# the trusted PEM encoded CA certificate chain stored in a Kubernetes Secret
caCertSecretRef: "vault-ca-secret"
2 changes: 1 addition & 1 deletion kustomize/mariadb-cluster/base/mariadb-galera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
spec:
rootPasswordSecretKeyRef:
name: mariadb
key: root-password
Copy link
Collaborator

Choose a reason for hiding this comment

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

Changing this key will break all the service deploy? Example: glance, neutron, etc will do something like:

--set endpoints.oslo_db.auth.admin.password="$(kubectl --namespace openstack get secret mariadb -o jsonpath='{.data.root-password}' | base64 -d)" \

which will look for mariadb secret with root-password. Will this work ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as per my understanding, if we update the password in the vault then its required to update helm charts to populate the correct password in the openstack services. I haven't validated it though.

Copy link
Contributor

Choose a reason for hiding this comment

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

For infra services I don't think we can change the password references; most of them are not goverened by helm.

key: mariadb-root-password
username: mariadb
database: mariadb

Expand Down
5 changes: 5 additions & 0 deletions kustomize/mariadb-cluster/base/vault/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace: openstack
resources:
- vaultauth.yaml
- vaultconnection.yaml
- mariadb-root-password.yaml
24 changes: 24 additions & 0 deletions kustomize/mariadb-cluster/base/vault/mariadb-root-password.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultStaticSecret
metadata:
name: mariadb-root-password
namespace: openstack
spec:
type: kv-v2

# mount path
mount: 'osh/mariadb'

# path of the secret
path: mariadb-root-password

# dest k8s secret
destination:
name: mariadb-root-password
create: true

# static secret refresh interval
refreshAfter: 30s

# Name of the CRD to authenticate to Vault
vaultAuthRef: vault-auth
14 changes: 14 additions & 0 deletions kustomize/mariadb-cluster/base/vault/vaultauth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultAuth
metadata:
name: vault-auth
namespace: openstack
spec:
method: kubernetes
mount: genestack
kubernetes:
role: osh
serviceAccount: default
audiences:
- vault
vaultConnectionRef: vault-connection
18 changes: 18 additions & 0 deletions kustomize/mariadb-cluster/base/vault/vaultconnection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultConnection
metadata:
namespace: openstack
name: vault-connection
spec:
# required configuration
# address to the Vault server.
address: https://vault.vault.svc.cluster.local:8200
# optional configuration
# HTTP headers to be included in all Vault requests.
# headers: []
# TLS server name to use as the SNI host for TLS connections.
# tlsServerName: ""
# skip TLS verification for TLS connections to Vault.
skipTLSVerify: false
# the trusted PEM encoded CA certificate chain stored in a Kubernetes Secret
caCertSecretRef: "vault-ca-secret"
Loading