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.5k
認証の仕組みと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
880
AppEngine × Spring Boot × Kotlin
int128
0
120
いつものJIRA設定
int128
1
190
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
4.8k
本番環境のリリースを自動化した話
int128
0
780
Swagger × Spring Cloud
int128
0
110
The Evolution of System Architecture
int128
0
180
Other Decks in Programming
See All in Programming
High-Level Programming Languages in AI Era -Human Thought and Mind-
hayat01sh1da
PRO
0
780
ペアプロ × 生成AI 現場での実践と課題について / generative-ai-in-pair-programming
codmoninc
1
18k
AIともっと楽するE2Eテスト
myohei
6
2.6k
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
320
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
270
A full stack side project webapp all in Kotlin (KotlinConf 2025)
dankim
0
120
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
11k
レベル1の開発生産性向上に取り組む − 日々の作業の効率化・自動化を通じた改善活動
kesoji
0
220
The Modern View Layer Rails Deserves: A Vision For 2025 And Beyond @ RailsConf 2025, Philadelphia, PA
marcoroth
1
170
“いい感じ“な定量評価を求めて - Four Keysとアウトカムの間の探求 -
nealle
1
10k
XP, Testing and ninja testing
m_seki
3
250
5つのアンチパターンから学ぶLT設計
narihara
1
170
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
Into the Great Unknown - MozCon
thekraken
40
1.9k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
How to train your dragon (web standard)
notwaldorf
95
6.1k
Git: the NoSQL Database
bkeepers
PRO
430
65k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
BBQ
matthewcrist
89
9.7k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Designing Experiences People Love
moore
142
24k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Visualization
eitanlees
146
16k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
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/.