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
460
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
240
初めてのPSI試験 with Vault Associate
hirokimatsumoto
0
260
多数のプロダクトを開発・運用するためのツール環境
hirokimatsumoto
0
200
デプロイメント手法を選択する/Decide the way of deployment
hirokimatsumoto
2
1k
Podライフサイクルを体験する/ux-with-pod-lifecycle
hirokimatsumoto
1
580
Effective Container with VSCode Remote Container
hirokimatsumoto
0
170
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
事業会社における 機械学習・推薦システム技術の活用事例と必要な能力 / ml-recsys-in-layerx-wantedly-2026
yuya4
0
140
LayerX コーポレートエンジニアリング室におけるサプライチェーンセキュリティへの取り組み / Supply Chain Security at LayerX Corporate Engineering
yuyatakeyama
3
810
【Snowflake Summit 2026 Recap!!】Snowflake Summit Deep Dive: Security & Governance
civitaspo
1
300
複数のSONiCディストリビューションを触りながら比較してみた
sonic
0
110
不要なレビューをAIにまかせて AIコーディングの環境改善を加速した
shoota
1
250
ぼっちではじめた登壇が「51名」「241件」の発信に化けた
subroh0508
1
300
40代で“やっとエンジニアになれた”――閉じた学びを開き、空の青さを知る / 20260628 Naoki Takahashi
shift_evolve
PRO
4
660
気軽に使える"情報のハブ"としてのNotion活用 〜フロー情報の集積点 と、 Claude Code × Notion AI〜
syucream
1
180
クラウドファンディング版StackChan 3体(4体)をインタラクティブな体験型作品にして展示もした話 / スタックチャンお誕生日会2026
you
PRO
0
170
入門!AWS Blocks
ysuzuki
1
180
Oracle Cloud Infrastructure:2026年6月度サービス・アップデート
oracle4engineer
PRO
0
260
AWS Security Hub CSPMの成功・失敗体験
cmusudakeisuke
0
510
Featured
See All Featured
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
210
Technical Leadership for Architectural Decision Making
baasie
3
420
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
170
Writing Fast Ruby
sferik
630
63k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
240
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
170
Between Models and Reality
mayunak
4
350
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
A designer walks into a library…
pauljervisheath
211
24k
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みんながインフラまでの変更内 容を理解できる。再現できる。