0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Runtime Classを理解する

Last updated at Posted at 2025-10-07

目的

  • Runtime Class を理解する

手段

killercodaで手を動かす

環境

killercoda

Runtime Class とは

RuntimeClass(ランタイムクラス)は、Kubernetesの機能の一つで、Podのコンテナを実行するために使用するコンテナランタイムの設定を選択するためのものです。
これは、クラスター内で異なるコンテナランタイムや、同じランタイムでも異なる設定を使い分けることを可能にします。

Podごとに、標準のランタイム(例:runc)だけでなく、代替のランタイム(例:gVisor [高いセキュリティ] や Kata Containers [完全な仮想化環境])などを指定できるようになります。
これにより、ワークロードの特性(セキュリティ要件、パフォーマンス要件など)に応じて最適な実行環境を選べます。

つまり、node 上のコンテナランタイム(ex: Containerd, CRI-O)に Runtime Class(ex: gVisor)を設定しておき、yaml で pod 起動時に利用する Runtime Class を runtimeClassName フィールドで指定する流れですね。

気を付ける点は以下の通りです

  • 事前に Runtime Class は設定する必要がある
  • デフォルトの Runtime Class は runc
  • 特定の Runtime Class を指定する場合は runtimeClassName フィールドに事前設定した Runtime Class リソース名を指定

それぞれサンプル設定を確認します。

  • 事前に Runtime Class は設定する必要がある
  • デフォルトの Runtime Class は ruc
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
  name: gvisor # リソース名
handler: runsc # これがgVisorランタイムを指定するハンドラー名
# yaml ファイルとして保存後、k apply -f xxx.yaml でリソース作成

runsc はなぜ runsc なのか?

runscは、Googleが開発したセキュリティを強化したコンテナランタイムであるgVisorプロジェクトに含まれる実行可能ファイル(バイナリ)の名称です。
Open Container Initiative (OCI)のランタイム仕様に準拠しており、DockerやKubernetesなどの既存のコンテナツールと統合して、サンドボックス化されたコンテナを実行するために使用されます。

つまり、gVisor をインストした場合は、Runtime Class リソース作成時、handler は runsc を設定します。言い換えれば、gVisor を利用するという宣言ですね。

  • 特定の Runtime Class を指定する場合は runtimeClassName フィールドに事前設定した Runtime Class リソース名を指定
apiVersion: v1
kind: Pod
metadata:
  name: sec
spec:
  runtimeClassName: gvisor
  containers:
    - image: nginx:1.21.5-alpine
      name: sec
  dnsPolicy: ClusterFirst
  restartPolicy: Always

あとがき

Kubernetes は奥が深い...

ソース

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?