# GCP Console 共筆
## Compute Engine
所有 GCE 相關設定都在這裡
>GCE : `Google Compute Engine` 的簡稱,是由 GCP 提供的 VM 及相關資源

### 創建個體
#### 筆記
- 區域- 影響可共用的==網路介面== ~e.g.~ ~台灣~
- 機器設定- 機器配置, 注意 :money_with_wings: :money_with_wings:
- 開機磁碟- OS、磁碟大小, 可以直接匯入image
- 身分及API存取權- ```存取權範圍-> 針對各個 API 設定存取權-> Cloud 原始碼存放區=> 唯讀```
- 網路- ```網路介面-> 編輯網路介面-> 與我共用的子網路->《選擇要共用的子網路》```
- 安全性- ```安全殼層金鑰-> 新增項目->《輸入金鑰》``` ~金鑰為各跳版機SSH~ ~key~
### 初始新個體
- terminal登入(ssh)
- 檢查git套件及版本(2.x.x以上) ```git --version```
- 安裝最新版本git
- 刪除舊版本
```sudo yum -y remove git```、```sudo yum -y remove git-*```
- 安裝最新
`sudo yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.9-1.x86_64.rpm` 、
`sudo yum install git`
- 
- 建立新路徑(資料夾) `mkdir [name]` ~e.g.~ ~mkdir~ ~Demo~
並移至該路徑(資料夾)
- `gcloud source repos clone [git source] --project=[當前專案ID]`
~e.g.~ ~gcloud~ ~source~ ~repos~ ~clone~ ~BattlePomelo_Stephen~ ~--project=gcp-20201229-002~!
* 後續更新code (拉下git) `git pull`
---
## 監控(Monitoring)
GCP 資源監控都在這設定

---
## 紀錄(Logging)
收集 GCP 相關服務產生的日誌
* [官方文案-記錄查詢語言](https://cloud.google.com/logging/docs/view/logging-query-language)
* [將 Ops Agent 安裝在單台虛擬機上](https://cloud.google.com/logging/docs/agent/ops-agent/installation)

### 捕捉紀錄檔
進入各台預捕捉log的機器
- 安裝
`curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh`
`sudo bash add-google-cloud-ops-agent-repo.sh --also-install`
* [官方文案](https://cloud.google.com/logging/docs/agent/ops-agent/installation)
- 啟動
`systemctl start google-fluentd.service`
- 重啟
`systemctl restart google-fluentd.service`
- 停止
`systemctl stop google-fluentd.service`
- 檢查狀態
`systemctl status google-fluentd.service`

---
## 網路服務
GCP 的網路相關服務,像是負載平衡,DNS CDN 等服務的設定
:::warning
:exclamation: 這在我們的專案是相當重要的一塊,要多做筆記
:::

* [負載平衡範例](https://hackmd.io/Ey_CyF7MSPyIErVG_Y_Tsw)
---
## Cloud Source Repo
GCP 提供的 [source code repo 服務](https://hackmd.io/FbKjyNYRSmG3WNVQfUpE7g)

### 新增SSH key
Push Commit需要擁有SSH Keys, 進入Manage SSH Keys新增及管理
- 
- 
### 新增存放區

- 建立新的存放區 
- 存放區名稱-> 自定義
專案-> 搜尋game 2
#### 從本機Git存放區推送程式碼
- 於本地欲存放git之路徑建立新的git
- 建立==README.md==檔案
- `git add .`
- `git commit -m "project init"`
- 執行步驟2、3指令 ~*~ ~"google"此參數可自定義~
#### 在本機Git存放區中為您的存放區建立副本
- 移至欲存放git的路徑
- 執行步驟2~5
---
## 帳單
記得定期查看累積費用
>這邊 DC 有統一做監控並發送異常警告,但還是建議每天上來巡一下

---
###### tags: `GCP` `RD7` `Game2` `創新研發組`