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
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
260
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
610
Ansibleをやろうと思ったきっかけ/The-reason-why-I-want-to-learn-Ansible
hirokimatsumoto
0
120
Other Decks in Technology
See All in Technology
サイバー捜査員研修(前半)
nomizone
1
1.9k
事業価値と Engineering 2026年度版
recruitengineers
PRO
44
22k
サイバー捜査員研修(後半)
nomizone
1
810
今こそ聞きたいソフトウェア設計 ドメイン駆動設計再入門
masuda220
PRO
17
6.8k
もう一度考える SRE チームの作り方・育て方 / Rethinking SRE #1: Building and Growing SRE Teams
rrreeeyyy
6
1k
【CEDEC2026】次世代デジタルカードゲームのサーバー設計と運用 〜『Shadowverse: Worlds Beyond』の舞台裏~
cygames
PRO
1
970
GitHub CopilotのFinOps- AI CreditのObservabilityと価値を生むためのエージェント設計
yuriemori
0
140
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
53k
【CEDEC2026】グラフィックスエンジニアのためのニューラルシェーディング入門
cygames
PRO
0
120
Pavlokで始める電撃駆動開発
sgrsn
0
180
20260807_第6回_関東kaggler会LT_claw系bot xangiと始める、"寂しくない" kaggle
sugupoko
0
200
SmartHR Engineering Team Deck
smarthr
1
1.2k
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
370
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
780
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
690
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
420
Test your architecture with Archunit
thirion
1
2.3k
Un-Boring Meetings
codingconduct
0
380
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
200
The SEO Collaboration Effect
kristinabergwall1
1
520
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
590
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
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みんながインフラまでの変更内 容を理解できる。再現できる。