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 / authentication and client-go credential plugin
Search
Hidetake Iwata
August 28, 2019
Programming
7
6.8k
認証の仕組みと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.1k
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.5k
CLIでOAuth/OIDCを快適に利用する
int128
0
550
AppEngine × Spring Boot × Kotlin
int128
0
71
いつものJIRA設定
int128
1
150
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
4.4k
本番環境のリリースを自動化した話
int128
0
620
Swagger × Spring Cloud
int128
0
77
The Evolution of System Architecture
int128
0
140
Other Decks in Programming
See All in Programming
The grand strategy of Ruby Parser
yui_knk
5
280
The Cutting Edge Of Versioning (LambdaConf 2024)
chriskrycho
0
250
ソースコードを美しくたもつために ~コードレビューの認知限界を突破し、年間400リリースを達成する~
kotauchisunsun
1
730
Embedding it into Ruby code
soutaro
1
310
Balkan Ruby 2024 — How and why to run SQLite on Rails in production
fractaledmind
0
110
仕様と実装で学ぶOpenTelemetry
drumato
2
970
Docker_OSS_ホスティング入門
satokoki645
0
140
Escolhendo (ou não) o melhor ORM para o seu projeto
andreiacsilva
1
160
TypeScriptのパフォーマンス改善
yajihum
14
5k
Documentation testsの恩恵 / Documentation testing benefits
ssssota
1
560
ペパボOpenTelemetry革命
pyama86
2
980
Adding Security to Microcontroller Ruby
sylph01
1
160
Featured
See All Featured
The Invisible Side of Design
smashingmag
294
49k
It's Worth the Effort
3n
180
27k
Side Projects
sachag
451
41k
What's new in Ruby 2.0
geeforr
338
31k
Gamification - CAS2011
davidbonilla
77
4.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
39
2.5k
Building an army of robots
kneath
300
41k
4 Signs Your Business is Dying
shpigford
176
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
352
28k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
323
20k
Teambox: Starting and Learning
jrom
128
8.4k
Producing Creativity
orderedlist
PRO
338
39k
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/.