Skip to Content
ネットワークとKubernetes
book

ネットワークとKubernetes

by James Strong, Vallery Lancey
March 2025
Intermediate to advanced
340 pages
6h 8m
Japanese
O'Reilly Media, Inc.
Content preview from ネットワークとKubernetes

第4章. Kubernetesネットワーク入門

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

Linuxとコンテナネットワーキングの重要なコンポーネントについて説明したので、Kubernetesのネットワーキングについてさらに詳しく説明する準備が整った。この章では、Podがクラスタの内部と外部でどのように接続するかについて説明する。また、Kubernetesの内部コンポーネントがどのように接続するかも取り上げる。サービスやイングレスのような、ディスカバリとロードバランサに関するより高いレベルのネットワーク抽象化については、次の章で説明する。

KubernetesNetworkingは、これら4つのネットワーク問題を解決しようとしている:

  • コンテナ間通信を高度に連係させる

  • ポッド間通信

  • Pod間通信

  • 社外とサービス間のコミュニケーション

Docker ネットワーキング・モデルは、デフォルトで仮想ブリッジ・ネットワークを使用する。これはホストごとに定義され、コンテナが接続するプライベート・ネットワークである。コンテナのIPアドレスにはプライベートIPアドレスが割り当てられるため、異なるマシン上で動作するコンテナは互いに通信できない。開発者は、ホストのポートをコンテナのポートにマッピングし、Dockerでノード間に到達するトラフィックをプロキシする必要がある。このシナリオでは、コンテナ間のポート衝突を避けるのはDocker管理者次第であり、通常はシステム管理者がこれにあたる。Kubernetesネットワーキングは、これとは異なる処理を行う。

Kubernetesのネットワーキング・モデル

Kubernetesネットワーキング・モデルは、マルチホスト・クラスター・ネットワーキングをネイティブにサポートしている。Podは、どのホストにデプロイされているかにかかわらず、デフォルトで相互に通信できる。KubernetesはCNIプロジェクトに依存し、以下の要件に準拠している:

  • すべてのコンテナはNATなしで相互に通信しなければならない。

  • ノードはコンテナとNATなしで通信できる。

  • コンテナのIPアドレスは、コンテナ自身がコンテナ外から見ているIPアドレスと同じである。

Kubernetesにおける作業の単位はPodと呼ばれる。Podには1つ以上のコンテナが含まれ、常にスケジュールされ、同じノード上で「一緒に」実行される。この接続性により、サービスの個々のインスタンスを個別のコンテナに分離できる。例えば、開発者はあるコンテナでサービスを実行し、別のコンテナでログフォワーダーを実行することを選択できる。別々のコンテナでプロセスを実行することで、別々のリソース割り当てを持つことができる(例えば、「ログフォワーダーは512MB以上のメモリを使用できない」など)。また、コンテナのビルドに必要なスコープを減らすことで、コンテナのビルドとデプロイの機械を分離することができる。

以下は最小限のPod定義である。多くのオプションを省略している。Kubernetesは、Podのステータスなど、読み取り専用のさまざまなフィールドを管理している:

apiVersion: v1
kind: Pod
metadata:
  name: go-web
  namespace: default
spec:
  containers:
  - name: go-web
    image: 
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

DevOpsのためのPython

DevOpsのためのPython

Noah Gift, Kennedy Behrman, Alfredo Deza, Grig Gheorghiu
Ansible:第3版

Ansible:第3版

Bas Meijer, Lorin Hochstein, René Moser
オブザーバビリティ・エンジニアリング

オブザーバビリティ・エンジニアリング

Charity Majors, Liz Fong-Jones, George Miranda, 大谷 和紀, 山口 能迪

Publisher Resources

ISBN: 9798341624627