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
k8s ecosystem management with using of Argo CD
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Kota Kimura
October 07, 2023
Technology
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
k8s ecosystem management with using of Argo CD
Kota Kimura
October 07, 2023
More Decks by Kota Kimura
See All by Kota Kimura
Operating and Migrating OpenTelemetry Collector in a 100-Cluster-Scale Multi-Tenant Environment
kkk777
0
8
KubeCon NA 2024 Recap
kkk777
0
19
Getting Started kubernetes
kkk777
0
63
story about confronting node failure due to excessive memory consumption in kubelet
kkk777
1
49
Other Decks in Technology
See All in Technology
新規事業を牽引する技術選定 〜フルスタックTypeScript開発の実践事例〜
nullnull
3
360
ポケモンの型をTypeScriptの型システムで表現してみた
subroh0508
0
350
サプライチェーンセキュリティの空白地帯 - 信頼できる”依存性”の未来を考える
rung
PRO
2
780
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.9k
ChatworkとBPaaS 異なる特性で学んだAI機能開発の ベストプラクティス
kubell_hr
2
3.1k
サイバーセキュリティ概論 / Introduction to Cybersecurity
ks91
PRO
0
170
Platform Engineering as a Product: Criteria for Improvement and Multi-Tenant Design
kumorn5s
0
520
美味しいスイスチーズを作ろう🧀🐭
taigamikami
1
260
ブロックチェーン / Blockchain
ks91
PRO
0
110
LLMと共に進化するプロセスを目指して
ymatsuwitter
12
3.6k
社内 AI エージェント Synapse と セマンティックレイヤーの育て方
hiroakis
0
320
Rubyで音を視る
ydah
1
110
Featured
See All Featured
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
150
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
390
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Side Projects
sachag
455
43k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
Rails Girls Zürich Keynote
gr2m
96
14k
Why Our Code Smells
bkeepers
PRO
340
58k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Building the Perfect Custom Keyboard
takai
2
780
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
410
What's in a price? How to price your products and services
michaelherold
247
13k
Transcript
Argo CD をフル活用した k8s エコシステム管理 Hackers Champloo CyberAgent group Infrastructure
Unit Kota Kimura
目次 1. Kubernetes 運用の課題 2. サイバーエージェントの KaaS AKE
3. Argo CD を活用した エコシステム管理 4. まとめ
自己紹介 木村 洸太 - Kota Kimura • 株式会社サイバーエージェント グループIT推進本部 CIU所属
2023年5月中途入社 • KaaS プロダクト AKE の開発・運用を担当 • 趣味はサウナ巡り 以前の沖縄来訪時の思い出 @ KKimura
Kubernetes 運用の課題 Kubernetes って、運用大変って聞くけど何が大変なの?本当に辛いの? • Kubernetes クラスタ自体の管理 • Kubernetes では足りない部分を埋めるエコシステムの管理
Kubernetes 運用の課題 Kubernetes って、運用大変って聞くけど何が大変なの?本当に辛いの? • Kubernetes クラスタ自体の管理 自前のオンプレ Kubernetes は大変だが、、、
マネージド Kubernetes (GKE / EKS / AKS) の利用で大幅カットできる 参考になる資料やブログ記事などもかなりたくさんある!! ※ 3ヶ月に1回 マイナーバージョンが上がっていくので、アップデート戦略は検討必要有
Kubernetes 運用の課題 Kubernetes って、運用大変って聞くけど何が大変なの?本当に辛いの? • Kubernetes では足りない部分を埋めるエコシステムの管理 そもそも塩漬けになりがち.... → k8s
API の廃止などのタイミングであげる エコシステムのマニフェストを手動で取得、書き換えて利用すると... Upstream の追従コストが高い オプションの変更 、推奨設定への変更、RBAC変更、etc ArgoCD / Prometheus / External Secret など
AKE - Kubernetes as a Service
AKE - Kubernetes as a Service • ユーザーが指定の k8s バージョンでクラスタを利用できる
→ ClusterAPI で実現 • 各クラスタで利用するアドオンの Enable / Disable が切り替え可能 → ArgoCD で実現 管理クラスタ ユーザークラスタ v1.26.5 External DNS v1.27.1 Cluster Autoscaler, ingress v1.25.10 Prometheus, External Secret プライベートクラウド版 マネージド Kubernetes
Argo CD を活用したエコシステム管理
再喝 : AKE - Kubernetes as a Service • ユーザーが指定の
k8s バージョンでクラスタを利用できる → ClusterAPI で実現 • 各クラスタで利用するアドオンの Enable / Disable が切り替え可能 → ArgoCD で実現 管理クラスタ ユーザークラスタ v1.26.5 External DNS v1.27.1 Cluster Autoscaler, ingress v1.25.10 Prometheus, External Secret プライベートクラウド版 マネージド Kubernetes これどう実現するの???
ざっくり Argo CD watch k8s クラスタ Argo CD deploy
kind: Application metadata: metadata: name: app spec: project: default source: repoURL:
[email protected]
:xxxxx/addons.git targetRevision: main path: xxx destination: server: 10.0.0.1:6443 namespace: app Application リソース ※ Argo CD 自体も k8s リソースとして定義して k8s クラスタ内にデプロイします ※ 所属チームでは、Argo CD 用クラスタ (管理クラスタ)に展開し 後述の ApplicationSet で各ユーザクラスタの同期をします 10.0.0.1:6443
[email protected]
:xxxxx/addons.git Kustomize / Helm によるデプロイが多い
Argo CD ApplicationSet Generator 条件にしたがって、Application リソースを作成する拡張機能 ApplicationSet : • Cluster
generator Argo CD Cluster Secret を条件に作成 ※ 他にも Git generator など様々あります kind: ApplicationSet metadata: name: app spec: generators: - clusters: {} template: metadata: name: 'app-{{ name }}' spec: project: default source: repoURL:
[email protected]
:xxxxx/addons.git targetRevision: main path: manifests/example-app/overlays/release destination: server: '{{ server }}' kind: Secret metadata: name: kimura namespace: argocd stringData: name: kimura-cluster server: 10.0.0.1:6443 config: (Argo CD の kubeconfig 相当) kind: Secret metadata: name: hackers-champloo namespace: argocd stringData: name: champloo-cluster server: 10.0.0.2:6443 config: (Argo CD の kubeconfig 相当) kind: Application metadata: metadata: name: app-kimura-cluster spec: .... destination: server: 10.0.0.1:6443 kind: Application metadata: metadata: name: app-champloo-cluster spec: .... destination: server: 10.0.0.2:6443 https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Generators/ ※ Cluster が作成されたら、Secret リソースを作成する自作カスタムコントローラーを開発
利用アドオンの切り替え Generator の Selector を利用 kind: ApplicationSet metadata: name:
app spec: generators: - clusters: selector: matchExpressions: - key: addons.ake.cycloud.io/app operator: In values: - “true” template: {...} Argo CD Cluster Secret の label / annotation の値を元に Application リソースを作成するか分岐 kind: Secret metadata: name: kimura namespace: argocd labels: addons.ake.cycloud.io/app: “true” addons.ake.cycloud.io/app2: “false” stringData: {...} kind: Secret metadata: name: hackers-champloo namespace: argocd labels: addons.ake.cycloud.io/app: “false” addons.ake.cycloud.io/app2: “false” stringData: {...} kind: Application metadata: metadata: name: app-kimura-cluster spec: .... destination: server: 10.0.0.1:6443 ユーザーのクラスタ作成/更新時のパラメータを元に Secret リソースの labelの値を設定
アプリケーションの挙動変更 ユーザーが指定する値を変数として、アプリケーションに渡して、挙動を変更したい ex) Datadog で利用する API Key • Helm
で デプロイする場合 values に値を渡して挙動を変更可能 kind: ApplicationSet metadata: name: datadog spec: template: spec: source: helm: parameters: - name: ake.apikey value: {{ metadata.annotations…}} • Kustomize で デプロイする場合 ApplicationSet の機能では、外部からパラメータを渡すことができない 後述の Argo CD Config Management Plugins を実装することで実現
Argo CD Config Management Plugins 任意のコマンドを実行して、マニフェストを生成できるプラグイン機能 argocd-repo-server の サイドカーコンテナとして設定を加える apiVersion:
apps/v1 kind: Deployment metadata: name: argocd-repo-server spec: {...} containers: - name: my-plugin command: [/var/run/argocd/argocd-cmp-server] image: quay.io/argoproj/argocd volumeMounts: {...} - mountPath: /home/argocd/cmp-server/config/plugin.yaml subPath: plugin.yaml name: cmp-my-plugin volumes: - configMap: name: my-plugin-config name: cmp-my-plugin apiVersion: v1 kind: ConfigMap metadata: name: my-plugin-config data: plugin.yaml: | apiVersion: argoproj.io/v1alpha1 kind: ConfigManagementPlugin metadata: name: my-plugin spec: init: command: [sh, -c, 'echo "Initializing..."'] generate: command: [sh, -c, 'echo "Generating…”] init (前処理) と generate(生成処理) を定義できる Config Map をサイドカーにマウント
Argo CD Config Management Plugins 具体例 : sed 等で該当ファイルの値を埋める apiVersion:
v1 kind: ConfigMap metadata: name: my-plugin-config data: plugin.yaml: | {...} spec: init: command: [sh, -c, “ sed -i -e \”s|__CPU_LIMIT__|$ARGOCD_ENV_CPU_LIMIT|g\” ./my-replace.yaml ] generate: command: [ kustomize, build, . ] apiVersion: v1 kind: Pod metadata: name: example spec: {...} resources: limits: cpu: __CPU_LIMIT__ my-replace.yaml 値の書き換え 値の代入 kind: ApplicationSet metadata: name: my-app spec: template: spec: source: plugin: name: my-plugin env: - name: CPU_LIMIT value: {{ metadata.annotations…}} ※ Application から 渡される環境変数では、 prefix に 「ARGOCD_ENV」がつく
まとめ
まとめ • Argo CD の機能を活用することで柔軟にエコシステムの管理が可能 • Argo CD は多機能で面白い!今後も Deep
Dive していきたい! • とはいえ複雑なカスタマイズをしすぎると運用負荷が高まるので 柔軟性をどこまで持たせるかを考えるのが、 Platform サービスを開発する面白みの醍醐味