Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
LoK101.pdf
Jerry
December 11, 2018
Technology
0
160
LoK101.pdf
Jerry
December 11, 2018
Tweet
Share
More Decks by Jerry
See All by Jerry
Gitlab CI 入門
cheng
0
210
Other Decks in Technology
See All in Technology
220628 「Google AppSheet」タスク管理アプリをライブ作成 吉積情報伊藤さん
comucal
PRO
0
130
Citizen 개발기
outsider
0
130
Persistence in Serverless Applications - ServerlessDays NYC
marcduiker
0
220
現状のFedCMの動作解説と OIDCとの親和性について- OpenID TechNight vol.19
ritou
2
450
【toranoana.deno#7】Denoからwasmを呼び出す基礎
toranoana
0
100
音のような言葉 〜ちゃちゃっとチャットで楽しむちょっとしたコツ〜 / words like sounds
satoryu
1
1.3k
データエンジニアと作るデータ文化
yuki_saito
4
1.5k
サイボウズの アジャイル・クオリティ / Agile Quality at Cybozu
cybozuinsideout
PRO
4
2.2k
約6年間運用したシステムをKubernetesに完全移行するまで/Kubernetes Novice Tokyo
isaoshimizu
5
790
The role of the data organization as a business progresses
line_developers
PRO
3
850
SI企業が「アジャイル推し」になったら 幸せになれますか?/Can SI company be happy if it becomes “Agile stan” ?
chinmo
1
1.1k
JDK Flight Recorder入門
chiroito
1
500
Featured
See All Featured
From Idea to $5000 a Month in 5 Months
shpigford
373
44k
Support Driven Design
roundedbygravity
86
8.5k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
172
8.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
337
17k
Testing 201, or: Great Expectations
jmmastey
21
5.4k
Why Our Code Smells
bkeepers
PRO
324
55k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
315
19k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
151
13k
A designer walks into a library…
pauljervisheath
196
16k
Why You Should Never Use an ORM
jnunemaker
PRO
47
7.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.3k
Raft: Consensus for Rubyists
vanstee
126
5.4k
Transcript
Laravel on Kubernetes 101
Agenda • 簡單認識 Kubernetes / Docker • 介紹 Kubernetes 各項元件
• 實際部署⼀一個 Laravel Project 到 GKE 上
關於我 • Jerry Cheng • Sr. Software Engineer • 偶爾會假裝⾃自⼰己是
Operator • https://www.facebook.com/ ilay.tw
What is Kubernetes • 容器的全⾃自動管理理/調度平台,誕⽣生⾃自 Google Borg • 不限制 application
類型,只要能容器化的都吃 • 各種抽象化的資源類型 • web/database • task runner • auto scaler • Ingress..
Why Containers • ⼀一致性的執⾏行行環境 • ⽅方便便的應⽤用部署,有利利於持續整合/持續部署 • 清楚的分離 Dev 與
Ops,有利利於分⼯工 • 以應⽤用為中⼼心的管理理⽅方式
Docker • 了了解 Docker Container 的⽣生命週期 • 了了解 Docker Image
的管理理流程
https://docs.microsoft.com/zh-tw/dotnet/standard/microservices-architecture/docker-application-development- process/media/image1.png
Docker Registry • 維護⽅方式跟 Github 有 87% 像,但是放 Docker image
• Dockerhub -> 由 Docker 官⽅方維護,是⽬目前最⼤大的 public registry • Private registry: • VMware Harbor • Gitlab Registry • Cloud: AWS/GCP/Azure…
Kubernetes 資源介紹
Kubernetes Nodes • Node • Node • 負責 Resource 的執⾏行行
• 監控 Resource 的健康狀狀態 • Master Node • 管理理與監控 Node • 負責調度所有的 Resource • 儲存整個 Cluster 的運作狀狀態 • 架設⽅方式 • ⾃自架:minikube / kubeadm / Rancher 2.x (⼈人⽣生短短幾個秋...) • 直接⽤用 Cloud: AWS/ GCP/ Azure/ DigitalOcean…
None
• ⼀一組資源的集合 • 隔離不同 namespace 之間的資源(persistent volume 除外) • 預設有
kube-system/ kube-public/ default https://www.mundodocker.com.br/wp-content/uploads/2017/06/namespaces.png
Pod • Kubernetes 中的最⼩小執⾏行行單位 • ⼀一個完整的 application 部署封裝,可能有⼀一個以上的 container •
共享儲存空間/網路路 https://i0.wp.com/foxutech.com/wp-content/uploads/2018/02/Kubernetes-Pod.jpg
ReplicaSet • 保證 Pod 的數量量跟設定中要求的⼀一樣 • 少了了就補⿑齊,多了了就砍掉,絕對不多不少 • ⽀支援動態縮放 https://prod-edxapp.edx-cdn.org/assets/courseware/v1/27bbf25e6c924d3db9c2e7e568a90bbf/asset-v1:LinuxFoundationX+LFS158x+2T2017+type@asset+block/replicaset-3.png
Deployment • 管理理 Pod 與 ReplicaSet • 聲明式更更新 • ⽀支援
Rolling Update
Rolling Update
Rolling Update
Rolling Update
Rolling Update
Job • 啟動 Pod 並且執⾏行行指定次數 • Pod 如果執⾏行行錯誤,會重新開啟直到完成
Service • ⽤用來來存取 Pod 的資源 • 可透過 Kubernetes 內部的 DNS
來來對應 • 各種 Service Type: • ClusterIP • NodePort • LoadBalancer
ClusterIP Service https://cdn-images-1.medium.com/max/1600/1*I4j4xaaxsuchdvO66V3lAg.png
NodePort Service https://cdn-images-1.medium.com/max/1600/1*CdyUtG-8CfGu2oFC5s0KwA.png
LoadBalancer Service https://cdn-images-1.medium.com/max/1600/1*P-10bQg_1VheU9DRlvHBTQ.png
Ingress • 類似 Virtual Host 的概念念 • 可以⽤用 URL 來來
proxy 到不同的 service https://cdn-images-1.medium.com/max/2000/1*KIVa4hUVZxg-8Ncabo8pdg.png
Label • Key-Value • 可以放在任何的資源設定中作為識別 • 可透過 Selector 查詢
Selector • ⽤用來來查詢 Labels • 透過 Selector 可以查詢到關聯聯的 Labels
https://www.metaltoad.com/sites/default/files/2018-01/Screen%20Shot%202018-01-19%20at%204.23.36%20PM.png
Volume • 在 Pod 啟動時⾃自動掛載(需要先定義) • 可以掛載 Host 的檔案或是⽬目錄 •
也能掛 ConfigMap/ Secret
ConfigMap • ⽤用來來放各種設定 • 可以 mount 到 container 中使⽤用 •
Environment 設定可以放這
Secret • 基本上功能跟 ConfigMap ⼀一樣 • 不過有做 Base64 Encode •
適合放敏感性的資料
Let’s laravel it https://gitlab.com/kube-laravel/
Laravel requirements • Nginx/PHP-FPM • Database (MySQL) • Cache/Session store
(Redis) • Storage (S3/GCS) • Log (ELK) • Exception handler (Sentry)
Q & A “