Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
認証の仕組みとclient-go credential plugin / authentication and client-go credential plugin
Hidetake Iwata
August 28, 2019
Programming
7
5.3k
認証の仕組みと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
880
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.2k
CLIでOAuth/OIDCを快適に利用する
int128
0
190
AppEngine × Spring Boot × Kotlin
int128
0
64
いつものJIRA設定
int128
1
86
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
3.8k
本番環境のリリースを自動化した話
int128
0
460
Swagger × Spring Cloud
int128
0
50
The Evolution of System Architecture
int128
0
50
Other Decks in Programming
See All in Programming
人類には難しいZynqで組み込みRust
ikemori
0
490
機能横断型チームにおける技術改善
takeshiakutsu
3
450
あなたの会社の古いシステム、なんとかしませんか?~システム刷新から考えるDX化への道筋とバリエーション~/webinar20220420-systems
grapecity_dev
0
130
Micro Frontends with Module Federation: Beyond the Basics @jax2022
manfredsteyer
PRO
1
290
LOWYAの信頼性向上とNew Relic
kazumax55
4
350
How useEvent would change our applications
koba04
1
1.6k
アプリのログをチーム外で活用してもらうためにやったこと
shotakashihara
0
180
microCMS × Shopifyで、ECサイトがリニューアル後急成長した話
microcms
0
470
TSDサービスRecap ~PMBOK®ガイド第7版超速まるわかりガイド~|ミツエーリンクスTSD
mlctsd
0
100
もしも、 上司に鬼退治を命じられたら~プロジェクト計画編~
higuuu
0
270
Jetpack Compose 頑張らないPreviewParameterProvider
horie23
0
100
読みやすいコードを書こう
yutorin
0
400
Featured
See All Featured
How GitHub (no longer) Works
holman
296
140k
Build your cross-platform service in a week with App Engine
jlugia
219
17k
Designing on Purpose - Digital PM Summit 2013
jponch
106
5.6k
Writing Fast Ruby
sferik
612
57k
GraphQLとの向き合い方2022年版
quramy
16
8.1k
The Invisible Side of Design
smashingmag
289
48k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
224
49k
Design by the Numbers
sachag
271
17k
Designing Experiences People Love
moore
130
22k
Art Directing for the Web. Five minutes with CSS Template Areas
malarkey
196
9.4k
The Pragmatic Product Professional
lauravandoore
19
2.9k
GraphQLの誤解/rethinking-graphql
sonatard
24
6.2k
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/.