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
Witchcraft for Memory
pocke
1
720
Zephyr RTOSを使った開発コンペに参加した件
iotengineer22
1
180
LangSmith×Webhook連携で実現するプロンプトドリブンCI/CD
sergicalsix
1
180
作曲家がボカロを使うようにPdMはAIを使え
itotaxi
0
410
AIとともに進化するエンジニアリング / Engineering-Evolving-with-AI_final.pdf
lycorptech_jp
PRO
0
150
MUITにおける開発プロセスモダナイズの取り組みと開発生産性可視化の取り組みについて / Modernize the Development Process and Visualize Development Productivity at MUIT
muit
1
11k
Node-RED × MCP 勉強会 vol.1
1ftseabass
PRO
0
180
FrankenPHPでLaravelを動かしてみよう
yousaku
0
100
「Chatwork」の認証基盤の移行とログ活用によるプロダクト改善
kubell_hr
1
240
本が全く読めなかった過去の自分へ
genshun9
0
740
Tech-Verse 2025 Keynote
lycorptech_jp
PRO
0
1.6k
Should Our Project Join the CNCF? (Japanese Recap)
whywaita
PRO
0
310
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Making Projects Easy
brettharned
116
6.3k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
It's Worth the Effort
3n
185
28k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
The Language of Interfaces
destraynor
158
25k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
The Pragmatic Product Professional
lauravandoore
35
6.7k
A Tale of Four Properties
chriscoyier
160
23k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.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 “