|
| 1 | +--- |
| 2 | +title: Secret management |
| 3 | +weight: 25 |
| 4 | +aliases: /rhoso-gitops/secret-management/ |
| 5 | +--- |
| 6 | + |
| 7 | +:toc: |
| 8 | +:_content-type: ASSEMBLY |
| 9 | +include::modules/comm-attributes.adoc[] |
| 10 | +:imagesdir: /images |
| 11 | + |
| 12 | +[id="rhoso-gitops-secret-management"] |
| 13 | += Secret management for the {rhoso-gitops-pattern} |
| 14 | + |
| 15 | +The {rhoso-gitops-pattern} requires secrets for OpenStack service passwords, SSH |
| 16 | +key pairs, bare-metal controller credentials, and container registry |
| 17 | +authentication. You can provide these secrets in two ways depending on whether a |
| 18 | +secure storage backend is available. The two approaches can also be combined: for |
| 19 | +example, store shared credentials (registry, subscription) in the backend while |
| 20 | +injecting service-specific passwords as `bootstrap_secrets`, or use |
| 21 | +`onMissingValue: generate` to let the backend generate passwords at deployment |
| 22 | +time. |
| 23 | + |
| 24 | +For the canonical list of required secrets, see |
| 25 | +link:https://docs.redhat.com/en/documentation/red_hat_openstack_services_on_openshift/latest/html/deploying_red_hat_openstack_services_on_openshift/assembly_preparing-rhocp-for-rhoso#proc_providing-secure-access-to-the-RHOSO-services_preparing[Providing secure access to the {rh-rhoso-short} services] |
| 26 | +in the {rh-rhoso} documentation. |
| 27 | + |
| 28 | +[id="rhoso-secrets-approaches"] |
| 29 | +== Choosing a secrets approach |
| 30 | + |
| 31 | +Review the following approaches before you deploy the pattern. |
| 32 | + |
| 33 | +[id="rhoso-secrets-vault-eso"] |
| 34 | +=== Secure storage backend and {eso-op} |
| 35 | + |
| 36 | +image::rhoso-gitops/rhoso-gitops-secrets-vault-eso.png[Secure storage backend and {eso-op} secrets flow] |
| 37 | + |
| 38 | +This is the recommended approach for production deployments. You store secrets |
| 39 | +in a secure storage backend (for example {hashicorp-vault}, AWS Secrets Manager, |
| 40 | +or any |
| 41 | +link:https://external-secrets.io/latest/provider/aws-secrets-manager/[provider supported by the {eso-op}]). |
| 42 | +`ExternalSecret` resources project these secrets into the `openstack` namespace |
| 43 | +through a `SecretStore`. |
| 44 | + |
| 45 | +The framework does not install the storage backend or the {eso-op} |
| 46 | +automatically. You must include the {eso-op} through the `operator-dependencies` |
| 47 | +Argo CD application by using a Kustomize component from the upstream |
| 48 | +link:https://github.com/openstack-k8s-operators/gitops/tree/main/components/secrets[secrets components]. |
| 49 | +The `openstack-secrets` Argo CD application deploys the `SecretStore` and |
| 50 | +`ExternalSecret` resources that pull secrets from the backend. |
| 51 | + |
| 52 | +This approach uses the following configuration: |
| 53 | + |
| 54 | +* The bootstrap secret (for example `vault-approle-secret-id`) is defined as a |
| 55 | + `bootstrap_secret`. The framework injects it into the `openstack` namespace |
| 56 | + during `make install` so that the {eso-op} `SecretStore` can authenticate |
| 57 | + against the backend. |
| 58 | +* All other secrets are defined under the `secrets:` section of the |
| 59 | + `values-secret.yaml` file. The framework loads them into the backend during |
| 60 | + `make load-secrets`. |
| 61 | +* `ExternalSecret` resources, deployed by the `openstack-secrets` Argo CD |
| 62 | + application, fetch secrets from the backend and create the corresponding |
| 63 | + Kubernetes `Secret` objects. |
| 64 | + |
| 65 | +[id="rhoso-secrets-direct-injection"] |
| 66 | +=== Direct injection without an external store |
| 67 | + |
| 68 | +image::rhoso-gitops/rhoso-gitops-secrets-direct.png[Direct injection secrets flow] |
| 69 | + |
| 70 | +Use this approach when you do not have a secure storage backend. All secrets are |
| 71 | +defined as `bootstrap_secrets` in the `values-secret.yaml` file. The framework |
| 72 | +injects them as Kubernetes `Secret` objects during `make install`. No storage |
| 73 | +backend or {eso-op} is installed. |
| 74 | + |
| 75 | +When you use this approach, configure the following: |
| 76 | + |
| 77 | +* Set `global.secretStore.backend` to `"none"` in `values-global.yaml`. |
| 78 | +* Define every required secret under the `bootstrap_secrets:` section. |
| 79 | +* Leave the `secrets:` section empty. |
| 80 | + |
| 81 | +[id="rhoso-required-secrets"] |
| 82 | +== Required secrets |
| 83 | + |
| 84 | +The {rhoso-gitops-pattern} requires the following secrets in the `openstack` |
| 85 | +namespace. The `values-secret.yaml.template` file in the pattern repository |
| 86 | +contains placeholder entries for each secret. |
| 87 | + |
| 88 | +[cols="2,3,3",options="header"] |
| 89 | +|=== |
| 90 | +| Secret name | Key fields | Purpose |
| 91 | + |
| 92 | +| `vault-approle-secret-id` |
| 93 | +| `id` |
| 94 | +| Authentication credential for the {eso-op} `SecretStore` to connect to the |
| 95 | + secure storage backend. Required only with the backend + {eso-op} approach. |
| 96 | + |
| 97 | +| `osp-secret` |
| 98 | +| Multiple service and database password fields |
| 99 | +| OpenStack service passwords (for example `AdminPassword`, |
| 100 | + `KeystoneDatabasePassword`, `NeutronPassword`). See the |
| 101 | + link:https://docs.redhat.com/en/documentation/red_hat_openstack_services_on_openshift/latest/html/deploying_red_hat_openstack_services_on_openshift/assembly_preparing-rhocp-for-rhoso#proc_providing-secure-access-to-the-RHOSO-services_preparing[{rh-rhoso} documentation] |
| 102 | + for the complete list. |
| 103 | + |
| 104 | +| `baremetalset-password-secret` |
| 105 | +| `NodeRootPassword` |
| 106 | +| Root password for bare-metal data plane nodes. |
| 107 | + |
| 108 | +| `dataplane-ansible-ssh-private-key-secret` |
| 109 | +| `ssh-privatekey`, `ssh-publickey`, `authorized_keys` |
| 110 | +| SSH key pair for Ansible provisioning of data plane nodes. |
| 111 | + |
| 112 | +| `libvirt-secret` |
| 113 | +| `LibvirtPassword` |
| 114 | +| Libvirt authentication password. |
| 115 | + |
| 116 | +| `nova-migration-ssh-key` |
| 117 | +| `ssh-privatekey`, `ssh-publickey` |
| 118 | +| SSH key pair for Nova live migration. |
| 119 | + |
| 120 | +| `redfish-bmc-secret-auth` |
| 121 | +| `username`, `password` |
| 122 | +| Redfish BMC credentials for bare-metal node management. |
| 123 | + |
| 124 | +| `redhat-registry` |
| 125 | +| `edpm_container_registry_logins` |
| 126 | +| Container registry credentials for EDPM nodes (JSON format). |
| 127 | + |
| 128 | +| `subscription-manager` |
| 129 | +| `username`, `password`, `rhc_auth` |
| 130 | +| {redhat} Subscription Manager credentials for EDPM nodes. |
| 131 | +|=== |
| 132 | + |
| 133 | +[id="rhoso-configuring-vault-eso"] |
| 134 | +== Configuring secrets with a secure storage backend |
| 135 | + |
| 136 | +.Prerequisites |
| 137 | + |
| 138 | +* You have forked and cloned the |
| 139 | + link:https://github.com/validatedpatterns-sandbox/rhoso-gitops[rhoso-gitops] |
| 140 | + repository. |
| 141 | +* You have deployed a secure storage backend and have an authentication |
| 142 | + credential (for example an AppRole secret ID) available. |
| 143 | +* You have a Git repository with Kustomize overlays that define the |
| 144 | + `SecretStore` and `ExternalSecret` resources for the `openstack` namespace. |
| 145 | +* You have the OpenStack service passwords, SSH key pairs, BMC credentials, and |
| 146 | + registry credentials listed in the |
| 147 | + link:https://docs.redhat.com/en/documentation/red_hat_openstack_services_on_openshift/latest/html/deploying_red_hat_openstack_services_on_openshift/assembly_preparing-rhocp-for-rhoso#proc_providing-secure-access-to-the-RHOSO-services_preparing[{rh-rhoso} documentation]. |
| 148 | + |
| 149 | +.Procedure |
| 150 | + |
| 151 | +. Include the {eso-op} in the `operator-dependencies` application by adding a |
| 152 | + Kustomize component in `overrides/values-rhoso-gitops.yaml`. The following |
| 153 | + example uses the {redhat} build of the {eso-op}: |
| 154 | ++ |
| 155 | +[source,yaml,subs="+quotes"] |
| 156 | +---- |
| 157 | +applications: |
| 158 | + operator-dependencies: |
| 159 | + kustomize: |
| 160 | + components: |
| 161 | + - "https://github.com/openstack-k8s-operators/gitops/components/secrets/external-secrets-operator/redhat?ref=__<gitops-tag>__" |
| 162 | +---- |
| 163 | ++ |
| 164 | +For other {eso-op} variants, see the upstream |
| 165 | +link:https://github.com/openstack-k8s-operators/gitops/tree/main/components/secrets[components/secrets] |
| 166 | +README. |
| 167 | + |
| 168 | +. Enable the `openstack-secrets` application in the same overrides file. This |
| 169 | + application deploys the `SecretStore` and `ExternalSecret` resources that pull |
| 170 | + secrets from the backend: |
| 171 | ++ |
| 172 | +[source,yaml,subs="+quotes"] |
| 173 | +---- |
| 174 | + openstack-secrets: |
| 175 | + enabled: true |
| 176 | + repoURL: "https://github.com/__<your_organization>__/__<your-gitops-overlay>__.git" |
| 177 | + path: "__<path-to-eso-overlay>__" |
| 178 | + targetRevision: "__<branch-or-tag>__" |
| 179 | +---- |
| 180 | + |
| 181 | +. Extract the authentication credential from your secure storage backend (for |
| 182 | + example an AppRole secret ID) and save it to a file: |
| 183 | ++ |
| 184 | +[source,terminal,subs="+quotes"] |
| 185 | +---- |
| 186 | +$ echo -n "__<approle-secret-id>__" > ~/vault-approle-secret-id |
| 187 | +---- |
| 188 | + |
| 189 | +. Create a `values-secret.yaml` file based on the template. Include the |
| 190 | + bootstrap secret for the backend credential and define all other secrets under |
| 191 | + the `secrets:` section for backend injection: |
| 192 | ++ |
| 193 | +[source,yaml,subs="+quotes"] |
| 194 | +---- |
| 195 | +version: "2.0" |
| 196 | +
|
| 197 | +bootstrap_secrets: |
| 198 | + - name: vault-approle-secret-id |
| 199 | + targetNamespaces: |
| 200 | + - openstack |
| 201 | + fields: |
| 202 | + - name: id |
| 203 | + path: ~/vault-approle-secret-id |
| 204 | + onMissingValue: error |
| 205 | +
|
| 206 | +secrets: |
| 207 | + - name: osp-secret |
| 208 | + fields: |
| 209 | + - name: AdminPassword |
| 210 | + value: "__<admin-password>__" |
| 211 | + # ... remaining service password fields |
| 212 | + # ... remaining secrets |
| 213 | +---- |
| 214 | + |
| 215 | +. Install the pattern: |
| 216 | ++ |
| 217 | +[source,terminal] |
| 218 | +---- |
| 219 | +$ ./pattern.sh make install |
| 220 | +---- |
| 221 | + |
| 222 | +. Verify that the `ExternalSecret` resources are synchronized: |
| 223 | ++ |
| 224 | +[source,terminal] |
| 225 | +---- |
| 226 | +$ oc get externalsecrets -n openstack |
| 227 | +---- |
| 228 | ++ |
| 229 | +Each `ExternalSecret` shows a `SecretSynced` status when the {eso-op} has |
| 230 | +created the corresponding Kubernetes `Secret`. |
| 231 | + |
| 232 | +[id="rhoso-configuring-direct-injection"] |
| 233 | +== Configuring secrets with direct injection |
| 234 | + |
| 235 | +.Prerequisites |
| 236 | + |
| 237 | +* You have forked and cloned the |
| 238 | + link:https://github.com/validatedpatterns-sandbox/rhoso-gitops[rhoso-gitops] |
| 239 | + repository. |
| 240 | +* You have the OpenStack service passwords, SSH key pairs, BMC credentials, and |
| 241 | + registry credentials listed in the |
| 242 | + link:https://docs.redhat.com/en/documentation/red_hat_openstack_services_on_openshift/latest/html/deploying_red_hat_openstack_services_on_openshift/assembly_preparing-rhocp-for-rhoso#proc_providing-secure-access-to-the-RHOSO-services_preparing[{rh-rhoso} documentation]. |
| 243 | + |
| 244 | +.Procedure |
| 245 | + |
| 246 | +. Set the secret store backend to `none` in `values-global.yaml`: |
| 247 | ++ |
| 248 | +[source,yaml] |
| 249 | +---- |
| 250 | +global: |
| 251 | + secretStore: |
| 252 | + backend: "none" |
| 253 | +---- |
| 254 | + |
| 255 | +. Copy the secrets template and edit it: |
| 256 | ++ |
| 257 | +[source,terminal,subs="+quotes"] |
| 258 | +---- |
| 259 | +$ cp values-secret.yaml.template ~/values-secret-rhoso-gitops.yaml |
| 260 | +---- |
| 261 | ++ |
| 262 | +Replace every `CHANGEME_*` placeholder with the actual value. For SSH key pairs, |
| 263 | +set the `path:` field to point at your local key files. Secret values must be in |
| 264 | +plain text, not base64-encoded. |
| 265 | + |
| 266 | +. Install the pattern: |
| 267 | ++ |
| 268 | +[source,terminal] |
| 269 | +---- |
| 270 | +$ ./pattern.sh make install |
| 271 | +---- |
| 272 | + |
| 273 | +. Verify that the secrets exist in the `openstack` namespace: |
| 274 | ++ |
| 275 | +[source,terminal] |
| 276 | +---- |
| 277 | +$ oc get secrets -n openstack |
| 278 | +---- |
0 commit comments