Skip to content

Commit

Permalink
Use HashiCorp Vault for Ceilometer deployment
Browse files Browse the repository at this point in the history
This commit will consume the secrets from HashiCorp Vault using
vault-secretes-operator for the Ceilometer deployment.
  • Loading branch information
pratik705 committed Mar 28, 2024
1 parent 873de97 commit c941292
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 11 deletions.
91 changes: 80 additions & 11 deletions docs/openstack-ceilometer.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,89 @@
# Deploy Ceilometer

## 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/ceilometer/` 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=ceilometer
```

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

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

### Create the secrets

- Ceilometer-keystone-admin-password:

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

- Ceilometer-keystone-test-password:

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

- Ceilometer-rabbitmq-password:

``` shell
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv put -mount=osh/ceilometer ceilometer-rabbitmq-password \
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/ceilometer
kubectl exec --stdin=true --tty=true vault-0 -n vault -- \
vault kv get -mount=osh/ceilometer ceilometer-keystone-admin-password
```

## Install Ceilometer

- 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 Ceilometer installation:

``` shell
kubectl apply -k /opt/genestack/kustomize/ceilometer/base/vault/
```

- Validate whether the required Kubernetes secrets from Vault are populated:

``` shell
kubectl --namespace openstack create secret generic ceilometer-keystone-admin-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 ceilometer-keystone-test-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 ceilometer-rabbitmq-password \
--type Opaque \
--from-literal=password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-32};echo;)"
kubectl get secrets -n openstack
```

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

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

# mount path
mount: 'osh/ceilometer'

# path of the secret
path: ceilometer-keystone-admin-password

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

# static secret refresh interval
refreshAfter: 30s

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

# mount path
mount: 'osh/ceilometer'

# path of the secret
path: ceilometer-keystone-test-password

# dest k8s secret
destination:
name: ceilometer-keystone-test-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/ceilometer/base/vault/ceilometer-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: ceilometer-rabbitmq-password
namespace: openstack
spec:
type: kv-v2

# mount path
mount: 'osh/ceilometer'

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

# dest k8s secret
destination:
name: ceilometer-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/ceilometer/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
- ceilometer-keystone-admin-password.yaml
- ceilometer-keystone-test-password.yaml
- ceilometer-rabbitmq-password.yaml
14 changes: 14 additions & 0 deletions kustomize/ceilometer/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/ceilometer/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"

0 comments on commit c941292

Please sign in to comment.