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
190
デプロイメント手法を選択する/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
Databricks 月刊サービスアップデート 2026年05月号
tyosi1212
0
210
サプライチェーンセキュリティの空白地帯 - 信頼できる”依存性”の未来を考える
rung
PRO
2
780
ルールやカスタム機能、どう使う?理想の出力を引き出すために今知りたいIBM Bob 5つの機能
muehara
1
360
社内 AI エージェント Synapse と セマンティックレイヤーの育て方
hiroakis
0
260
Socrates × Looker 〜セマンティックレイヤーで進化するデータ分析エージェント〜
hanon52_
0
310
実装は速くなった、レビューはどうする? ― 自身のレビューをAIで再現させるサーヴァントエンジニアリングのすゝめ / Implementation got faster. So what about reviews? — An invitation to Servant Engineering: Recreating your own code reviews with AI
nrslib
7
4.2k
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development
yoshidashingo
1
380
Building applications in the Gemini API family.
line_developers_tw
PRO
0
2.1k
SIer20年! 培ったスキルがスタートアップで輝く時
shucho0103
0
590
Databricks における 生成AIガバナンスの実践
taka_aki
1
340
Diagnosing performance problems without the guesswork
elenatanasoiu
0
170
ChatworkとBPaaS 異なる特性で学んだAI機能開発の ベストプラクティス
kubell_hr
2
3.1k
Featured
See All Featured
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
560
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Accessibility Awareness
sabderemane
1
130
Git: the NoSQL Database
bkeepers
PRO
432
67k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
210
Visualization
eitanlees
152
17k
We Have a Design System, Now What?
morganepeng
55
8.2k
Amusing Abliteration
ianozsvald
1
200
A better future with KSS
kneath
240
18k
We Are The Robots
honzajavorek
0
240
Crafting Experiences
bethany
1
170
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みんながインフラまでの変更内 容を理解できる。再現できる。