インフラ系SEの技術メモ

雑なエンジニアが低信頼性のメモを書いています。参考程度にとどめてください。

(Kubernetes)runtimeClassNameを変更してみるメモ

自由に変更ができる

以下のような説明がある通りで

$ kubectl explain pod.spec.runtimeClassName
KIND:     Pod
VERSION:  v1

FIELD:    runtimeClassName <string>

DESCRIPTION:
     RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group,
     which should be used to run this pod. If no RuntimeClass resource matches
     the named class, the pod will not be run. If unset or empty, the "legacy"
     RuntimeClass will be used, which is an implicit class with an empty
     definition that uses the default runtime handler. More info:
     https://git.k8s.io/enhancements/keps/sig-node/585-runtime-class This is a
     beta feature as of Kubernetes v1.14.

Podに指定することができます。

試しに既存のPodのYAMLに同値を設定した上でApplyし直すと

$ kubectl apply -f test.yaml 
The Pod "sec" is invalid: spec: Forbidden: pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds`, `spec.tolerations` (only additions to existing tolerations) or `spec.terminationGracePeriodSeconds` (allow it to be set to 1 if it was previously negative)
  core.PodSpec{
        ... // 24 identical fields
        DNSConfig:          nil,
        ReadinessGates:     nil,
-       RuntimeClassName:   &"gvisor",
+       RuntimeClassName:   nil,
        Overhead:           nil,
        EnableServiceLinks: &true,
        ... // 2 identical fields
  }

初めてみるエラーに遭遇しました。同一Podに見えなかったんでしょうね。

適用後

消した後であればさくっと動かせます。
コンテナの中身をcrictl inspectで見比べると

<     "runtimeType": "io.containerd.runc.v2",
---
>     "runtimeType": "io.containerd.runsc.v1",

こんな感じ。本当だ、違ってる。

だからどうした、の世界ですがランタイムまで変えれるというのは興味深いですね。