# GCP GCR

### Edgegap을 Google Container Registry와 함께 사용하기

### 준비해야 합니다

* [x] GCR의 GCP 리전
* [x] GCP 프로젝트 이름
* [x] IAM 사용자의 JSON 키

### 이 정보를 얻으려면 GCP 콘솔로 이동하세요

1. 프로젝트로 이동
2. Container Registry로 이동
3. 전체 리포지토리 이름 복사

### 전체 저장소 이름 분리

이 전체 저장소가 주어졌을 때: **gcr.io/project-name/example**

당신의 **저장소** 다음이 됩니다: **gcr.io**

그리고 당신의 **이미지** 다음이 됩니다: **project-name/example**

### JSON 키 파일 생성

다음을 따르세요 [**GCP 단계**](https://cloud.google.com/container-registry/docs/advanced-authentication#json-key) 이 파일을 생성하려면.

{% hint style="warning" %}
다음 사항을 확인하세요 `Google 서비스 계정` 컨테이너 레지스트리를 관리할 수 있는 적절한 권한이 있는지
{% endhint %}

다음과 유사한 내용을 포함한 파일이 생성됩니다

```json
{
  "type": "service_account",
  "project_id": "project-name",
  "private_key_id": "12345abcdef12345",
  "private_key": "-----BEGIN PRIVATE KEY-----\n[...]\n-----END PRIVATE KEY-----\n",
  "client_email": "example@project-name.iam.gserviceaccount.com",
  "client_id": "1234567890",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/example%40project-name.iam.gserviceaccount.com"
}
```

### 앱을 Edgegap에 추가

#### **API 예시**

{% hint style="info" %}
사용자 이름은 항상 다음과 같습니다 **\_json\_key**
{% endhint %}

```json
{
    [...]
    "docker_repository": "gcr.io",
    "docker_image": "project-name/repository-name",
    "docker_tag": "v1",
    "private_username": "_json_key",
    "private_token": "<The Content of JSON key file as JSON String>",
    [...]
}
```

Private Token은 다음과 유사하게 보입니다

```json
{
    [...]
    "private_token": "{\"type\": \"service_account\", \"project_id\": \"project-name\", \"private_key_id\": \"12345abcdef12345\", \"private_key\": \"-----BEGIN PRIVATE KEY-----\\n[...]\\n-----END PRIVATE KEY-----\\n\", \"client_email\": \"example@project-name.iam.gserviceaccount.com\", \"client_id\": \"1234567890\", \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\", \"token_uri\": \"https://oauth2.googleapis.com/token\", \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\", \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/example%40project-name.iam.gserviceaccount.com\"}",
    [...]
}
```

#### **대시보드에서**

우리 대시보드에서, **프라이빗 레지스트리 토큰** 다음의 내용이 됩니다 **JSON 키 파일**

**문자열화(Stringify)하지 않고 내용 그대로 복사할 수 있습니다**

<figure><img src="https://1562312210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR0dHSFv9ymoC0DO5G8J%2Fuploads%2Fgit-blob-7302363fb151d9cdc2e8f010c04158138c9379f0%2Fgcr-example.png?alt=media" alt=""><figcaption></figcaption></figure>
