> [!CAUTION]
> You are currently viewing version 1.4 of the Apigee hybrid documentation. **This version is end of life.** You should upgrade to a newer version. For more information, see [Supported versions](https://docs.cloud.google.com/apigee/docs/hybrid/supported-platforms.md.txt#supported-versions).

<button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">Version 1.4 (unsupported)</button>

- Supported versions:
- [v1.17 (latest)](https://docs.cloud.google.com/apigee/docs/hybrid/v1.17/2-5-install-service-accounts.html)
- [v1.16](https://docs.cloud.google.com/apigee/docs/hybrid/v1.16/2-5-install-service-accounts.html)
- [v1.15](https://docs.cloud.google.com/apigee/docs/hybrid/v1.15/2-5-install-service-accounts.html)
- [v1.14](https://docs.cloud.google.com/apigee/docs/hybrid/v1.14/2-5-install-service-accounts.html)
- [List of supported versions](https://docs.cloud.google.com/apigee/docs/hybrid/supported-platforms.md.txt#supported-versions)
- Unsupported versions:
- [v1.13](https://docs.cloud.google.com/apigee/docs/hybrid/v1.13/2-5-install-service-accounts.html)
- [v1.12](https://docs.cloud.google.com/apigee/docs/hybrid/v1.12/2-5-install-service-accounts.html)
- [v1.11](https://docs.cloud.google.com/apigee/docs/hybrid/v1.11/2-5-install-service-accounts.html)
- [v1.10](https://docs.cloud.google.com/apigee/docs/hybrid/v1.10/2-5-install-service-accounts.html)
- [v1.9](https://docs.cloud.google.com/apigee/docs/hybrid/v1.9/2-5-install-service-accounts.html)
- [v1.8](https://docs.cloud.google.com/apigee/docs/hybrid/v1.8/2-5-install-service-accounts.html)
- [v1.7](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/2-5-install-service-accounts.html)
- [v1.6](https://docs.cloud.google.com/apigee/docs/hybrid/v1.6/2-5-install-service-accounts.html)
- [v1.5](https://docs.cloud.google.com/apigee/docs/hybrid/v1.5/2-5-install-service-accounts.html)
- [v1.4](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-5-install-service-accounts.md.txt)
- [v1.3](https://docs.cloud.google.com/apigee/docs/hybrid/v1.3/2-5-install-service-accounts.html)
- [v1.2](https://docs.cloud.google.com/apigee/docs/hybrid/v1.2/2-5-install-service-accounts.html)
- [v1.1](https://docs.cloud.google.com/apigee/docs/hybrid/v1.1/2-5-install-service-accounts.html)

This step explains how to create the Google Cloud service accounts and TLS credentials
that are required for Apigee hybrid to operate.

## Create the service accounts


Apigee hybrid uses Google Cloud [service accounts](https://cloud.google.com/iam/docs/service-accounts) to allow hybrid components to communicate by making authorized
API calls.


In this step, you use an Apigee hybrid command-line tool to create a set of service accounts
and download the service account private key files.


To learn more about service accounts and read the full list of service accounts recommended for
production environments, see the following:

- [About service accounts](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/sa-about.md.txt)
- [Service accounts and roles used by hybrid components](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/sa-about.md.txt#recommended-sas)


Apigee provides a tool, `create-service-account`, that creates the service accounts,
assigns the roles to the service accounts, and creates and downloads the key files for the service
account in a single command. To learn about the related Google Cloud concepts, see
[Creating
and managing service accounts](https://cloud.google.com/iam/docs/creating-managing-service-accounts) and
[Creating
and managing service account keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys).

1. Be sure that you are in the `base_directory/hybrid-files` directory you configured in [Set up the project directory structure](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-5-install-service-accounts.md.txt#setup-directory).
2. Execute the following command from inside the `hybrid-files` directory. This command creates a service account for the `apigee-metrics` component and places the downloaded key in the `./service-accounts` directory.

   ```
   ./tools/create-service-account apigee-metrics ./service-accounts
   ```


   When you see the following prompt, enter <kbd>y</kbd>:

   ```
   [INFO]: gcloud configured project ID is project_id.
    Press: y to proceed with creating service account in project: project_id
    Press: n to abort.
   ```


   If this is the first time an SA with the exact name assigned by the tool was created, then
   the tool just creates it, and you do not have to do anything further.


   If, however, you see the following message and prompt, enter <kbd>y</kbd> to generate
   new keys:

   ```
   [INFO]: Service account apigee-metrics@project_id.iam.gserviceaccount.com already exists.
   ...
    [INFO]: The service account might have keys associated with it. It is recommended to use existing keys.
    Press: y to generate new keys.(this does not de-activate existing keys)
    Press: n to skip generating new keys.
   ```
3. Now, create the rest of the service accounts using the following commands. The `create-service-account` command is interactive and requires a response for each account.

   ```
   ./tools/create-service-account apigee-synchronizer ./service-accounts
   ```

   ```
   ./tools/create-service-account apigee-udca ./service-accounts
   ```

   ```
   ./tools/create-service-account apigee-mart ./service-accounts
   ```

   ```
   ./tools/create-service-account apigee-cassandra ./service-accounts
   ```

   ```
   ./tools/create-service-account apigee-logger ./service-accounts
   ```

   ```
   ./tools/create-service-account apigee-watcher ./service-accounts
   ```

   ```
   ./tools/create-service-account apigee-distributed-trace ./service-accounts
   ```

   > [!NOTE]
   > **Note:** The Cloud Pub/Sub API must be enabled in the Google Cloud project that owns the service account for Synchronizer. See [Enable APIs](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/precog-enableapi.md.txt).

4. Verify that the service account keys were created using the following command. You are responsible for storing these private keys securely. The key filenames are prefixed with the name of your Google Cloud project.

   ```
   ls ./service-accounts
   ```


   The result should look something like the following:

   ```
   gcp-project-id-apigee-cassandra.json
   gcp-project-id-apigee-distributed-trace.json
   gcp-project-id-apigee-logger.json
   gcp-project-id-apigee-mart.json
   gcp-project-id-apigee-metrics.json
   gcp-project-id-apigee-synchronizer.json
   gcp-project-id-apigee-udca.json
   gcp-project-id-apigee-watcher.json
   ```

> [!NOTE]
> **Tip:** Apigee hybrid includes a validator that checks your service accounts' key files and permissions when [apigeectl](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/cli-reference.md.txt) applies the Apigee hybrid runtime components to your cluster. This validation is enabled by default. For more information, see [Service account
> validation](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/sa-validation).

## Create TLS certificates


You are required to provide TLS certificates for the runtime ingress gateway in your
Apigee hybrid configuration. For the purpose of this quickstart (a non-production trial installation),
the runtime gateway can accept self-signed credentials. In the following steps,
[openssl](https://www.openssl.org/) is used to generate the self-signed credentials.

> [!NOTE]
> **Note:** In a production environment, you will need to use signed certificates. You can either use either a certificate and key pair or a Kubernetes secret. For an example on how to obtain a TLS certificate from the *Lets Encrypt* certificate authority (CA), see [Obtain TLS credentials: An example](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/lets-encrypt.md.txt).


In this step, you will create the TLS credential files and add them to
the `base_directory/hybrid-files/certs` directory.
In [Step 6: Configure the
cluster](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-6-install-configure-cluster), you will add the file paths to the cluster configuration file.

1. Be sure that you are in the `base_directory/hybrid-files` directory you configured in [Set up the project directory structure](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-5-install-service-accounts.md.txt#setup-directory).
2. Make sure to save a domain name to the **`DOMAIN`** environment variable using the following command:

   ```
   echo $DOMAIN
   ```
3. Execute the following command from inside the `hybrid-files` directory:

   ```
   openssl req  -nodes -new -x509 -keyout ./certs/keystore.key -out \
       ./certs/keystore.pem -subj '/CN='$DOMAIN'' -days 3650
   ```


   Where **`DOMAIN`** is the same one you used for your environment in
   [Part 1, Step 5: Create an
   environment group](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/precog-add-environment).


   This command creates a self-signed certificate/key pair that you can use for the quickstart
   installation.
4. Check to make sure the files are in the `./certs` directory using the following command:

       ls ./certs
         keystore.pem
         keystore.key


   Where `keystore.pem` is the self-signed TLS certificate file and `keystore.key`
   is the key file.


You now have the service accounts and credentials needed to manage Apigee hybrid
in your Kubernetes cluster. Next, you will create a file that is used by Kubernetes
to deploy the hybrid runtime components to the cluster.
[1](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-1-install-create-cluster.md.txt) [2](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-2-install-cert-manager.md.txt) [3](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-3-install-asm.md.txt) [4](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-4-install-apigeectl.md.txt) [5](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-5-install-service-accounts.md.txt) [(NEXT) Step 6: Configure the hybrid runtime](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-6-install-configure-cluster.md.txt) [7](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/2-7-install-hybrid-runtime.md.txt)

<br />