GCPUG.TW meetup #28 - GKE上運作您的k8s服務
-
Upload
simon-su -
Category
Technology
-
view
190 -
download
3
Transcript of GCPUG.TW meetup #28 - GKE上運作您的k8s服務
![Page 1: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/1.jpg)
GKE上運作您的K8S服務
Simon Su x Sunny Hu / 201708
![Page 2: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/2.jpg)
We are from GCPUG.TW~
大家好,我們是 Google Cloud Platform User Group (GCPUG) 台灣分支,我們是一
個Google Cloud Platform 相關技術的民間
社群,成立的宗旨在分享與交換 Google Cloud Platform 上的一些技術與使用經驗。
歡迎對 Google Cloud Platform 有興趣的朋
友們可以共襄盛舉。
![Page 3: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/3.jpg)
Outline
● Google Container Engine (GKE) Introduction● Cloud Source Repositories● Container Registry service● Container Builder with CICD
![Page 4: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/4.jpg)
Lab 0 - Join GCPUG.TW
![Page 5: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/5.jpg)
Google Container Engine Intro.https://cloud.google.com/container-engine/
![Page 6: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/6.jpg)
GKE - Easily Create Cluster
![Page 7: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/7.jpg)
● 5各節點以下,代管Master Node● 無痛升級
● Host自動擴展機制
● Cloud logging整合
● Stackdriver監控整合
● 與Cloud Console介面整合
GKE - Features
![Page 8: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/8.jpg)
Should be ready...
● 連線您的GKE集群
gcloud container clusters get-credentials [cluster_name]
--zone [cluster_zone]--project [cluster_project]
● 連線了的GKE Dashboard
kubectl proxy http://127.0.0.1:8001/
![Page 9: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/9.jpg)
從Nginx服務的建立過程,來看Google Container Engine為您做了什麼....
Step 1:kubectl run --image=nginx mynginx --port=80
Step 2: kubectl expose deploy/mynginx --type=LoadBalancer
Step 3:kubectl get all
Lab 1 - 從Nginx看GKE
![Page 10: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/10.jpg)
Cloud Source Repositorieshttps://cloud.google.com/source-repositories/
![Page 11: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/11.jpg)
Cloud Source Repositories
● 大家熟悉的git repository● 與gcloud認證整合
● 整合cloud debugger● 連結 GitHub 或 Bitbucket 存放區
● 原始碼瀏覽器
![Page 12: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/12.jpg)
將本地端專案複製到Cloud Repository
![Page 13: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/13.jpg)
從Cloud Repository中複製專案原始碼...
![Page 14: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/14.jpg)
從github或是bitbuckt中複製git專案
![Page 15: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/15.jpg)
Step 1: 建立您的專案
mkdir myprojectcd myprojectecho ‘Hello GKE!’ > index.html
Step 2: 建立Dockerfilecat << EOF > DockerfileFrom nginxAdd . /usr/share/nginx/htmlEOF
Lab 2 - Create your project
![Page 16: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/16.jpg)
Step 3:git initgit remote add google https://source.developers.google.com/p/[project-id]/r/[repo-name]git add . git commit -m “init”git push --all google
Lab 2 - Create your project
![Page 17: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/17.jpg)
Lab 2 - 成功
![Page 18: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/18.jpg)
Container Registry servicehttps://cloud.google.com/source-registry/
![Page 19: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/19.jpg)
What is Google Container Registry service?
● gcr.io● Google代管的Container Registry● 無限量空間
● 無需架設服務器
● 可以管理版本與Tag資訊
● 以GCP專案為存取範圍
● Build triggers● Build history
![Page 20: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/20.jpg)
● 安裝gcloud sdk
curl https://sdk.cloud.google.com | bash
● 認證gcloud sdk
gcloud init
● 安裝kubectl模組
gcloud components install kubectl
使用gcr.io前置作業
![Page 21: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/21.jpg)
Step 1:docker build -t gcr.io/[my-project-id]/[image-name] .ordocker tag nginx gcr.io/[my-project-id]/[image-name]
Step 2:docker push gcr.io/[my-project-id]/[image-name]orgcloud docker -- push gcr.io/[my-project-id]/[image-name]
使用gcr.io
![Page 22: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/22.jpg)
Lab 3 - Push your image to gcr.io
Step 1: 在Lab2的專案中,執行build動作
docker build -t gcr.io/[my-project-id]/myweb .
Step 2: 將image放到container registrydocker push gcr.io/[my-project-id]/myweb
![Page 23: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/23.jpg)
Lab 3 - 成功
![Page 24: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/24.jpg)
Container Builder with CICDhttps://cloud.google.com/source-builder/
![Page 25: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/25.jpg)
What is Container Builder?
● 繼承GCP的高速網路,上
傳、下載速度快
● 具備Google Level 隱私權與
安全性
● 可整合持續部署功能
![Page 26: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/26.jpg)
建置自己的trigger
![Page 27: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/27.jpg)
Lab 4 - Auto Build Docker Image
Step 1:設定build trigger,使用Tag = v0.1這樣的方式來Build image
Step 2:設定完成,檢視log與Cloud Builer
Step 3: Push new taggit tag v0.1git push google v0.1
![Page 28: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/28.jpg)
Lab 4 - 成功
![Page 29: GCPUG.TW meetup #28 - GKE上運作您的k8s服務](https://reader034.fdocument.pub/reader034/viewer/2022052318/5a64ee597f8b9aa6218b460d/html5/thumbnails/29.jpg)
FAQTHANKS