CRI 플러그인 설정 가이드
containerd를 Kubernetes의 컨테이너 런타임으로 쓰려면 CRI 플러그인 설정을 이해해야 해요. CRI 플러그인 설정은 containerd 설정(기본 경로: /etc/containerd/config.toml)의 일부예요. 이 문서는 설정 버전, cgroup 드라이버, snapshotter, 런타임 클래스, 이미지 pull, 레지스트리, CNI 템플릿까지 CRI 플러그인 설정 항목을 하나씩 짚어 줘요.
출처: 문서
본문
이 문서는 CRI 플러그인 설정에 대한 설명을 담고 있어요. CRI 플러그인 설정은 containerd 설정(기본 경로: /etc/containerd/config.toml)의 일부예요.
containerd 설정에 대해 더 알고 싶으면 여기를 참고하세요.
[plugins."io.containerd.grpc.v1.cri"] 섹션은 CRI에만 해당하는 설정이라는 점에 유의하세요. ctr, nerdctl, Docker/Moby 같은 다른 containerd 클라이언트는 이 섹션을 인식하지 않아요.
설정 버전(Config versions)
/etc/containerd/config.toml의 내용은 반드시 버전 헤더로 시작해야 해요. 예를 들면:
설정 버전 3은 containerd v2.0에서 도입됐어요. containerd 1.x에서 쓰던 설정 버전 2도 여전히 지원되며, 자동으로 설정 버전 3으로 변환돼요.
더 자세한 내용은 ../PLUGINS.md를 참고하세요.
기본 설정(Basic configuration)
Cgroup 드라이버(Cgroup Driver)
containerd와 Kubernetes는 기본적으로 레거시 cgroupfs 드라이버로 cgroup을 관리하지만, systemd 기반 호스트에서는 cgroups의 "single-writer" 규칙을 지키기 위해 systemd 드라이버를 쓰는 게 좋아요.
containerd가 systemd 드라이버를 쓰도록 설정하려면 /etc/containerd/config.toml에 다음 옵션을 넣으세요:
- containerd 2.x인 경우
[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc.options]
SystemdCgroup = true
- containerd 1.x인 경우
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
containerd 외에도 KubeletConfiguration이 "systemd" cgroup 드라이버를 쓰도록 설정해야 해요. KubeletConfiguration은 보통 /var/lib/kubelet/config.yaml에 있어요:
apiVersion: kubelet.config.k8s.io/v1beta1
cgroupDriver: "systemd"
kubeadm 사용자라면 kubeadm 문서도 함께 보세요.
참고: Kubernetes v1.28은 cgroup 드라이버 자동 감지를 알파 기능으로 지원해요.
KubeletCgroupDriverFromCRIkubelet feature gate를 켜면 kubelet이 CRI 런타임에서 cgroup 드라이버를 자동으로 감지하고, 위의KubeletConfiguration설정 단계는 필요하지 않아요.cgroup 드라이버를 결정할 때 containerd는 기본 런타임 클래스부터 시작해 runc 기반 런타임 클래스들의
SystemdCgroup설정을 사용해요. runc 기반 런타임 클래스가 설정돼 있지 않으면 containerd는 systemd가 실행 중인지 판단하는 방식으로 자동 감지에 의존해요. 예상치 못한 동작을 피하려면 모든 runc 기반 런타임 클래스가 같은SystemdCgroup설정을 갖도록 구성해야 해요.kubelet의 cgroup 드라이버 자동 설정 기능은 containerd v2.0 이상에서 지원돼요.
Snapshotter
기본 snapshotter는 overlayfs예요(Docker의 overlay2 스토리지 드라이버와 비슷한 것):
- containerd 2.x인 경우
[plugins.'io.containerd.cri.v1.images']
snapshotter = "overlayfs"
- containerd 1.x인 경우
[plugins."io.containerd.grpc.v1.cri".containerd]
snapshotter = "overlayfs"
다른 지원 snapshotter는 여기를 참고하세요.
런타임 클래스(Runtime classes)
다음 예제는 containerd에 커스텀 런타임을 등록하는 방법이에요:
- containerd 2.x인 경우
[plugins."io.containerd.cri.v1.runtime".containerd]
default_runtime_name = "crun"
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes]
# crun: https://github.com/containers/crun
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes.crun]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes.crun.options]
BinaryName = "/usr/local/bin/crun"
# gVisor: https://gvisor.dev/
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes.gvisor]
runtime_type = "io.containerd.runsc.v1"
# Kata Containers: https://katacontainers.io/
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes.kata]
runtime_type = "io.containerd.kata.v2"
- containerd 1.x인 경우
[plugins."io.containerd.grpc.v1.cri".containerd]
default_runtime_name = "crun"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
# crun: https://github.com/containers/crun
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.crun]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.crun.options]
BinaryName = "/usr/local/bin/crun"
# gVisor: https://gvisor.dev/
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.gvisor]
runtime_type = "io.containerd.runsc.v1"
# Kata Containers: https://katacontainers.io/
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.kata]
runtime_type = "io.containerd.kata.v2"
추가로, 다음 RuntimeClass 리소스들을 cluster-admin 역할로 클러스터에 설치해야 해요:
kind: RuntimeClass
metadata:
name: crun
handler: crun
---
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: gvisor
handler: gvisor
---
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: kata
handler: kata
파드에 런타임 클래스를 적용하려면 .spec.runtimeClassName을 설정하세요:
kind: Pod
spec:
runtimeClassName: crun
Kubernetes 문서도 함께 보세요.
이미지 Pull 설정(containerd v2.1 이후)(Image Pull Configuration (since containerd v2.1))
이미지 Pull을 위한 Transfer Service(Transfer Service for Image Pull)
containerd v2.1부터 CRI 플러그인은 클라이언트 기반 pull 대신 containerd의 Transfer Service를 기본으로 사용해 이미지를 pull해요.
Transfer Service를 설정하려면 config.toml에 다음 설정을 사용하세요:
# Transfer service specific configurations
max_concurrent_downloads = 3
unpack_config = { ... }
로컬 Pull 모드(Local Pull Mode)
Transfer Service 대신 클라이언트 기반 pull 방식을 쓰고 싶다면, CRI 이미지 설정에 use_local_image_pull = true를 넣으면 돼요:
use_local_image_pull = true
설정 차이와 로컬 모드로의 자동 폴백(Configuration differences and automatic fallback to Local Mode)
이미지 pull 설정을 지정하는 방식은 Transfer Service와 Local Pull 모드 사이에 차이가 있어요:
| CRI 이미지 설정 옵션 | Local Pull | Transfer Service Pull |
|---|---|---|
| Snapshotter | ✅ 지원 | ✅ 지원 |
| DisableSnapshotAnnotations | ✅ 지원 | ⚠️ snapshotter 플러그인에서 설정해야 함:[proxy_plugins.stargz.exports]enable_remote_snapshot_annotations = "true" |
| ImagePullProgressTimeout | ✅ 지원 | ✅ 지원 |
| DiscardUnpackedLayers | ✅ 지원 | ❌ 미지원 |
| PinnedImages | ✅ 지원 | ✅ 지원 |
| Registry Settings | ✅ 모두 지원 | ⚠️ ConfigPath와 Headers만 지원 (Mirrors, Configs, Auths는 미지원, deprecated이기도 함) |
| ImageDecryption | ❌ 비활성화 | ❌ 비활성화 |
| MaxConcurrentDownloads | ✅ CRI Image 설정 사용 | ⚠️ transfer service 플러그인 plugins."io.containerd.transfer.v1.local"에서 설정해야 함 |
| ImagePullWithSyncFs | ✅ 지원 | ❌ 미지원 |
| StatsCollectPeriod | ✅ 지원 | ✅ 지원 |
호환성을 보장하기 위해, containerd 2.1은 설정 충돌을 자동으로 감지하고 필요하면 로컬 이미지 pull 모드로 폴백해요.
CRI 이미지 설정에 다음 항목이 하나라도 있으면, containerd는 자동으로 use_local_image_pull = true를 설정하고 경고를 기록해요:
DisableSnapshotAnnotations = falseDiscardUnpackedLayers = trueRegistry.Mirrors가 설정된 경우Registry.Configs가 설정된 경우Registry.Auths가 설정된 경우MaxConcurrentDownloads != 3ImagePullWithSyncFs = true
경고 메시지는 어떤 설정 옵션이 폴백을 트리거했는지 알려주고, Transfer Service를 쓸 때 그 옵션을 올바르게 설정하는 방법을 안내해요.
전체 설정(Full configuration)
각 설정 항목의 설명과 기본값은 다음과 같아요:
- containerd 2.x인 경우
# - Version 3 (Recommended for containerd 2.x): Introduced in containerd 2.0.
# Several plugin IDs have changed in this version.
# - Version 2 (Recommended for containerd 1.x): Introduced in containerd 1.3.
# Still supported in containerd v2.x.
# Plugin IDs are changed to have prefixes like "io.containerd.".
# - Version 1 (Default): Introduced in containerd 1.0. Removed in containerd 2.0.
version = 3
[plugins]
[plugins.'io.containerd.cri.v1.images']
snapshotter = 'overlayfs'
disable_snapshot_annotations = true
discard_unpacked_layers = false
max_concurrent_downloads = 3
image_pull_progress_timeout = '5m0s'
image_pull_with_sync_fs = false
stats_collect_period = 10
use_local_image_pull = false
[plugins.'io.containerd.cri.v1.images'.pinned_images]
sandbox = 'registry.k8s.io/pause:3.10.2'
[plugins.'io.containerd.cri.v1.images'.registry]
config_path = ''
[plugins.'io.containerd.cri.v1.images'.image_decryption]
key_model = 'node'
[plugins.'io.containerd.cri.v1.runtime']
enable_selinux = false
selinux_category_range = 1024
max_container_log_line_size = 16384
disable_cgroup = false
disable_apparmor = false
restrict_oom_score_adj = false
disable_proc_mount = false
unset_seccomp_profile = ''
tolerate_missing_hugetlb_controller = true
disable_hugetlb_controller = true
device_ownership_from_security_context = false
ignore_image_defined_volumes = false
netns_mounts_under_state_dir = false
enable_unprivileged_ports = true
enable_unprivileged_icmp = true
cdi_spec_dirs = ['/etc/cdi', '/var/run/cdi']
drain_exec_sync_io_timeout = '0s'
ignore_deprecation_warnings = []
stats_collect_period = '1s'
stats_retention_period = '2m'
enable_criu = true
[plugins.'io.containerd.cri.v1.runtime'.containerd]
default_runtime_name = 'runc'
ignore_blockio_not_enabled_errors = false
ignore_rdt_not_enabled_errors = false
[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes]
[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc]
runtime_type = 'io.containerd.runc.v2'
runtime_path = ''
pod_annotations = []
container_annotations = []
privileged_without_host_devices = false
privileged_without_host_devices_all_devices_allowed = false
cgroup_writable = false
base_runtime_spec = ''
cni_conf_dir = ''
cni_max_conf_num = 0
snapshotter = ''
sandboxer = 'podsandbox'
disable_pause_image_pull = false
io_type = ''
[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc.options]
BinaryName = ''
CriuImagePath = ''
CriuWorkPath = ''
IoGid = 0
IoUid = 0
NoNewKeyring = false
Root = ''
ShimCgroup = ''
[plugins.'io.containerd.cri.v1.runtime'.cni]
bin_dirs = ['/opt/cni/bin']
conf_dir = '/etc/cni/net.d'
max_conf_num = 1
setup_serially = false
conf_template = ''
ip_pref = ''
use_internal_loopback = false
[plugins.'io.containerd.grpc.v1.cri']
disable_tcp_service = true
stream_server_address = '127.0.0.1'
stream_server_port = '0'
stream_idle_timeout = '4h0m0s'
enable_tls_streaming = false
[plugins.'io.containerd.grpc.v1.cri'.x509_key_pair_streaming]
tls_cert_file = ''
tls_key_file = ''
- containerd 1.x인 경우
# - Version 3 (Recommended for containerd 2.x): Introduced in containerd 2.0.
# Several plugin IDs have changed in this version.
# - Version 2 (Recommended for containerd 1.x): Introduced in containerd 1.3.
# Still supported in containerd v2.x.
# Plugin IDs are changed to have prefixes like "io.containerd.".
# - Version 1 (Default): Introduced in containerd 1.0. Removed in containerd 2.0.
version = 2
# The 'plugins."io.containerd.grpc.v1.cri"' table contains all of the server options.
[plugins."io.containerd.grpc.v1.cri"]
# disable_tcp_service disables serving CRI on the TCP server.
# Note that a TCP server is enabled for containerd if TCPAddress is set in section [grpc].
disable_tcp_service = true
# stream_server_address is the ip address streaming server is listening on.
stream_server_address = "127.0.0.1"
# stream_server_port is the port streaming server is listening on.
stream_server_port = "0"
# stream_idle_timeout is the maximum time a streaming connection can be
# idle before the connection is automatically closed.
# The string is in the golang duration format, see:
# https://golang.org/pkg/time/#ParseDuration
stream_idle_timeout = "4h"
# enable_selinux indicates to enable the selinux support.
enable_selinux = false
# selinux_category_range allows the upper bound on the category range to be set.
# if not specified or set to 0, defaults to 1024 from the selinux package.
selinux_category_range = 1024
# sandbox_image is the image used by sandbox container.
sandbox_image = "registry.k8s.io/pause:3.10.2"
# stats_collect_period is the period (in seconds) of snapshots stats collection.
stats_collect_period = 10
# enable_tls_streaming enables the TLS streaming support.
# It generates a self-sign certificate unless the following x509_key_pair_streaming are both set.
enable_tls_streaming = false
# tolerate_missing_hugetlb_controller if set to false will error out on create/update
# container requests with huge page limits if the cgroup controller for hugepages is not present.
# This helps with supporting Kubernetes <=1.18 out of the box. (default is `true`)
tolerate_missing_hugetlb_controller = true
# ignore_image_defined_volumes ignores volumes defined by the image. Useful for better resource
# isolation, security and early detection of issues in the mount configuration when using
# ReadOnlyRootFilesystem since containers won't silently mount a temporary volume.
ignore_image_defined_volumes = false
# netns_mounts_under_state_dir places all mounts for network namespaces under StateDir/netns
# instead of being placed under the hardcoded directory /var/run/netns. Changing this setting
# requires that all containers are deleted.
netns_mounts_under_state_dir = false
# max_container_log_line_size is the maximum log line size in bytes for a container.
# Log line longer than the limit will be split into multiple lines. -1 means no
# limit.
max_container_log_line_size = 16384
# disable_cgroup indicates to disable the cgroup support.
# This is useful when the daemon does not have permission to access cgroup.
disable_cgroup = false
# disable_apparmor indicates to disable the apparmor support.
# This is useful when the daemon does not have permission to access apparmor.
disable_apparmor = false
# restrict_oom_score_adj indicates to limit the lower bound of OOMScoreAdj to
# the containerd's current OOMScoreAdj.
# This is useful when the containerd does not have permission to decrease OOMScoreAdj.
restrict_oom_score_adj = false
# max_concurrent_downloads restricts the number of concurrent downloads for each image.
max_concurrent_downloads = 3
# disable_proc_mount disables Kubernetes ProcMount support. This MUST be set to `true`
# when using containerd with Kubernetes <=1.11.
disable_proc_mount = false
# unset_seccomp_profile is the seccomp profile containerd/cri will use if the seccomp
# profile requested over CRI is unset (or nil) for a pod/container (otherwise if this field is not set the
# default unset profile will map to `unconfined`)
# Note: The default unset seccomp profile should not be confused with the seccomp profile
# used in CRI when the runtime default seccomp profile is requested. In the later case, the
# default is set by the following code (https://github.com/containerd/containerd/blob/main/contrib/seccomp/seccomp_default.go).
# To summarize, there are two different seccomp defaults, the unset default used when the CRI request is
# set to nil or `unconfined`, and the default used when the runtime default seccomp profile is requested.
unset_seccomp_profile = ""
# enable_unprivileged_ports configures net.ipv4.ip_unprivileged_port_start=0
# for all containers which are not using host network
# and if it is not overwritten by PodSandboxConfig
# Note that before containerd v2.0, this value defaulted to false.
# [k8s discussion](https://github.com/kubernetes/kubernetes/issues/102612)
enable_unprivileged_ports = true
# enable_unprivileged_icmp configures net.ipv4.ping_group_range="0 2147483647"
# for all containers which are not using host network, are not running in user namespace
# and if it is not overwritten by PodSandboxConfig
# Note that before containerd v2.0, this value defaulted to false.
enable_unprivileged_icmp = true
# cdi_spec_dirs is the list of directories to scan for CDI spec files
# For more details about CDI configuration please refer to
# https://tags.cncf.io/container-device-interface#containerd-configuration
cdi_spec_dirs = ["/etc/cdi", "/var/run/cdi"]
# drain_exec_sync_io_timeout is the maximum duration to wait for ExecSync API'
# IO EOF event after exec init process exits. A zero value means there is no
# timeout.
#
# The string is in the golang duration format, see:
# https://golang.org/pkg/time/#ParseDuration
#
# For example, the value can be '5h', '2h30m', '10s'.
drain_exec_sync_io_timeout = "0s"
# 'plugins."io.containerd.grpc.v1.cri".x509_key_pair_streaming' contains a x509 valid key pair to stream with tls.
[plugins."io.containerd.grpc.v1.cri".x509_key_pair_streaming]
# tls_cert_file is the filepath to the certificate paired with the "tls_key_file"
tls_cert_file = ""
# tls_key_file is the filepath to the private key paired with the "tls_cert_file"
tls_key_file = ""
# 'plugins."io.containerd.grpc.v1.cri".containerd' contains config related to containerd
[plugins."io.containerd.grpc.v1.cri".containerd]
# snapshotter is the default snapshotter used by containerd
# for all runtimes, if not overridden by an experimental runtime's snapshotter config.
snapshotter = "overlayfs"
# no_pivot disables pivot-root (linux only), required when running a container in a RamDisk with runc.
# This only works for runtime type "io.containerd.runtime.v1.linux".
no_pivot = false
# disable_snapshot_annotations disables to pass additional annotations (image
# related information) to snapshotters. These annotations are required by
# stargz snapshotter (https://github.com/containerd/stargz-snapshotter)
# changed to default true with https://github.com/containerd/containerd/pull/4665 and subsequent service refreshes.
disable_snapshot_annotations = true
# discard_unpacked_layers allows GC to remove layers from the content store after
# successfully unpacking these layers to the snapshotter.
discard_unpacked_layers = false
# default_runtime_name is the default runtime name to use.
default_runtime_name = "runc"
# ignore_blockio_not_enabled_errors disables blockio related
# errors when blockio support has not been enabled. By default,
# trying to set the blockio class of a container via annotations
# produces an error if blockio hasn't been enabled. This config
# option practically enables a "soft" mode for blockio where these
# errors are ignored and the container gets no blockio class.
ignore_blockio_not_enabled_errors = false
# ignore_rdt_not_enabled_errors disables RDT related errors when RDT
# support has not been enabled. Intel RDT is a technology for cache and
# memory bandwidth management. By default, trying to set the RDT class of
# a container via annotations produces an error if RDT hasn't been enabled.
# This config option practically enables a "soft" mode for RDT where these
# errors are ignored and the container gets no RDT class.
ignore_rdt_not_enabled_errors = false
# 'plugins."io.containerd.grpc.v1.cri".containerd.default_runtime' is the runtime to use in containerd.
# DEPRECATED: use `default_runtime_name` and `plugins."io.containerd.grpc.v1.cri".containerd.runtimes` instead.
[plugins."io.containerd.grpc.v1.cri".containerd.default_runtime]
# 'plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime' is a runtime to run untrusted workloads on it.
# DEPRECATED: use `untrusted` runtime in `plugins."io.containerd.grpc.v1.cri".containerd.runtimes` instead.
[plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime]
# 'plugins."io.containerd.grpc.v1.cri".containerd.runtimes' is a map from CRI RuntimeHandler strings, which specify types
# of runtime configurations, to the matching configurations.
# In this example, 'runc' is the RuntimeHandler string to match.
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
# runtime_type is the runtime type to use in containerd.
# The default value is "io.containerd.runc.v2" since containerd 1.4.
# The default value was "io.containerd.runc.v1" in containerd 1.3, "io.containerd.runtime.v1.linux" in prior releases.
runtime_type = "io.containerd.runc.v2"
# runtime_path is an optional field that can be used to overwrite path to a shim runtime binary.
# When specified, containerd will ignore runtime name field when resolving shim location.
# Path must be abs.
runtime_path = ""
# pod_annotations is a list of pod annotations passed to both pod
# sandbox as well as container OCI annotations. Pod_annotations also
# supports golang path match pattern - https://golang.org/pkg/path/#Match.
# e.g. ["runc.com.*"], ["*.runc.com"], ["runc.com/*"].
#
# For the naming convention of annotation keys, please reference:
# * Kubernetes: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set
# * OCI: https://github.com/opencontainers/image-spec/blob/main/annotations.md
pod_annotations = []
# container_annotations is a list of container annotations passed through to the OCI config of the containers.
# Container annotations in CRI are usually generated by other Kubernetes node components (i.e., not users).
# Currently, only device plugins populate the annotations.
container_annotations = []
# privileged_without_host_devices allows overloading the default behaviour of passing host
# devices through to privileged containers. This is useful when using a runtime where it does
# not make sense to pass host devices to the container when privileged. Defaults to false -
# i.e pass host devices through to privileged containers.
privileged_without_host_devices = false
# privileged_without_host_devices_all_devices_allowed allows the allowlisting of all devices when
# privileged_without_host_devices is enabled.
# In plain privileged mode all host device nodes are added to the container's spec and all devices
# are put in the container's device allowlist. This flags is for the modification of the privileged_without_host_devices
# option so that even when no host devices are implicitly added to the container, all devices allowlisting is still enabled.
# Requires privileged_without_host_devices to be enabled. Defaults to false.
privileged_without_host_devices_all_devices_allowed = false
# cgroup_writable field enables the support for writable cgroups in unprivileged containers with cgroup v2 enabled. When disabled, the cgroup interface (/sys/fs/cgroup) is mounted as read-only, preventing containers from managing their own cgroup hierarchies.
cgroup_writable = false
# base_runtime_spec is a file path to a JSON file with the OCI spec that will be used as the base spec that all
# container's are created from.
# Use containerd's `ctr oci spec > /etc/containerd/cri-base.json` to output initial spec file.
# Spec files are loaded at launch, so containerd daemon must be restarted on any changes to refresh default specs.
# Still running containers and restarted containers will still be using the original spec from which that container was created.
base_runtime_spec = ""
# conf_dir is the directory in which the admin places a CNI conf.
# this allows a different CNI conf for the network stack when a different runtime is being used.
cni_conf_dir = "/etc/cni/net.d"
# cni_max_conf_num specifies the maximum number of CNI plugin config files to
# load from the CNI config directory. By default, only 1 CNI plugin config
# file will be loaded. If you want to load multiple CNI plugin config files
# set max_conf_num to the number desired. Setting cni_max_config_num to 0 is
# interpreted as no limit is desired and will result in all CNI plugin
# config files being loaded from the CNI config directory.
cni_max_conf_num = 1
# snapshotter overrides the global default snapshotter to a runtime specific value.
# Please be aware that overriding the default snapshotter on a runtime basis is currently an experimental feature.
# See https://github.com/containerd/containerd/issues/6657 for context.
snapshotter = ""
# sandboxer is the sandbox controller for the runtime.
# The default sandbox controller is the podsandbox controller, which create a "pause" container as a sandbox.
# We can create our own "shim" sandbox controller by implementing the sandbox api defined in runtime/sandbox/v1/sandbox.proto in our shim, and specifiy the sandboxer to "shim" here.
# We can also run a grpc or ttrpc server to serve the sandbox controller API defined in services/sandbox/v1/sandbox.proto, and define a ProxyPlugin of "sandbox" type, and specify the name of the ProxyPlugin here.
sandboxer = ""
# io_type is the way containerd get stdin/stdout/stderr from container or the execed process.
# The default value is "fifo", in which containerd will create a set of named pipes and transfer io by them.
# Currently the value of "streaming" is supported, in this way, sandbox should serve streaming api defined in services/streaming/v1/streaming.proto, and containerd will connect to sandbox's endpoint and create a set of streams to it, as channels to transfer io of container or process.
io_type = ""
# 'plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options' is options specific to
# "io.containerd.runc.v1" and "io.containerd.runc.v2". Its corresponding options type is:
# https://github.com/containerd/containerd/blob/v1.3.2/runtime/v2/runc/options/oci.pb.go#L26 .
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
# NoPivotRoot disables pivot root when creating a container.
NoPivotRoot = false
# NoNewKeyring disables new keyring for the container.
NoNewKeyring = false
# ShimCgroup places the shim in a cgroup.
ShimCgroup = ""
# IoUid sets the I/O's pipes uid.
IoUid = 0
# IoGid sets the I/O's pipes gid.
IoGid = 0
# BinaryName is the binary name of the runc binary.
BinaryName = ""
# Root is the runc root directory.
Root = ""
# SystemdCgroup enables systemd cgroups.
SystemdCgroup = false
# CriuImagePath is the criu image path
CriuImagePath = ""
# CriuWorkPath is the criu work path.
CriuWorkPath = ""
# 'plugins."io.containerd.grpc.v1.cri".cni' contains config related to cni
[plugins."io.containerd.grpc.v1.cri".cni]
# bin_dir is the directory in which the binaries for the plugin is kept.
bin_dir = "/opt/cni/bin"
# conf_dir is the directory in which the admin places a CNI conf.
conf_dir = "/etc/cni/net.d"
# max_conf_num specifies the maximum number of CNI plugin config files to
# load from the CNI config directory. By default, only 1 CNI plugin config
# file will be loaded. If you want to load multiple CNI plugin config files
# set max_conf_num to the number desired. Setting max_config_num to 0 is
# interpreted as no limit is desired and will result in all CNI plugin
# config files being loaded from the CNI config directory.
max_conf_num = 1
# conf_template is the file path of golang template used to generate
# cni config.
# If this is set, containerd will generate a cni config file from the
# template. Otherwise, containerd will wait for the system admin or cni
# daemon to drop the config file into the conf_dir.
# See the "CNI Config Template" section for more details.
conf_template = ""
# ip_pref specifies the strategy to use when selecting the main IP address for a pod.
# options include:
# * ipv4, "" - (default) select the first ipv4 address
# * ipv6 - select the first ipv6 address
# * cni - use the order returned by the CNI plugins, returning the first IP address from the results
ip_pref = "ipv4"
# use_internal_loopback specifies if we use the CNI loopback plugin or internal mechanism to set lo to up
use_internal_loopback = false
# 'plugins."io.containerd.grpc.v1.cri".image_decryption' contains config related
# to handling decryption of encrypted container images.
[plugins."io.containerd.grpc.v1.cri".image_decryption]
# key_model defines the name of the key model used for how the cri obtains
# keys used for decryption of encrypted container images.
# The [decryption document](https://github.com/containerd/containerd/blob/main/docs/cri/decryption.md)
# contains additional information about the key models available.
#
# Set of available string options: {"", "node"}
# Omission of this field defaults to the empty string "", which indicates no key model,
# disabling image decryption.
#
# In order to use the decryption feature, additional configurations must be made.
# The [decryption document](https://github.com/containerd/containerd/blob/main/docs/cri/decryption.md)
# provides information of how to set up stream processors and the containerd imgcrypt decoder
# with the appropriate key models.
#
# Additional information:
# * Stream processors: https://github.com/containerd/containerd/blob/main/docs/stream_processors.md
# * Containerd imgcrypt: https://github.com/containerd/imgcrypt
key_model = "node"
# 'plugins."io.containerd.grpc.v1.cri".registry' contains config related to
# the registry
[plugins."io.containerd.grpc.v1.cri".registry]
# config_path specifies a directory to look for the registry hosts configuration.
#
# The cri plugin will look for and use config_path/host-namespace/hosts.toml
# configs if present OR load certificate files as laid out in the Docker/Moby
# specific layout https://docs.docker.com/engine/security/certificates/
#
# If config_path is not provided defaults are used.
#
# *** registry.configs and registry.mirrors that were a part of containerd 1.4
# are now DEPRECATED and will only be used if the config_path is not specified.
# It is an error to specify both config_path and the deprecated configs or mirrors
config_path = "/etc/containerd/certs.d:/etc/docker/certs.d"
레지스트리 설정(Registry Configuration)
다음은 기본 레지스트리 hosts 설정의 간단한 예제예요. containerd의 config.toml에 config_path = "/etc/containerd/certs.d"를 설정하고, 설정 경로 아래에 설정하려는 호스트 네임스페이스를 나타내는 docker.io 디렉터리 트리를 만드세요. 그다음 docker.io 안에 hosts.toml 파일을 추가해 호스트 네임스페이스를 설정하면 돼요. 다음처럼 보여야 해요:
/etc/containerd/certs.d
└── docker.io
└── hosts.toml
$ cat /etc/containerd/certs.d/docker.io/hosts.toml
server = "https://docker.io"
[host."https://registry-1.docker.io"]
capabilities = ["pull", "resolve"]
커스텀 인증서를 지정하려면:
server = "https://192.168.12.34:5000"
[host."https://192.168.12.34:5000"]
ca = "/path/to/ca.crt"
더 자세한 내용은 docs/hosts.md를 참고하세요.
신뢰할 수 없는 워크로드(Untrusted Workload)
신뢰할 수 없는 워크로드를 실행하는 권장 방법은, Kubernetes 1.12에서 도입된 RuntimeClass API를 사용해 plugins."io.containerd.grpc.v1.cri".containerd.runtimes에서 신뢰할 수 없는 워크로드를 실행하도록 설정된 RuntimeHandler를 선택하는 거예요.
다만 레거시 io.kubernetes.cri.untrusted-workload 어노테이션을 사용해 파드가 신뢰할 수 없는 워크로드용 런타임으로 실행되기를 요청하는 경우라면, RuntimeHandler plugins."io.containerd.grpc.v1.cri"cri.containerd.runtimes.untrusted를 먼저 정의해야 해요. io.kubernetes.cri.untrusted-workload 어노테이션이 true로 설정되면 untrusted 런타임이 사용돼요. 예제는 Create an untrusted pod using Kata Containers를 참고하세요.
CNI 설정 템플릿(CNI Config Template)
이상적으로는 cni 설정을 시스템 관리자나 calico, weaveworks 같은 cni 데몬이 배치해야 해요. 하지만 cni 설정을 배치해 줄 cni daemonset이 없는 경우에는 이 템플릿이 유용해요.
cni 설정 템플릿은 golang 템플릿 형식을 사용해요. 현재 지원되는 값은 다음과 같아요:
.PodCIDR은 노드에 할당된 첫 번째 CIDR의 문자열이에요..PodCIDRRanges는 노드에 할당된 모든 CIDR의 문자열 배열이에요. 보통 dualstack 지원에 쓰여요..Routes는 필요한 모든 라우트의 문자열 배열이에요. 보통 dualstack 지원이나, 단일 스택이지만 IPv4·IPv6가 실행 시점에 결정되는 경우에 쓰여요.
golang 템플릿 액션으로 cni 설정을 렌더링할 수 있어요. 예를 들어 다음 템플릿을 쓰면 CNI 설정에 dualstack용 CIDR과 라우트를 추가할 수 있어요:
"type": "host-local",
"ranges": [{{range $i, $range := .PodCIDRRanges}}{{if $i}}, {{end}}[{"subnet": "{{$range}}"}]{{end}}],
"routes": [{{range $i, $route := .Routes}}{{if $i}}, {{end}}{"dst": "{{$route}}"}{{end}}]
}
지원 중단 안내(Deprecation)
CRI 플러그인의 설정 옵션은 "admin-facing CLI components"에 대한 Kubernetes 지원 중단 정책을 따라요.
요약하면, 설정 옵션이 지원 중단(deprecated)으로 공지되면:
- 6개월 또는 1릴리스(더 긴 쪽) 동안 기능이 유지돼요;
- 사용할 때 경고가 출력돼요.