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

第2章 Linuxネットワーク Linuxネットワーキング

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

Kubernetesにおけるネットワーキングの実装を理解するためには、Linuxにおけるネットワーキングの基礎を理解する必要がある。結局のところ、KubernetesはLinux(またはWindows!)マシンのための複雑な管理ツールであり、Kubernetesネットワークスタックで作業している間、これを無視することは難しい。この章では、Kubernetesで注目すべき分野に焦点を当てながら、Linuxネットワークスタックの概要を説明する。Linuxのネットワーキングとネットワーク管理に精通しているのであれば、この章は読み飛ばすか、読み飛ばしてもよいだろう。

チップ

この章()では、多くのLinuxプログラムを紹介している。man <program> でアクセスできるマニュアル(man)ページには、より詳細な情報が掲載されている。

基本

第1章で使った Goウェブサーバをもう一度見てみよう。このウェブサーバはポート8080でリッスンし、/へのHTTPリクエストに対して "Hello "を返す(例2-1参照)。

例2-1. Goによる最小ウェブサーバ
package main

import (
	"fmt"
	"net/http"
)

func hello(w http.ResponseWriter, _ *http.Request) {
	fmt.Fprintf(w, "Hello")
}

func main() {
	http.HandleFunc("/", hello)
	http.ListenAndServe("0.0.0.0:8080", nil)
}
警告

ポート1〜1023(ウェルノウンポートとも呼ばれる)は、バインドするのにroot権限が必要である。

つまり、典型的なウェブ・サービスは、ルート・ユーザとして実行されるべきではない。このため、多くのプログラミングは1024番ポート以上でリッスンすることになる(特にHTTPサービスでは8080番ポートがよく使われる)。可能であれば、非特権ポートでリッスンし、インフラ・リダイレクト(ロードバランサ転送、Kubernetesサービスなど)を使って、外部から見える特権ポートを非特権ポートでリッスンしているプログラムに転送する。

こうすることで、あなたのサービスの脆弱性を悪用する攻撃者が、過度に広範なパーミッションを利用できなくなる。

このプログラムがLinuxサーバーマシンで実行されていて、外部クライアントが/ にリクエストを出したとする。 サーバーでは何が起こるか? まず始めに、このプログラムはアドレスとポートをリッスンする必要がある。 このプログラムはそのアドレスとポートに対応するソケットを作成し、それにバインドする。 このソケットは、指定されたアドレスとポート(ここでは任意のIPアドレスで8080 )の両方宛てのリクエストを受け取る。

0.0.0.0 IPv4の 、IPv6の 、ワイルドカードアドレスである。それぞれのプロトコルのすべてのアドレスにマッチするため、ソケットバインディングに使用すると、利用可能なすべてのIPアドレスをリッスンする。[::]

これは、サービスを実行するマシンのIPアドレスを事前に知ることなく、サービスを公開するのに便利である。 ほとんどのネットワーク公開サービスは、この方法でバインドする。 ...

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