$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
オリジナルのKubectlを作る
Search
katsunori nakajima
June 25, 2021
Business
0
420
オリジナルのKubectlを作る
katsunori nakajima
June 25, 2021
Tweet
Share
More Decks by katsunori nakajima
See All by katsunori nakajima
Kubernetesクラスタを組む
karosuwindam
0
410
Other Decks in Business
See All in Business
株式会社ヤプリ AI研修
tsujimura14
1
240
週4社員しながら個人開発にベットする / Betting on Personal Projects While Working a Four-Day Week
kohii00
4
2.9k
実体験:エンジニアの妊娠・出産と仕事/real-life-experience-pregnancy-childbirth-and-work-for-engineers
emiki
9
1.9k
らんみるぷろじぇくと採用情報
ranmil
0
200
株式会社琉球ウェルネス 会社説明資料
ryukyuwellness
0
120
Fuji Oil 2025 Board of Directors
tsogo817421
2
330
イクシアス株式会社 会社紹介資料
ixyas
0
2.6k
株式会社メディアドゥ 採用ピッチ資料
mediado
0
120
YADOKARI CULTURE DECK 2025
yadokari
0
220
NicoScan - 領収書・請求書をAI-OCRでExcel自動変換
raimiura
1
230
ホワイトプラス会社紹介資料 / wp_introduction
whiteplus_recruit
0
190
インキュデータ会社紹介資料
okitsu
3
47k
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
300
How STYLIGHT went responsive
nonsquared
100
6k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.1k
4 Signs Your Business is Dying
shpigford
186
22k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
16
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
310
Navigating Weather and Climate Data
rabernat
0
42
Marketing to machines
jonoalderson
1
4.3k
Transcript
オリジナルのKubectlを作 る 2021/06/25
Kubectlとは • Kuberentesの制御のCUIツール • DeploymentやServiceなどのリソース情報を制御できる • ~/.kube/configに書かれた情報(kubeconfig)をもとに Kubernetesネットワークにアクセスする
Kubectl get pod –A kubectl –n namespace describe pod kubectl
get service –A kubectl –n namespace describe service
PodとServiceを調べたりすることを ワンラインでできないのか?
Client-goというgo言語のライブラリがあ る
Client-goとは • KubernetesのAPIをたたくGo言語のライブラリ • これを使用すれば、Kubernetesの制御をプログラミングできる
使用するには • Go言語 v1.16以上のインストール • Kubernetes環境 • Kubeconfig(ローカルテスト用) • VS
Code(開発環境)
Go言語の使い方 • Go言語をv1.14からv1.16にアップデートで苦労したので • modファイルを作らないとbuildができない • go init mod 適当な名前
• 使用するpackageはmodに書かれていないとエラー • go get パッケージ • 「./フォルダ」で呼び出していたローカルライブラリの書き方 は、「モジュール名/フォルダ」で呼び出すことが可能
• 300行ぐらいで、以下のようなアプリができた。
まとめなど • Client-goを使用して、pod名とネームスペース、それに紐づい たserviceやポートを取得するアプリができた。 • コンテナ化して、podの情報監視も可能
Client-goを使用して Kubernetesクラスタを制御す るアプリを作ろう