--- tags: Blue 的學習紀錄 --- # Google Cloud Certification - Associate Cloud Engineer ![associate cloud engineer](https://hackmd.io/_uploads/BkmkfZeBi.png) > <https://www.credential.net/ea496d98-9cdd-4fd3-a5fb-145652797241> 考到啦~~ ExamTopics 超好用,在考試中看到好多一模一樣的題目 下面內容是我在準備過程中所做的紀錄 --- **目標:** <https://cloud.google.com/certification/cloud-engineer> **考試內容:** <https://cloud.google.com/certification/guides/cloud-engineer> **ExamTopics 刷題筆記(不公開):** <https://docs.google.com/document/d/11o45Z3TZT73kNQokfy_tbCmr-2vk4-Pqzn71mQdhDJ4/edit#> 選擇放 google doc 的原因是圖片是儲存在文件裡,而不是另一個外部空間 不公開的原因是我直接將題目圖片截圖至文件中,怕有侵權疑慮所以不公開 **考試地點 & 日期:** 我選擇實體考試,而非線上 地點: [台北恆毅考試中心](https://www.uuu.com.tw/About/tpe) [Google Map 地點](https://goo.gl/maps/SBnM5BMozsZKLZ3J9) 交通方式: 文湖線 - 南京復興站 - 7 號出口 考試時間: 2022/10/31(一) 13:30 ## Exam Pro 影片隨手筆記 <https://www.youtube.com/watch?v=jpno8FSqpc8> ### Cloud Service Models <https://www.youtube.com/watch?v=jpno8FSqpc8&t=3613s> - IaaS: Infrastructure as a Service 例如 Linode、Google Compute Engine 從作業系統開始,使用者來負責 底層網路、機器的運行由服務端負責 - PaaS: Platform as a Service 例如 Heroku 應用程式由使用者來負責 runtime、OS 由服務端來負責 - SaaS: Software as a Service 例如 Gmail、MS Office 365 這些分類的目的在於==責任如何分配== ### Google Cloud Global Infrastructure <https://www.youtube.com/watch?v=jpno8FSqpc8&t=4102s> - zone gcp network 裡的最小單位 範例:`us-east4-a`, `us-east4-b` - region 由 zone 所組成 一個 region 具有高可用的特性 region 內的 zone 的相互通訊時間小於 5ms ### Compute Service Options <https://www.youtube.com/watch?v=jpno8FSqpc8&t=4519s> - serverless & fully managed [解釋 serverless 和 fully managed](https://cloud.google.com/blog/topics/developers-practitioners/serverless-vs-fully-managed-whats-difference) > serverless: > I code my application or service and I don't care where it run..just make sure my user is able to get to it when they try. > > fully managed: > I care how and where my service runs because I have a specific type of service that needs more control over the underlying resources and… my application/team benefits from the extra controls. **serverless:** 只管寫程式,完全不管硬體相關的事情 例如跑在哪台機器上、有幾台機器、機器的運算能力和儲存空間等等,這些都不關心 收費方式舉例:request 的數量、function 被呼叫的次數、使用了多少資源 **fully managed:** 除了程式碼,同時也關心硬體的事情 可以控制有幾台機器在跑,機器各自的運算能力如何等等 讓使用者可以輕易規劃 High Availability (HA) 和 Disaster recovery (DR) 收費方式舉例:以機器運行的時間來計算(所以就算實際上機器沒有任務執行,錢也會照算)(compute engine) - Compute Engine IaaS 一台 VM 會稱為一個 instances 可部署在特定的 zone 之內 可決定 VM 所要運行的 OS 透過 `instance group` 來管理多個 VM,autoscaling - Google Kubernetes Engine - GKE CaaS - Container as a Service 建立在 k8s 之上的一個圖形化介面平台 幫助使用者關於 k8s 的使用 gke 會使用 Compute Engine 來當作 k8s 裡的 node - App Engine <https://cloud.google.com/appengine/docs> PaaS ## Google Cloud Fundamentals: Core Infrastructure <https://www.cloudskillsboost.google/course_templates/60> ### CH.1 Introducting Google Cloud GCP 的 IaaS 服務是以秒計費的 關於 compute engine 的計費,若使用的時間超過 1/4 月 1/4 月後的時間都會有折價 關於價錢的控制,有幾種方法: - 設定 budget 可以在 billing account 或 project level 設定預算 預算可以是固定的數字或是某種規則的變數,例如上個月的 110% - 設定 alert 例如當預算達到 90% 時,就會進行通知 - 使用 report report 是 GCP 的一個視覺化工具,可以查看目前的支出 - quota 可防止服務因被攻擊或不預期的錯誤導致的過度消耗 quota 有分兩種,兩種都屬於 project level: - rate quota 會在特定時間之後重置,例如: 在預設情況下,GKE 會配置給每個 project 每 100 秒只能 1000 個 API call 100 秒後,數字就會重置 - allocation quota 管理著 project 所能擁有的 resource,例如: 在預設情況下,每個 project 只能擁有 5 個 VPC 這些 quota 可向 google cloud support 進行申請提升 ### CH.3 Resources and Access in the Cloud #### Google Cloud resource hierarchy Organization -> Folder -> Project -> Resources Policy 可以定義在 Organization, Folder, Project 少部分的 Resource 可以設定 Policy Policy 的設定會延伸至較下面的層級 譬如設定 Organization 的 Policy,則所有 Folder 也會沿用此 Policy 一個 Resource 只能屬於一個 Project Project ID 為 Global unique,而且無法變更 Project Name 可以任意變更 Folder 可以 nest 可再放 Folder,或是 Project Folder 並不是必備,可以沒有 Folder 層 但 Folder 的建立一定需要 Organization Node Organization node 的建立會因為使用者是否為「Google Workspace customer」而有所不同 如果是,則 Project 會自動屬於使用者的 Organization node 若不是,則可以使用 Cloud Identity 來新建 Organization node #### IAM IAM 在做的,是在定義**誰**可以在**哪個資源**上面**做什麼事** **誰**: - Google account mail - Google group Google account 的集合 - Service account 給 service 所使用,例如 VM - Cloud Identity domain **做什麼事**: 能做什麼事由 **role** 來定義 role 則是由數個 permission 所組成 role 可以分成三類:basic、predefined、custom - basic 並不如字面上 basic,而是在影響著 project 之下的所有資源 basic 之中有四種 role: ![iam basic 中的 4 種 role](https://hackmd.io/_uploads/HJcVl_ra9.png) - owner 可以增刪查改、管理 project 之下的所有資源和權限,管理 billing - editor 可以查看及編輯 project 之下的所有資源 - viewer 只能查看 project 之下的所有資源 - billing admin 可以查看 project 之下的所有資源,管理 billing basic 的權限相當廣大,若是在一個多人協作的 project 中,非常不適合使用這個 role - predefined 由各別 google service 所提供的 role 所擁有的 permission 會依據 service 而有所不同 - custom 可以自定義一個 role 所擁有的 permission 只能用在 organization 或 project level,不能用在 folder level #### 與 GCP 互動的四種方式 - Google Console GCP web-based 圖形化介面 - Cloud SDK and Cloud Shell - Cloud SDK GCP 上的一堆工具,例如: - gcloud tool 提供主要的 command-line interface 給 Google Cloud 上各個服務 - gsutil 提供以 command line 的方式存取 Cloud Storage - bq BigQuery 的 command line 工具 - Cloud Shell 得以用 command line 在瀏覽器上操作 cloud resource Cloud Shell 是一個 Debian-based 的 VM,並且配有 5GB 的使用空間 Cloud SDK 可在 Cloud Shell 內使用 Cloud Shell 內的資料,除了 `./home` 以下之外,每個小時就會被洗掉 - APIs Google APIs Explorer 可以查看所有可用的 API - Cloud Console Mobile App #### Load Balancing load balancer 的種類 - Global HTTP(S) cross-regional for web application - Global SSL Proxy For Secure Sockets Layer traffic - Global TCP Proxy TCP traffic that doesnt use SSL - Regional across region UDP traffic traffic on any port number - Regional internal load balance traffic inside your project ### CH.4 Virtual Machines and Networks in the Cloud #### VPC - Virtual Private Cloud Public Cloud - 所有組織共用一份 infrastructure Private Cloud - 一份 infrastructure 只有一個組織在使用 Virtual Private Cloud - 用起來像是一個組織一份 infrastructure,但其實是所有組織在共用 #### 與 VPC 連線的方法 - 使用 VPN(Virtual Private Network) IPsec VPN protocol、Cloud Router、Border Gateway Protocol - Direct Peering Peering 表示將 router 放在公開的資料中心,例如 Google 資料將在這個資料中心進行 exchange - Carrier Peering service provider's network 提供 - Dedicated Interconnect 提供 SLA 99.99% 的連線服務 - Partner Interconnect ??? #### VPC network Routes 負責告訴 VM 及 VPC network 如何溝通 - allow-custom 內部可以 ping 內部 - allow-icmp 內部可以 ping 外部 <https://cloud.google.com/vpc/docs/subnets> Virtual Private Cloud (VPC) networks 是一種 global resources 每個 VPC network 包含了多個 IP 區段,又稱為 subnet subnet 為 regional resources #### Compute Engine - 計費方式 - 費用以運行的時間做為計算,時間單位為"秒" - 當運行超過 1/4 個月之後,在 1/4 個月之後開始就會有折扣 - 若已知一年或三年內所需的運算資源是固定不變動的,可以使用 commited-use 的方式,會有折扣 - 一次性的任務,可以使用 Preemptible VM,比較便宜 ### CH.5 Storage in the Cloud ![各 storage 的適用場景及儲存上限](https://hackmd.io/_uploads/Hy048Iyks.png) - Cloud Storage 一種 object storage - 什麼是 object storage? windows 作業系統中的檔案就是 file storage,意思是每個檔案都擁有特定路徑,資料存放於特定層級之中 object storage 中的資料則沒有層級的概念,並且所有檔案都會有額外的 metadata,讓資料容易地被辨識,以便可以找到 - `bucket` Cloud Storage 的檔案藉由 bucket 來管理 bucket 需要 global unique name 及特定的地理資訊 - 不可編輯,只能覆蓋 Cloud Storage 中的資料無法進行編輯,只能覆蓋新的檔案 - version control 管理者可以決定每個 bucket,對於新檔案是要直接覆蓋 還是 Cloud Storage 會追蹤檔案變更的地方(像 git) 並且可以將檔案回復到特定版本 - 檔案的生命週期管理政策 例如,可以設定自動刪除放置了一年的檔案 或是當開啟版本控制時,設定只保留最新的三個版本 - Cloud Storage,依據檔案的存取頻率,可以再細分為四類 - Standard Storage 頻繁的讀取,hot data 或是生命很短暫的 - Nearline Storage "建議"存放大約一個月才會存取一次的資料 - Coldline Storage 90 天"只能"讀取一次的資料 - Archive Storage 365 天"只能"讀取一次的資料 - 上傳資料的方式 - gsutil 由 cloud SDK 提供的 command line tool - cloud console 從 gui 頁面上直接上傳 - Storage Transfer Service 提供大型資料(例如 TB 等級)的上傳管道 可以管理 batch transfers 的方式 從其他 cloud provider, 其他 cloud storage region 或特定 HTTP(S) endpoint - Transfer Appliance 一個 server 將 server 連到特定的網路下,就可以將網路內的資料上傳至 cloud storage - Cloud SQL 提供 relational databases 的服務,例如 MySQL, PostgreSQL - Cloud Spanner 同樣提供 relational database 的服務,但特別適用於以下情境: - 有 joins 和 secondary indexes 的需求 - Built-in high availability - Strong global consistency - Database sizes that exceed 2 terabytes - Higt throughput per second,每秒破萬的讀寫 - Firestore NoSQL cloud database 資料的單位是 document,collection 內會有多個 document,就像是 MongoDB 擁有每日 free quota - Cloud Bigtable NoSQL big data database service 目標是要能處理大量的 workload 所以很適合應用於需要處理大量資料的場景,例如 IOT, 金融資料, 機器學習 ### CH.6 Containers in the Cloud k8s 已經有點熟了,所以這裡不做紀錄 #### Anthos hybrid and multi-cloud solution 內建 k8s 及 GKE 讓 k8s 可在多個雲之間運行著 ### CH.7 Applications in the Cloud #### App Engine PaaS 平台,使用者只需選擇要使用的程式語言、框架,App Engine 負責建置 server 使用步驟: - 在地端開發 app - 使用 SDK 進行部署 - App Engine 自動運行 app 依據環境可以分成兩種: <https://cloud.google.com/appengine/docs/the-appengine-environments> - standard 應用程式將運行在 sandbox 之內,意思是我們完全不用關心程式碼的運行環境 但是 runtime 被限定只能使用 GCP 所支援的項目,包含程式語言及其版本的選擇 因此擁有最快的執行速度及最低的成本 計費方式以所選擇的 instance 的啟動時間來計算 - flexible 應用程式會運行在 Compute Engine VM 的 Docker container 之內 App Engine 幫使用者管理 Compute Engine 意思是自動做 health-check、自動更新 OS、每周重啟 使用 Dockerfile 來自定義 runtime 支援任何版本的 Python, Java, Node.js, Go, Ruby, PHP, or .NET 計價方式以 vCPU, memory, and persistent disks 的使用量 <https://cloud.google.com/appengine/docs/the-appengine-environments#compare_high-level_features> | | Standard | Flexible | |:-----------------:|:------------------------------------:|:-----------------------------------------------------:| | Instance 啟動時間 | 秒 | 分鐘 | | SSH | 不行 | 可以(預設不行) | | 寫入 local disk | 不行(有些 runtime 可以讀寫 `/tmp`) | 可以,ephemeral (disk initialized on each VM startup) | App Engine Standard 的作用在於讓使用者免除部屬及 scaling 的問題 GKE 則是幫助使用者使用 k8s App Engine Flexible 則介於以上兩者之間 #### Cloud Endpoints & Apigee Edge - Cloud Endpoints 類似於 AWS API Gateway 可以宣告多個 API - Apigee Edge 一樣類似於 API Gateway 但是可以做到 rate limiting, quotas, analytics Apigee Edge 的 server 不必放在 GCP 內 #### Cloud Run 運行 stateless 的 container serverless,完全不用管 infra 建立在 knative 上,背後是 k8s 啟動速度很快,能夠 auto scaling 以所使用到的計算資源為計費 將應用程式的 image 上傳至 Artifact Registry 後即可部屬到 Cloud Run 也可以直接上傳 source code,Cloud Run 自動 build 成 container ### CH.8 Developing and Deploying in the Cloud - Cloud Source Repositories 應該類似於 Github 和 Gitlab,只是是在 GCP 上,並且能與 GCP 上的其他服務有更好的整合 - Cloud Functions 類似於 AWS Lambda #### Terraform: Infrastructure as Code 所謂 "Infrastructure as Code" 指的是,讓 infra 這件事情就像是寫 code 一樣 使用 Terraform 就可以寫 template,讓 infra 照著所寫的 template 而去生成 ### CH.9 Logging and Monitoring in the Cloud 這個章節主要在講 logging 及 monitoring 收集資料,進行處理,呈現 real-time 的系統資料 關於一個系統穩定性的描述,有 4 個項目: - latency - traffic - saturation - errors #### SLI, SLO 和 SLA 定義一個 service 的可用性 靠的是 SLI, SLO 和 SLA 這三個指標 - SLI: Service level indicators 用來衡量服務使用情況的量化指標 各指標建議以 `good event / all event` 的形式呈現 例如 `200 request / all request` - SLO: Service level objective SLO 是 SLI 再加上時間的描述 例如一個月內的 SLI 均維持在 99.9% 以上 - SLA: Service Level Agreements SLA 是對於客戶所承諾的服務品質,通常基於 SLO 來決定 參考資料: <https://ikala.cloud/understanding-sli-slo-sla-in-sre/> #### Log - Cloud Audit Logs Who did what, where, and when? - Agent Logs 看不懂 似乎是任意 VM 上的 log,即使是外部服務? - Network Logs - Service Logs ## Essential Google Cloud Infrastructure: Foundation <http://cloudskillsboost.google/course_templates/50> ### Projects, networks, and subnetworks #### Network 一個 project 預設可以擁有 5 個 network 一個 project 中的 network,有三種模式: ![network 的三種模式](https://hackmd.io/_uploads/HJGmARdJs.png) - default 每個 project 預設會給予的 default network - 每個 region 就有一個 subnet - default 的 firewall - auto mode 建立於 default network 之上 - custom mode ## Getting Started with Google Kubernetes Engine <https://www.cloudskillsboost.google/course_templates/2> ### CH.3 Introduction to Containers and Kubernetes Compute Engine offers a feature called managed instance groups With these, you can define resources that are automatically deployed to meet demand. GCP enables fine-grain control of costs of Compute Engine resources by providing per second billing. ### Introduction to Kubernetes Workloads ## Resources <https://github.com/sathishvj/awesome-gcp-certifications> <https://www.cloudskillsboost.google/course_templates/77?locale=zh_TW>