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
認証の仕組みとclient-go credential plugin / authentica...
Search
Hidetake Iwata
August 28, 2019
Programming
7
7.1k
認証の仕組みとclient-go credential plugin / authentication and client-go credential plugin
2019.8.28
Kubernetes Meetup Tokyo #22
Hidetake Iwata
August 28, 2019
Tweet
Share
More Decks by Hidetake Iwata
See All by Hidetake Iwata
Rewrite Go error handling using AST transformation
int128
1
1.2k
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.6k
CLIでOAuth/OIDCを快適に利用する
int128
0
700
AppEngine × Spring Boot × Kotlin
int128
0
80
いつものJIRA設定
int128
1
150
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
4.6k
本番環境のリリースを自動化した話
int128
0
670
Swagger × Spring Cloud
int128
0
80
The Evolution of System Architecture
int128
0
150
Other Decks in Programming
See All in Programming
Subclassing, Composition, Python, and You
hynek
3
190
Modern Functional Fluent CFML REST by Luis Majano
ortus24
0
160
ACES Meet におけるリリース作業改善の取り組み
fukucheee
0
150
Vue SFCのtemplateでTypeScriptの型を活用しよう
tsukkee
3
920
CSC509 Lecture 07
javiergs
PRO
0
140
Integrating AI in Your Enterprise Java Applications
ivargrimstad
0
870
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
8
750
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
140
Prompt Engineering for Developers @ AWS Community Day Adria 2024
slobodan
0
100
自分だけの世界を創るクリエイティブコーディング / Creative Coding: Creating Your Own World
chobishiba
2
2.1k
Memory API: Patterns, Use Cases, and Performance
josepaumard
2
200
空間の中でアイドルとレッスンする技術 - 1st "Vision" / Spatial Lesson technologies with my idol - 1st "Vision"
banjun
PRO
0
250
Featured
See All Featured
BBQ
matthewcrist
85
9.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
Designing Experiences People Love
moore
138
23k
Unsuck your backbone
ammeep
668
57k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
5
130
What's new in Ruby 2.0
geeforr
342
31k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
Raft: Consensus for Rubyists
vanstee
136
6.6k
What's in a price? How to price your products and services
michaelherold
243
11k
Embracing the Ebb and Flow
colly
84
4.4k
GraphQLとの向き合い方2022年版
quramy
43
13k
Transcript
認証の仕組みと client-go credential plugin 2019/8/28 Kubernetes Meetup Tokyo #22 Hidetake
Iwata (@int128)
None
今日お話しすること お話しすること • ユーザがKubernetesクライアント(kubectl)を操作する時,どのように認証情報 を取得しているか? お話ししないこと • 内部コンポーネントの認証(scheduler, kubelet等)
Kubernetesの認証 Kubernetesには不正なリクエストを防ぐために認証/認可がある. クライアントとサーバの間の認証は,TLSクライアント証明書,トークン,ユーザ名/パ スワードがサポートされている. kubectl (scheduler) (kubelet) ... kube-apiserver authorization:
Bearer TOKEN authorization: Basic XXXXXX TLSクライアント証明書 CA証明書
Kubernetesクライアントはkubeconfig(デフォルトでは~/.kube/config)に書いてある 静的な認証情報を利用してAPIサーバにアクセスする. Kubernetesクライアントの認証情報 kubectl client-go ~/.kube/config users: - name: hello-basic
user: client-certificate-data: LS... client-key-data: LS… password: YOUR_PASSWORD username: YOUR_USERNAME - name: hello-token user: token: YOUR_TOKEN 証明書と秘密鍵 ユーザ名/パスワード トークン
疑問:認証情報を更新するには? Q: トークン認証を利用している場合に,クライアントがサーバに送るトークンを新しい ものに更新したい.どうする? A: ユーザにkubeconfigのトークンを書き換えてもらう. Q: ユーザがつらいのでは? A: ・・・
auth-provider 静的な認証情報を扱うだけでなく,動的に認証情報を取得する仕組みが用意されて いる.コンパイル時に認証モジュール(auth-provider)を組み込む. https://github.com/kubernetes/client-go/tree/master/plugin/pkg/client/auth で実装されている kubectl client-go ~/.kube/config auth-provider 外部の認証情報
kubectlには以下のauth-providerが 組み込まれている. gcp, azure, openstack, oidc
疑問:組み込みモジュールの弊害 Q: 僕が考えた最強の認証方式に対応してください. A: ではgithub.com/kubernetes/client-goにプルリクをオナシャス!! Q: 強者のクラウドベンダしか対応してもらえないのでは・・・ A: ()
client-go credential plugin コンパイル時にモジュールを組み込むのではなく,外部コマンドを実行して動的に認 証情報を取得する仕組みが用意されている.(v1.11からbeta) kubectl client-go ~/.kube/config credential plugin
外部の認証情報 credential pluginはstdoutにJSON で認証情報を出力する. client-goはkubeconfigに書いてあ るcredential pluginを実行する.
Credential plugin の利用場面
aws-iam-authenticator(EKSのIAM認証) kubectlの実行時に裏でaws eks get-tokenを実行してトークンを取得する.ユーザは トークンを意識せずに透過的にKubernetesにアクセスできる. https://github.com/kubernetes-sigs/aws-iam-authenticator/pull/72 にてcredential pluginに対応 kubectl client-go
~/.kube/config aws eks get-token IAM master kube- apiserver aws-iam-au thenticator IAM トークン
kubelogin(OpenID Connect認証) kubectlの実行時に裏でkubelogin get-tokenを実行してIDトークンを取得する.ユー ザはトークンを意識せずに透過的にKubernetesにアクセスできる. kubectl client-go ~/.kube/config kubelogin get-token
OIDC Provider kube-apiserver OIDC Provider トークン authenticator https://github.com/int128/kubelogin からインストールできる
まとめ Kubernetesクライアントは以下からTLSクライアント証明書,トークン,ユーザ名/パス ワードといった認証情報を読み込んで,APIサーバに送信する. • kubeconfigに書いてある静的な認証情報 • 認証モジュール(auth-provider)が実行時に返す認証情報 • 外部コマンド(credential plugin)が実行時に返す認証情報
Special thanks: icons by https://icons8.com
参考資料 • client-go credential pluginsの仕様, https://kubernetes.io/docs/reference/access-authn-authz/authentication/ #client-go-credential-plugins • client-go credential
pluginsのプロポーザル, https://stupefied-goodall-e282f7.netlify.com/contributors/design-proposal s/auth/kubectl-exec-plugins/.