gcpug.tw meetup #28 - gke上運作您的k8s服務
Post on 22-Jan-2018
190 Views
Preview:
TRANSCRIPT
GKE上運作您的K8S服務
Simon Su x Sunny Hu / 201708
We are from GCPUG.TW~
大家好,我們是 Google Cloud Platform User Group (GCPUG) 台灣分支,我們是一
個Google Cloud Platform 相關技術的民間
社群,成立的宗旨在分享與交換 Google Cloud Platform 上的一些技術與使用經驗。
歡迎對 Google Cloud Platform 有興趣的朋
友們可以共襄盛舉。
Outline
● Google Container Engine (GKE) Introduction● Cloud Source Repositories● Container Registry service● Container Builder with CICD
Lab 0 - Join GCPUG.TW
Google Container Engine Intro.https://cloud.google.com/container-engine/
GKE - Easily Create Cluster
● 5各節點以下,代管Master Node● 無痛升級
● Host自動擴展機制
● Cloud logging整合
● Stackdriver監控整合
● 與Cloud Console介面整合
GKE - Features
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/
從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
Cloud Source Repositorieshttps://cloud.google.com/source-repositories/
Cloud Source Repositories
● 大家熟悉的git repository● 與gcloud認證整合
● 整合cloud debugger● 連結 GitHub 或 Bitbucket 存放區
● 原始碼瀏覽器
將本地端專案複製到Cloud Repository
從Cloud Repository中複製專案原始碼...
從github或是bitbuckt中複製git專案
Step 1: 建立您的專案
mkdir myprojectcd myprojectecho ‘Hello GKE!’ > index.html
Step 2: 建立Dockerfilecat << EOF > DockerfileFrom nginxAdd . /usr/share/nginx/htmlEOF
Lab 2 - Create your project
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
Lab 2 - 成功
Container Registry servicehttps://cloud.google.com/source-registry/
What is Google Container Registry service?
● gcr.io● Google代管的Container Registry● 無限量空間
● 無需架設服務器
● 可以管理版本與Tag資訊
● 以GCP專案為存取範圍
● Build triggers● Build history
● 安裝gcloud sdk
curl https://sdk.cloud.google.com | bash
● 認證gcloud sdk
gcloud init
● 安裝kubectl模組
gcloud components install kubectl
使用gcr.io前置作業
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
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
Lab 3 - 成功
Container Builder with CICDhttps://cloud.google.com/source-builder/
What is Container Builder?
● 繼承GCP的高速網路,上
傳、下載速度快
● 具備Google Level 隱私權與
安全性
● 可整合持續部署功能
建置自己的trigger
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
Lab 4 - 成功
FAQTHANKS
top related