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.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
1.3k
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.7k
CLIでOAuth/OIDCを快適に利用する
int128
0
800
AppEngine × Spring Boot × Kotlin
int128
0
94
いつものJIRA設定
int128
1
170
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
4.7k
本番環境のリリースを自動化した話
int128
0
730
Swagger × Spring Cloud
int128
0
86
The Evolution of System Architecture
int128
0
160
Other Decks in Programming
See All in Programming
Honoとフロントエンドの 型安全性について
yodaka
7
1.4k
Serverless Rust: Your Low-Risk Entry Point to Rust in Production (and the benefits are huge)
lmammino
1
150
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
260
CDKを使ったPagerDuty連携インフラのテンプレート化
shibuya_shogo
0
100
Boos Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
230
『GO』アプリ データ基盤のログ収集システムコスト削減
mot_techtalk
0
150
自力でTTSモデルを作った話
zgock999
0
100
CDK開発におけるコーディング規約の運用
yamanashi_ren01
2
250
DRFを少しずつ オニオンアーキテクチャに寄せていく DjangoCongress JP 2025
nealle
2
260
『テスト書いた方が開発が早いじゃん』を解き明かす #phpcon_nagoya
o0h
PRO
8
2.4k
Rails 1.0 のコードで学ぶ find_by* と method_missing の仕組み / Learn how find_by_* and method_missing work in Rails 1.0 code
maimux2x
1
130
SwiftUI Viewの責務分離
elmetal
PRO
2
270
Featured
See All Featured
Visualization
eitanlees
146
15k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
A better future with KSS
kneath
238
17k
Site-Speed That Sticks
csswizardry
4
400
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Code Reviewing Like a Champion
maltzj
521
39k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
133
33k
Being A Developer After 40
akosma
89
590k
Rails Girls Zürich Keynote
gr2m
94
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/.