# Google Container Registry

## Introduction

Bunnyshell enables you to connect Google Container registries to your organization, making it easy for you to store your application images there and deploy them on Kubernetes clusters.

{% hint style="info" %}
Before you proceed, make sure you have administrator privileges on your Google Container Registry.
{% endhint %}

## Granting Bunnyshell Access to GCR

1\. Install the gcloud CLI using the instructions [available here](https://cloud.google.com/sdk/docs/install).

2\. Enable Google Container Registry API using the command below.

```
gcloud services enable containerregistry.googleapis.com
```

### Creating the Service Account

3\. Now you'll have to grant Bunnyshell access to GCR. Start by creating a service account using the command below:

```
gcloud iam service-accounts create [USER] 
```

Example

```
gcloud iam service-accounts create bunnyshell-access
```

{% hint style="info" %}
In this case, **bunnyshell-access** is the GCR User ID we used.
{% endhint %}

4\. Grant the Service Account access to your storage:

```
gcloud projects add-iam-policy-binding PROJECT_ID \ --member=serviceAccount:USER@PROJECT_ID.iam.gserviceaccount.com \ --role=roles/storage.admin 
```

Example

```
gcloud projects add-iam-policy-binding [bunnyshell-84194] \ --member=serviceAccount:bunnyshell-access@bunnyshell-84194.iam.gserviceaccount.com \ --role=roles/storage.admin
```

{% hint style="info" %}
In this case, **bunnyshell-84194** is our GCR Project ID.
{% endhint %}

### Retrieving your Project ID

The **Project ID** can be fetched by clicking on the Project Name in the top bar.

![](https://1816776994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlP4CN7wxbqd_3NdM99%2Fuploads%2FYpVzLZvNFFIgzWlSapk4%2Fgcr_projectid.png?alt=media\&token=5606fd74-7a6e-4186-9f94-037aae142e73)

### Retrieving the Google Service Account&#x20;

5\. Retrieve the Google Service Account key using the command below:

```
gcloud iam service-accounts keys create gsa-key.json \ --iam-account=[USER@PROJECT_ID].iam.gserviceaccount.com
```

Example

```
gcloud iam service-accounts keys create gsa-key.json \ --iam-account=bunnyshell-access@bunnyshell-84194.iam.gserviceaccount.com
```

## Connecting your GCR Registry

1\. Access the **Bunnyshell** interface and click the <img src="https://1816776994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlP4CN7wxbqd_3NdM99%2Fuploads%2Famg2qle0NQi5P0n3ocP1%2Fintegrations%20icon.png?alt=media&#x26;token=9613b54e-aa3e-418f-aa6b-d6d7301f4817" alt="" data-size="line"> **Integrations** button on the left side.

![](https://1816776994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlP4CN7wxbqd_3NdM99%2Fuploads%2Fmco74e6DzmvJe1cUbFhY%2FRegistries%201.png?alt=media\&token=d114c686-fe3a-4cfd-914c-d71c6232a0b2)

2\. Click **Registries** on the left-side menu.

3\. Click the **Connect** **registry** button and select **Google Container Registry**.

4\. A new window will pop-up, where you will have to provide the following information:

* **Registry name**: Choose what name your cluster will have in Bunnyshell.&#x20;
* **Region**: The location of the registry, location where the image is stored.

{% hint style="info" %}
More details about GCR regions are available on the [Google Cloud documentation site](https://cloud.google.com/container-registry/docs/overview#registries).
{% endhint %}

* **GCR User ID**: Copy and paste the [Google Service Account](#creating-the-service-account) ID in this field.

{% hint style="info" %}
If you have a Google Service Account already created, the ID is the **string before the @ in the email address**.

**Example**:

In the address **<bunnyshell-access@bunnyshell-84194.iam.gserviceaccount.com>**, the string **bunnyshell-access** is the Google Service Account ID.
{% endhint %}

* **GCR Project ID:** Fetched by clicking on the Project Name in GCR interface.\
  [How to retrieve the Project ID](#retrieving-your-project-id).
* **Google Service Account Key (JSON)**: Copy and paste the contents of gsa-key.json inside this field.\
  [How to retrieve the Google Service Account Key](#retrieving-the-google-service-account).
