Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
LoK101.pdf
Search
Jerry
December 11, 2018
Technology
0
260
LoK101.pdf
Jerry
December 11, 2018
Tweet
Share
More Decks by Jerry
See All by Jerry
Gitlab CI 入門
cheng
0
320
Other Decks in Technology
See All in Technology
TypeScript 上達の道
ysknsid25
23
4.8k
CSPヘッダー導入で実現するWebサイトの多層防御:今すぐ試せる設定例と運用知見
llamakko
1
270
OpenTelemetry の Log を使いこなそう
biwashi
5
1.1k
AIに全任せしないコーディングとマネジメント思考
kikuchikakeru
0
280
[TechNight #91] Oracle Database 最新パフォーマンス分析手法
oracle4engineer
PRO
3
150
マルチモーダル基盤モデルに基づく動画と音の解析技術
lycorptech_jp
PRO
2
260
AI時代の知識創造 ─GeminiとSECIモデルで読み解く “暗黙知”と創造の境界線
nyagasan
0
160
AI エンジニアの立場からみた、AI コーディング時代の開発の品質向上の取り組みと妄想
soh9834
8
590
With Devin -AIの自律とメンバーの自立
kotanin0
2
790
Jitera Company Deck / JP
jitera
0
250
興味の胞子を育て 業務と技術に広がる”きのこ力”
fumiyasac0921
0
290
P2P ではじめる WebRTC のつまづきどころ
tnoho
1
270
Featured
See All Featured
Producing Creativity
orderedlist
PRO
346
40k
Art, The Web, and Tiny UX
lynnandtonic
301
21k
Building Adaptive Systems
keathley
43
2.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
283
13k
KATA
mclloyd
30
14k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Rails Girls Zürich Keynote
gr2m
95
14k
Into the Great Unknown - MozCon
thekraken
40
1.9k
Scaling GitHub
holman
461
140k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
110
19k
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 “