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
Kubernetes 入門 #3/kubernetes-hands-on-apps-for-k...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Hiroki Matsumoto
March 22, 2019
Technology
470
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kubernetes 入門 #3/kubernetes-hands-on-apps-for-k8ssa-#3
Hiroki Matsumoto
March 22, 2019
More Decks by Hiroki Matsumoto
See All by Hiroki Matsumoto
システム改善・育成のための障害対応訓練
hirokimatsumoto
0
270
CI/CD環境としてGitHub Actionsを選んだ理由
hirokimatsumoto
0
250
初めてのPSI試験 with Vault Associate
hirokimatsumoto
0
270
多数のプロダクトを開発・運用するためのツール環境
hirokimatsumoto
0
200
デプロイメント手法を選択する/Decide the way of deployment
hirokimatsumoto
2
1.1k
Podライフサイクルを体験する/ux-with-pod-lifecycle
hirokimatsumoto
1
590
Effective Container with VSCode Remote Container
hirokimatsumoto
0
180
GKE+Argo workflow
hirokimatsumoto
1
620
Ansibleをやろうと思ったきっかけ/The-reason-why-I-want-to-learn-Ansible
hirokimatsumoto
0
130
Other Decks in Technology
See All in Technology
AIで変わるエンジニアの働き方(仮)
naoinaoi
0
470
AI時代のアウトプット――変わったこと、変わらないこと / Devsumi 2026 Kansai #devsumi
jnchito
0
520
案件に一番詳しいAIを Amazon Bedrock AgentCore で作る ― 知見が知見を生むチームへ / Compounding Knowledge with AgentCore
yusukeshimizu
1
170
カーネルまで探検して理解するふたつの自動計装
sumiyae
0
250
三人寄ればチューリング完全
puhitaku
6
3k
Invisible to AI? Making TYPO3 Sites Quotable by AI Search Systems
wolfgangwagner
0
250
平文パスワードはログに“残り” ── 肝心の侵入は“痕跡すら残らない”
kuroneko13
0
120
VLMで2.3万枚のPyCon JP写真を検索!
terapyon
1
380
Head First モブプログラミング / Head First Mobprogramming
takaking22
10
12k
DDDのエッセンスを取り入れたAIでの開発
ak2ie
1
210
AI開発に用いられるHPC技術について
gpuunite_official
0
260
Oracle MCP Servers Explained
thatjeffsmith
0
430
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
500
Amusing Abliteration
ianozsvald
1
260
Ethics towards AI in product and experience design
skipperchong
2
350
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
800
Designing Experiences People Love
moore
143
24k
Writing Fast Ruby
sferik
630
63k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
Transcript
Kubernetes Sapporo for Beginners Kubernetes 入門 #3 ~ ハンズオン:コンテナにアクセス方法 ~
Kubernetes Sapporo for Beginners 自己紹介 松本 宏紀 ( まつもと ひろき
) • Kubernetes Sapporo for Beginners主催者。 • システム・アーキテクト • ソフトウェア・エンジニア • オフショアラボ・チームリーダー • デブサミ2019「Spring Bootでマイクロサービス作って苦労したお話」発表。 Twitter:@hirokimatsumo13
Kubernetes Sapporo for Beginners 今日のゴール 触って学ぶ。見て学ぶ。座学よりも体験を! • Serviceの種類と使い道を知る。 • Ingressの使い方。
• 上記を深く理解するための方法を理解する。
Kubernetes Sapporo for Beginners 事前準備 https://kubernetes-sapporo-for-beginners.github.io/hands-on/Step3-Service-Ingress/ #事前準備
Kubernetes Sapporo for Beginners ヘルプ! 助けてほしい時は手を挙げてください。 助けに Hirose さんがいきます。 (
早い者勝ち! )
Kubernetes Sapporo for Beginners Service 特定のPodの種類( Label Selector) に対してのアクセスを定義します。 TCP/UDP/(
SCTP ) プロトコルをサポート。L4ロードバランシング。 下記のような種類があります。 • ClusterIP • NodePort • LoadBalancer • ExternalName
Kubernetes Sapporo for Beginners 同一クラスタ内 Service: ClusterIP Node-A • クラスタ内で使うもの。
例:内部用バックエンドAPI。 • ロードバランシング方法は、バージョンやその実装に依存。 (GKEだと変更できない) proxy-modeの話はこちら! • クラスタIPを変えたい場合は、再作成が必要。 Node-B Node-C pod-0 pod-1 <<Service>> kube-proxy pod-2 $ kubectl apply -f ./hands-on/Step3-Service-Ingress/service/service-clusterip.yaml $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE greet-cip ClusterIP 10.102.66.190 <none> 80/TCP 19s $ kubectl exec -it cluster-pod -- curl http://greet-cip.default.svc.cluster.local/hello $ kubectl exec -it cluster-pod -- curl http://10.102.66.190/hello $ curl http://10.102.66.190/hello ← OK ← OK ← NG
Kubernetes Sapporo for Beginners 同一クラスタ内 Service: NodePort Node-A • クラスタ外から、各NodeのIPでアクセス可能。
例:GKEだと( 昔は ) ingressと併用。ChatBotとかで適当にア クセスしたい場合も利用してる。 • Port番号が衝突しないように注意が必要。 • Port番号は、30000〜32767の範囲で指定する。 • トラフィック制御はこちら! Node-B Node-C pod-0 pod-1 <<Service>> kube-proxy pod-2 $ kubectl apply -f ./hands-on/Step3-Service-Ingress/service/service-nodeport.yaml $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE greet-nodeport NodePort 10.107.87.220 <none> 80:30000/TCP 1s $ kubectl exec -it cluster-pod -- curl http://greet-nodeport.default.svc.cluster.local/hello $ curl http://10.107.87.220/hello $ curl http://localhost:30000/hello ← OK ← NG ← OK
Kubernetes Sapporo for Beginners 同一クラスタ内 Service: LoadBalancer Node-A • InternalなLBと外部公開用LBの指定が可能。
くわしくは、こちら! • Internal Loadbalancerとして使う事はある。 クラスタ間や、GCEインスタンスとの通信で利用する。 • 実装依存。GKEだとGCLBが出来る。 ※不要になったら削除しようね! • GCLBなどになるので、ファイアウォールの指定も可能。 Node-B Node-C pod-0 pod-1 <<Service>> LoadBalancer pod-2 $ kubectl apply -f ./hands-on/Step3-Service-Ingress/service/service-loadbalancer.yaml $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE greet-lb LoadBalancer 10.110.190.30 localhost 80:30001/TCP 1m $ kubectl exec -it cluster-pod -- curl http://greet-lb.default.svc.cluster.local/hello $ curl http://localhost:30001/hello $ curl http://localhost/hello ← OK ← NG( Only Docker for Desktop ) ← OK
Kubernetes Sapporo for Beginners 同一クラスタ内 Service: ExternalName Node-A • CNAMEとして別名を登録し、外部サービスへの接続先を制御
できる。 ※DNS制御なのでHTTPS通信時はハマるかも。 • 正直API-KEYとかでの連携や、アプリケーション側の設定を 使っていて使う場面に遭遇した事は無い。。。 Node-B Node-C pod-0 pod-1 foo.example.com pod-2 $ kubectl apply -f ./hands-on/Step3-Service-Ingress/service/service-externalname.yaml $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE search-engine ExternalName <none> iss.ndl.go.jp <none> 24s $ kubectl exec -it cluster-pod -- curl http://search-engine.default.svc.cluster.local/api/opensearch ← OK ← NG( Only Docker for Desktop ) ← OK bar.example.com kube-dns
Kubernetes Sapporo for Beginners その他のService、設定など • Multi-Port Service :複数のポートフォワード設定を定義できるよ。 •
Headless Service :DNSラウンドロビン方式。 kube-proxyを介さない。 • とりあえず困った公式の ここから色々追っていけば、解決するはず。 • Label Selectorによって、振り分けが変わる。
Kubernetes Sapporo for Beginners Ingress L7ロードバランシング。SSLターミネーション。主に外部(インターネット)からのアクセス を制御するために利用される。 よくある、「ロードバランサ」と思えばOKです。 Ingressの実態は、Ingress Controller次第です。後、実運用で使う際は、色々
annotationで指定しないと困る事になるので、各クラウドベンダーさんのドキュメントを 読みましょう。 ※例:静的IPの指定、SSL証明書の指定、ポート80番の不許可など。
Kubernetes Sapporo for Beginners 同一クラスタ内 Ingress Node-A • Ingressは、そのIngress Controller次第で、何が作られるか決
まる。※GKE→GCLB。 • 結構クラウドベンダー依存。 • Docker for DesktopだとIngress Controllerを事前に作成して おく必要がある。 https://github.com/docker/for-win/issues/1901 Node-B Node-C pod-0 pod-1 Ingress pod-2 $ kubectl delete -f ./hands-on/Step3-Service-Ingress/service/ $ kubectl apply -f ./hands-on/Step3-Service-Ingress/ingress/docker-ingress.yaml $ kubectl get ingress NAME HOSTS ADDRESS PORTS AGE ingress.extensions/greet-ingress * localhost 80 7m $ curl http://localhost/v1/hello $ curl http://localhost/v2/hello ← 一旦削除 ← Docker for Desktop用 ※gkeはgcp-ingress.yaml ← OK ← NG( Only Docker for Desktop ) ← OK
Kubernetes Sapporo for Beginners その他の設定など • ingress-nginx annotation • GCP
ingress annotation • その他は・・・調べていないです。 • Ingressで実装されている範囲は、結構バラバラ。長い間 betaです。
Kubernetes Sapporo for Beginners お掃除 使い終わっあたら消すんだよ!クラウド環境を使っている人は特に注意だよ! $ kubectl delete -f
./hands-on/Step3-Service-Ingress/ingress $ kubectl delete -f ./hands-on/Step3-Service-Ingress/prepare
Kubernetes Sapporo for Beginners 振り返り • Declarative object configuration •
再現不可能なスノーフレークサーバーからの脱却! • インフラエンジニア/ソフトウェアエンジニア。Dev/Opsみんながインフラまでの変更内 容を理解できる。再現できる。