Project: external-secrets (Provisioning / Security & Compliance)
File: ibm-secrets-manager.md

External Secrets Operator integrates with for secret management. We support API key and trusted profile container authentication for this provider. To generate your key (for test purposes we are going to generate from your user), first got to your (Access IAM) page: On the left, click "API Keys", then click on "Create" Pick a name and description for your key: You have created a key. Press the eyeball to show the key. Copy or save it because keys can't be displayed or downloaded twice. Create a secret containing your apiKey: ```shell kubectl create secret generic ibm-secret --from-literal=apiKey='APIKEYVALUE' ``` To create the trusted profile, first got to your (Access IAM) page: On the left, click "Access groups": Pick a name and description for your group: Click on "Access", and then on "Assign": Click on "Assign Access", select "IAM services", and pick "Secrets Manager" from the pick-list: Scope to "All resources" or "Resources based on selected attributes": Select the "SecretsReader" service access policy: Click "Add" and "Assign" to save the access group. Next, on the left, click "Trusted profiles": Press "Create" and pick a name and description for your profile: Scope the profile's access. The compute service type will be "Red Hat OpenShift on IBM Cloud". Additional restriction can be configured based on cloud or cluster metadata, or if "Specific resources" is selected, restriction to a specific cluster. Click "Add" next to the previously created access group and then "Create", to associate the necessary service permissions. To use the container-based authentication, it is necessary to map the API server `serviceAccountToken` auth token to the "external-secrets" and "external-secrets-webhook" deployment descriptors. Example below: ```yaml {% include 'ibm-container-auth-volume.yaml' %} ``` Be sure the `ibm` provider is listed in the `Kind=SecretStore` ```yaml {% include 'ibm-secret-store.yaml' %} ``` NOTE: In case of a `ClusterSecretStore`, Be sure to provide `namespace` in `secretApiKeySecretRef` with the namespace where the secret resides. NOTE: Only `secretApiKeySecretRef` or `containerAuth` should be specified, depending on authentication method being used. To find your `serviceURL`, under your Secrets Manager resource, go to "Endpoints" on the left. See here for a list of . We support the following secret types of : `arbitrary` `username_password` `iam_credentials` `service_credentials` `imported_cert` `public_cert` `private_cert` `kv` To define the type of secret you would like to sync you need to prefix the secret id with the desired type. If the secret type is not specified it is defaulted to `arbitrary`: ```yaml {% include

%} ``` The behavior for the different secret types is as following: `remoteRef` retrieves a string from secrets manager and sets it for specified `secretKey` `dataFrom` retrieves a string from secrets manager and tries to parse it as JSON object setting the key:values pairs in resulting Kubernetes secret if successful `remoteRef` requires a `property` to be set for either `username` or `password` to retrieve respective fields from the secrets manager secret and set in specified `secretKey` `dataFrom` retrieves both `username` and `password` fields from the secrets manager secret and sets appropriate key:value pairs in the resulting Kubernetes secret `remoteRef` retrieves an apikey from secrets manager and sets it for specified `secretKey` `dataFrom` retrieves an apikey from secrets manager and sets it for the `apikey` Kubernetes secret key `remoteRef` retrieves the credentials object from secrets manager and sets it for specified `secretKey` `dataFrom` retrieves the credential object as a map from secrets manager and sets appropriate key:value pairs in the resulting Kubernetes secret `remoteRef` requires a `property` to be set for either `certificate`, `private_key` or `intermediate` to retrieve respective fields from the secrets manager secret and set in specified `secretKey` `dataFrom` retrieves all `certificate`, `private_key` and `intermediate` fields from the secrets manager secret and sets appropriate key:value pairs in the resulting Kubernetes secret An optional `property` field can be set to `remoteRef` to select requested key from the KV secret. If not set, the entire secret will be returned `dataFrom` retrieves a string from secrets manager and tries to parse it as JSON object setting the key:values pairs in resulting Kubernetes secret if successful. It could be either used with the methods `Extract` to extract multiple key/value pairs from one secret (with optional `property` field being supported as well) `Find` to find secrets based on tags or regular expressions and allows finding multiple external secrets and map them into a single Kubernetes secret ```json { "key1": "val1", "key2": "val2", "key3": { "keyA": "valA", "keyB": "valB" }, "special.key": "special-content" } ``` ```yaml data: secretKey: key3_keyB remoteRef: key: 'kv/aaaaa-bbbb-cccc-dddd-eeeeee' property: 'key3.keyB' secretKey: special_key remoteRef: key: 'kv/aaaaa-bbbb-cccc-dddd-eeeeee' property: 'special.key' secretKey: key_all remoteRef: key: 'kv/aaaaa-bbbb-cccc-dddd-eeeeee' ``` ```yaml dataFrom: extract: key: 'kv/fffff-gggg-iiii-dddd-eeeeee' #mandatory decodingStrategy: Base64 #optional ``` ```yaml dataFrom: find: name: #matches any secret name ending in foo-bar regexp: "key" #assumption that secrets are stored like /comp/key1, key2/trigger, and comp/trigger/keygen within the secret manager find: tags: #matches any secrets with the following metadata labels environment: "dev" application: "BFF" ``` results in ```yaml data: key3_keyB: ... #valB special_key: ... #special-content key_all: ... #{"key1":"val1","key2":"val2", ..."special.key":"special-content"} keyA: ... #1st key-value pair from JSON object keyB: ... #2nd key-value pair from JSON object keyC: ... #3rd key-value pair from JSON object compkey1: ... #secret value for /comp/key1 key2_trigger: ... #secret value for key2/trigger comptrigger_keygen: ... #secret value for comp/trigger/keygen bffA: ... bffB: ... bffC: ... ``` To create a kubernetes secret from the IBM Secrets Manager, a `Kind=ExternalSecret` is needed. Below example creates a kubernetes secret based on ID of the secret in Secrets Manager. ```yaml {% include 'ibm-external-secret.yaml' %} ``` Alternatively, the secret name along with its secret group name can be specified instead of secret ID to fetch the secret. ```yaml {% include 'ibm-external-secret-by-name.yaml' %} ``` The operator will fetch the IBM Secret Manager secret and inject it as a `Kind=Secret` ``` kubectl get secret secret-to-be-created -n <namespace> | -o jsonpath='{.data.test}' | base64 -d ``` ESO can add metadata while creating or updating a Kubernetes secret to be reflected in its labels or annotations. The metadata could be any of the fields that are supported and returned in the response by IBM Secrets Manager. In order for the