Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Goでkubernetes operatorを実装してアプリのプレビュー環境を作る/go-ku...
Search
Takuma Kume
June 10, 2021
Technology
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Goでkubernetes operatorを実装してアプリのプレビュー環境を作る/go-kubernetes-operator
fukuoka.go#17
Takuma Kume
June 10, 2021
More Decks by Takuma Kume
See All by Takuma Kume
SRE/インフラエンジニアの市場価値とキャリアパス/Market value and career path for SRE-infrastructure engineers
takumakume
2
1.7k
【新卒研修】共通言語としてのSRE/SRE as a common language
takumakume
0
320
DDoSとの終わりなき戦い2025/endless_battle_with_ddos_attack_2025
takumakume
3
200
事業部CTOの現在地(パネルディスカッション)/Current-location-of-Division-CTO
takumakume
0
260
ロリポップ! for Gamersを支えるインフラ/lolipop for gamers infrastructure
takumakume
0
1.9k
ロリポップ! for Gamersの立ち上げ/lolipop for gamers launch
takumakume
0
3.1k
ホモグラフドメインを検出してみた/detect homograph domain
takumakume
0
870
ソフトウェアの継続的アップデートをコンテナ化によって加速させる/Accelerate continuous software updates with containerization
takumakume
0
5.8k
KubernetesにおけるSBOMを利用した脆弱性管理/Vulnerability_Management_with_SBOM_in_Kubernetes
takumakume
2
3.3k
Other Decks in Technology
See All in Technology
転んだ話が背中を預ける理由になる / A_story_about_falling_down_gives_you_a_reason_to_watch_each_other_s_backs.pdf
pauli
3
220
あなたの知らないAmazon VPC Route Server/Amazon VPC Route Server you don't know about
masakiokuda
2
220
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
350
ai_cording_with_k8s_knowledge.pdf
mochizuki875
1
280
いちAWSエンジニアのAI活用を振り返る #devio2026 / devio osaka 2026 kawahara
masahirokawahara
2
380
Google Cloud Next Tokyo 26登壇時のスクリプト
recruitengineers
PRO
0
190
生成AIを使って「人が」考える技術 ― AI時代の人機共想と実践ノウハウ|UNITT AC2026
ishiirikie
0
550
プロダクト価値を、 チームが使える判断軸に変える
vivion
0
110
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
leveragestech
PRO
0
150
The seven pitfalls of AI (revised version)
ufried
0
260
HacobuにおけるFDEとは/登壇資料(戸井田 裕貴)
hacobu
PRO
1
780
全社共通データ基盤をつくる。ソニーのDatabricks活用とデータガバナンス設計の裏側
sony
0
420
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Git: the NoSQL Database
bkeepers
PRO
433
67k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Product Roadmaps are Hard
iamctodd
55
13k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
The Limits of Empathy - UXLibs8
cassininazir
1
700
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Design in an AI World
tapps
1
350
Documentation Writing (for coders)
carmenintech
77
5.6k
Done Done
chrislema
187
17k
Transcript
GVLVPLBHP (PͰLVCFSOFUFTPQFSBUPSΛ࣮ͯ͠ ΞϓϦͷϓϨϏϡʔڥΛ࡞Δ
(.0ϖύϘגࣜձࣾ ϗεςΟϯάࣄۀ෦ 43&νʔϜ ΫϥυωΠςΟϒԽͷਪਐ ٱถഅ!UBLVNBLVNF
࣍ wlLVCFSOFUFTPQFSBUPSΛ࡞Δzͱ wࠓճ࣮ͨ͠ιϑτΣΞͷհ w։ൃܦҢ w(PʹΑΔ0QFSBUPS࣮ wॴײ
zLVCFSOFUFTPQFSBUPSΛ࡞Δzͱ
zLVCFSOFUFTPQFSBUPSΛ࡞Δzͱ apiserver kubectl apply Control plane Data plane controller manager
ReplicaSet Pod Pod ࢦఆ͞ΕͨPodͷΛ อͱ͏ͱ͢Δ ReplicaSetͷྫ replicas:2 PodΛ1ͭআͯ͠ ίϯτϩʔϥʔ͕ݕͯ͠ ࠶࡞͞ΕΔ
zLVCFSOFUFTPQFSBUPSΛ࡞Δzͱ apiserver kubectl apply Control plane Data plane controller manager
ReplicaSet Pod Pod ࢦఆ͞ΕͨPodͷΛ อͱ͏ͱ͢Δ ReplicaSetͷྫ replicas:2 PodΛ1ͭআͯ͠ ίϯτϩʔϥʔ͕ݕͯ͠ ࠶࡞͞ΕΔ kubernetes ͜ͷಈ͖Λ֦ுͰ͖Δ kubernetesΛ֦ு͢Δख๏ͷͻͱͭʹOperator͕͋Δ
zLVCFSOFUFTPQFSBUPSΛ࡞Δzͱ apiserver kubectl apply Control plane Data plane Custom Controller
Custom Resource Custom Resource Definition (CRD) + ಠࣗͷϦιʔεఆٛ CRDͷఆٛʹج͍ͮͨ Ϧιʔε CRΛίϯτϩʔϧͯ͠ ఆٛ͞Εͨঢ়ଶʹอͭ kubernetes operator ͷ࣮ମ
ࠓճ࣮ͨ͠ͷ
apiVersion: service-expose.../v1alpha1 kind: ServiceExpose metadata: name: example namespace: ns1 spec:
backend: service: name: example-svc port: number: 8080 domain: example.com path: / pathType: Prefix tlsEnable: true tlsSecretName: example-tls annotations: cert-manager.io/cluster-issuer: letsencrypt apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example namespace: ns1 annotations: cert-manager.io/cluster-issuer: letsencrypt spec: rules: - host: example-svc.ns1.example.com http: paths: - backend: service: name: example-svc port: number: 8080 path: / pathType: Prefix tls: - hosts: - example-svc.ns1.example.com secretName: example-tls backend: service: name: example-svc port: number: 8080 example-svc ns1 example.com example-svc ns1 example.com example-svc ns1 example.com ࢦఆͨ͠ServiceΛ IngressͰެ։͢Δ ެ։͢Δϗετ໊ͱͯ͠ αʔϏεσΟεΧόϦతʹ ࣗಈͰ༩͢Δ IUUQTHJUIVCDPNUBLVNBLVNFTFSWJDFFYQPTFPQFSBUPS αʔϏε໊ namespace υϝΠϯ Custom Resource
։ൃܦҢ
։ൃܦҢ w 8FCΞϓϦέʔγϣϯΛෳӡ༻͍ͯͯ͠ɺ։ൃؔऀ໊Ҏ্͍ Δ w 1VMM3FRVFTUຖͷϓϨϏϡʔڥΛLVCFSOFUFT্Ͱ࣮ߦ͍ͨ͠ w 1VMM3FRVFTU͕࡞͞ΕͨΒɺઐ༻ͷڥ্ཱ͕͕ͪΔ w ݱࡏͭͷTUBHJOHڥΛ։ൃऀͰڞ༗͍ͯ͠Δ
w σϓϩΠͷखؒ w ར༻ऀͷڝ߹ എܠ
kubernetes cluster app repo system manifests repo Pull Request Github
Actions ArgoCD Config ArgoCD Github Actions ArgoCD Config Pod Ingress Namespace: app-pr-XXX 1.PRͷ࡞ 2.PRͷϒϥϯνΛ kubernetesΫϥελʹ σϓϩΠ͢ΔͨΊͷ ArgoCDͷઃఆΛੜ commit Service 3.ArgoCDͷ ઃఆՃΛݕ 4.ArgoCDͷઃఆΛ σϓϩΠ 5.PRͷϒϥϯνͷ σϓϩΠΛ։࢝ dispatch argocd-util ίϚϯυͰੜ ʲ1VMM3FRVFTUຖͷϓϨϏϡʔڥʳ ArgoCDGithub ActionsΛ׆༻ͯ͠Pull ReqτϦΨʔͰGitOpsͰϓϨϏϡʔڥΛੜ͍ͯ͠Δ 6.PRͷϒϥϯνͷ ϓϨϏϡʔڥ͕࡞ΒΕΔ 7. external-dnsͰAϨίʔυ, cert-managerͰTLSূ໌ॻΛ ࣗಈઃఆ
!"" main.go #"" manifests !"" base $ !"" kustomization.yaml $
!"" app.deployment.yaml $ #"" app.service.yaml #"" overlays !"" production $ !"" kustomization.yaml $ #"" app.ingress.yaml #"" staging !"" kustomization.yaml #"" app.ingress.yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: app-pr-XXX spec: destination: namespace: app-pr-XXX server: https://kubernetes.default.svc source: path: manifests/overlays/staging repoURL: https://github.com/takumakume/app targetRevision: future-branch syncPolicy: syncOptions: - CreateNamespace=true ֤ڥͷmanifestsΛkustomizeͰཧ͍ͯ͠Δ #"" staging !"" kustomization.yaml #"" app.ingress.yaml Pull RequestຖʹNamespaceΛͬͯ stagingڥͷෳΛ࡞͍ͬͯΔ app-pr-XXX ʲ1VMM3FRVFTUຖͷϓϨϏϡʔڥʳ app repo
։ൃܦҢ ٕज़త՝ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: app-ingress
namespace: app spec: rules: - host: staging-app.example.com http: paths: - backend: service: name: app-svc port: number: 8080 path: / pathType: Prefix tls: - hosts: - staging-app.example.com secretName: app-tls staging-app.example.com staging-app.example.com w ڥͷෳ࡞Εͯɺ*OHSFTTͷϗετ ໊෦Λม͑Δ͜ͱ͕Ͱ͖ͳ͍ɻ w LVTUPNJ[Fͷ+40/1BUDIػೳɺZRίϚ ϯυͳͲͰஔͭͭ͠ద༻͢Δ͜ͱͰ ͖Δ͕ཧ͕ࡶʹͳΔɻʢܦݧࡁʣ w ద༻લͰNBOJGFTUTΛॻ͖࣮͑ͭͭ ߦ͢Δͱ(JU0QTʹΑΔԸܙ͕ബΕΔɻ ίί ίί
։ൃܦҢ ࣮ํ w (JU0QT͕Ͱ͖Δ͜ͱ w એݴతͰ͋Δ͜ͱ w ϓϨϏϡʔڥʹΞΫηε͢ΔͨΊͷϗετ໊ΛͲ͏͢Δ͔ʁ w
LVCFSOFUFTͷ4FSWJDF%JTDPWFSZ w 4&37*$&@/".&/".&"1"$&TWDDMVTUFSMPDBM w *OHSFTTͰ࣮ݱͰ͖ΔͱศརͰͳ͍͔
apiVersion: service-expose.../v1alpha1 kind: ServiceExpose metadata: name: example namespace: ns1 spec:
backend: service: name: example-svc port: number: 8080 domain: example.com path: / pathType: Prefix tlsEnable: true tlsSecretName: example-tls annotations: cert-manager.io/cluster-issuer: letsencrypt apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example namespace: ns1 annotations: cert-manager.io/cluster-issuer: letsencrypt spec: rules: - host: example-svc.ns1.example.com http: paths: - backend: service: name: example-svc port: number: 8080 path: / pathType: Prefix tls: - hosts: - example-svc.ns1.example.com secretName: example-tls backend: service: name: example-svc port: number: 8080 example-svc ns1 example.com example-svc ns1 example.com example-svc ns1 example.com ެ։͢Δ Service αʔϏεσΟεΧόϦతͳ ϗετ໊ΛࣗಈͰ༩ αʔϏε໊ namespace υϝΠϯ ࠶ܝ
kubernetes cluster app repo system manifests repo Pull Request Github
Actions ArgoCD Config ArgoCD Github Actions ArgoCD Config Pod Namespace: app-pr-XXX 1.PRͷ࡞ 2.PRͷϒϥϯνΛ kubernetesΫϥελʹ σϓϩΠ͢ΔͨΊͷ ArgoCDͷઃఆΛੜ commit Service 3.ArgoCDͷ ઃఆՃΛݕ 4.ArgoCDͷઃఆΛ σϓϩΠ 5.PRͷϒϥϯνͷ σϓϩΠΛ։࢝ 6.PRͷϒϥϯνͷ ϓϨϏϡʔڥ͕࡞ΒΕΔ dispatch argocd-util ίϚϯυͰੜ Service Expose ੜ app.app-pr-XXX.example.com Ingress 7. external-dnsͰAϨίʔυ, cert-managerͰTLSূ໌ॻΛ ࣗಈઃఆ ServiceExposeͷΈσϓϩΠ͢Δ͜ͱͰIngressࣗಈੜ͞ΕΔ
(PʹΑΔ0QFSBUPSͷ࣮
(PʹΑΔ0QFSBUPS࣮ w ࣮खஈ w IUUQTLVCFSOFUFTJPEPDTDPODFQUTFYUFOELVCFSOFUFTPQFSBUPS w 0QFSBUPS'SBNFXPSL w $/$'*ODVCBUJOH1SPKFDU
w (PΛ༻͍࣮ͨʹ͓͍ͯ෦ͰLVCFCVJMEFSΛར༻͍ͯ͠Δ
0QFSBUPS'SBNFXPSL w 0QFSBUPS4%, w LVCFSOFUFT"1*ʹਂ͍͕ࣝͳͯ͘ɺϩδοΫʹूதͰ͖ΔΑ͏ ʹӅณͯ͘͠Ε͍ͯΔ w ίʔυδΣωϨʔλʔ w
ςετ w ύοέʔδϯά
0QFSBUPS'SBNFXPSL w ࣮ʹ͋ͨͬͯͬͨ͜ͱ w 0QFSBUPS'SBNFXPSLͷެࣜυΩϡϝϯτ͕ॆ࣮͍ͯ͠ΔͷͰɺج ຊతʹͦ͜Λࢀর͢Δ IUUQTTELPQFSBUPSGSBNFXPSLJPEPDTCVJMEJOHPQFSBUPSTHPMBOH w
ͨ·ʹࡌ͍ͬͯͳ͍߹͕͋ΔͷͰɺLVCFCVJMEFSͷެࣜυΩϡϝ ϯτͰิ͢Δ IUUQTCPPLLVCFCVJMEFSJP w ϕετϓϥΫςΟεͷ࣮ફ IUUQTTELPQFSBUPSGSBNFXPSLJPEPDTCFTUQSBDUJDFTCFTUQSBDUJDFT
w 3FDPODJMFS-PPQͷ࣮͕ϝΠϯ w ྫɿʮ1PEΛݸ࣮ߦ͢Δʯͱఆٛ͢Εͦͷঢ়ଶʹऩଋ͢Δಈ͖ (PʹΑΔ0QFSBUPS࣮ Observe Diff Action ঢ়ଶΛऔಘ
ࠩΛݕग़ ࠩͷमਖ਼
w TFSWJDFFYQPTFPQFSBUPSͷ3FDPODJMFS-PPQ (PʹΑΔ0QFSBUPS࣮ Observe Diff Action - ੜ͖͢IngressͷSpecʁ -
ੜ͖͢Ingressͱݱࡏͷ Ingressͷࠩͳʹ͔ʁ - ࠩΛຒΊΔͨΊʹIngressͷ Create/Update/DeleteΛ࣮ߦ
w ςετ (PʹΑΔ0QFSBUPS࣮ ServiceExpose ঢ়ଶऔಘ Ingress ଘࡏ͢Δ͔ʁ Ingressͷ Ξοϓσʔτ
ඞཁ͔ʁ Ingress ੜ Ingress Ξοϓσʔτ Y Y N N Reconciler Loop w ্هͷΑ͏ʹ0QFSBUPSঢ়ଶભҠ͕ൃੜ͢Δɻ w ͋ΒΏΔύλʔϯͰ3FDPODJMFS-PPQ͕ႈʹͳΔΑ͏ʹςετ͠ ͍ͨɻ
w 0QFSBUPS4%,͕ҎԼͷπʔϧΛ༻͍ͯৼΔ͍ςετͷ࣮ߦڥΛ ఏڙ͍ͯ͠Δ w FOWUFTUDPOUSPMMFSSVOUJNFͷύοέʔδͰɺςετ༻ͷ LVCFSOFUFTDPOUSPMQMBOFΛఏڙ͢Δ w HJOLHP(PMBOHͷ#%%ςετϑϨʔϜϫʔΫ w
HPNFHB(PMBOHͷ.BUDIFS-JCSBSZ HJOLHPͱηοτͰ͏ (PʹΑΔ0QFSBUPS࣮
w ྫ͑ɺ4FSWJDF&YQPTF$VTUPN3FTPVSDF͕σϓϩΠ͞Εͨ͋ͱʹɺ 4UBUVT͕3FBEZʹભҠ͢ΔͷΛͪɺ*OHSFTT͕ੜͰ͖͍ͯΔ͔ͱ͍ ͏ςετ͕ॻ͚Δɻ (PʹΑΔ0QFSBUPS࣮
ॴײ
w (JU0QTͰΧόʔͰ͖ͳ͔ͬͨҰ෦ͷΛΓग़ͯ͠0QFSBUPSͱ͍ ͏ख๏ͰղܾͰ͖ͨɻ w ϓϨϏϡʔڥͷੜશମΛ0QFSBUPSͱ࣮ͯ͢͠Δ͜ͱߟ͑ ͕ͨɺιϑτΣΞΛγϯϓϧʹอͭ΄͏͕ྑ͍ͱߟ͑ͨɻ w (PͰ0QFSBUPSΛ࣮͢Δ্Ͱ0QFSBUPS4%,Λ͕ͬͨɺϩδοΫ ʹूதͰ͖ͯศརͩͬͨɻ
w (Pͱ͍͑ςʔϒϧۦಈςετΛΑ͘͏͕ɺঢ়ଶભҠΛςετ͢ Δ্Ͱ#%%ศརͩͬͨɻ ॴײ