@@ -67,6 +67,9 @@ const (
67
67
ModePodSandbox SandboxControllerMode = "podsandbox"
68
68
// ModeShim means use whatever Controller implementation provided by shim.
69
69
ModeShim SandboxControllerMode = "shim"
70
+ // DefaultSandboxImage is the default image to use for sandboxes when empty or
71
+ // for default configurations.
72
+ DefaultSandboxImage = "registry.k8s.io/pause:3.9"
70
73
)
71
74
72
75
// Runtime struct to contain the type(ID), engine, and root variables for a default runtime
@@ -242,8 +245,12 @@ type ImageDecryption struct {
242
245
// can be assumed. When platform is not provided, the default platform can
243
246
// be assumed
244
247
type ImagePlatform struct {
245
- Platform string
246
- Snapshotter string
248
+ Platform string `toml:"platform" json:"platform"`
249
+ // Snapshotter setting snapshotter at runtime level instead of making it as a global configuration.
250
+ // An example use case is to use devmapper or other snapshotters in Kata containers for performance and security
251
+ // while using default snapshotters for operational simplicity.
252
+ // See https://github.com/containerd/containerd/issues/6657 for details.
253
+ Snapshotter string `toml:"snapshotter" json:"snapshotter"`
247
254
}
248
255
249
256
type ImageConfig struct {
@@ -261,18 +268,21 @@ type ImageConfig struct {
261
268
DiscardUnpackedLayers bool `toml:"discard_unpacked_layers" json:"discardUnpackedLayers"`
262
269
263
270
// PinnedImages are images which the CRI plugin uses and should not be
264
- // removed by the CRI client.
271
+ // removed by the CRI client. The images have a key which can be used
272
+ // by other plugins to lookup the current image name.
265
273
// Image names should be full names including domain and tag
266
274
// Examples:
267
- // docker.io/library/ubuntu:latest
268
- // images.k8s.io/core/pause:1.55
269
- PinnedImages []string
275
+ // "sandbox": "k8s.gcr.io/pause:3.9"
276
+ // "base": "docker.io/library/ubuntu:latest"
277
+ // Migrated from:
278
+ // (PluginConfig).SandboxImage string `toml:"sandbox_image" json:"sandboxImage"`
279
+ PinnedImages map [string ]string
270
280
271
281
// RuntimePlatforms is map between the runtime and the image platform to
272
282
// use for that runtime. When resolving an image for a runtime, this
273
283
// mapping will be used to select the image for the platform and the
274
284
// snapshotter for unpacking.
275
- RuntimePlatforms map [string ]ImagePlatform
285
+ RuntimePlatforms map [string ]ImagePlatform `toml:"runtime_platforms" json:"runtimePlatforms"`
276
286
277
287
// Registry contains config related to the registry
278
288
Registry Registry `toml:"registry" json:"registry"`
@@ -305,8 +315,6 @@ type ImageConfig struct {
305
315
// PluginConfig contains toml config related to CRI plugin,
306
316
// it is a subset of Config.
307
317
type PluginConfig struct {
308
- // ImageConfig is the image service configuration
309
- ImageConfig
310
318
// ContainerdConfig contains config related to containerd
311
319
ContainerdConfig `toml:"containerd" json:"containerd"`
312
320
// CniConfig contains config related to cni
@@ -327,8 +335,6 @@ type PluginConfig struct {
327
335
// SelinuxCategoryRange allows the upper bound on the category range to be set.
328
336
// If not specified or set to 0, defaults to 1024 from the selinux package.
329
337
SelinuxCategoryRange int `toml:"selinux_category_range" json:"selinuxCategoryRange"`
330
- // SandboxImage is the image used by sandbox container.
331
- SandboxImage string `toml:"sandbox_image" json:"sandboxImage"`
332
338
// EnableTLSStreaming indicates to enable the TLS streaming support.
333
339
EnableTLSStreaming bool `toml:"enable_tls_streaming" json:"enableTLSStreaming"`
334
340
// X509KeyPairStreaming is a x509 key pair used for TLS streaming
@@ -437,31 +443,9 @@ const (
437
443
KeyModelNode = "node"
438
444
)
439
445
440
- // ValidatePluginConfig validates the given plugin configuration.
441
- func ValidatePluginConfig (ctx context.Context , c * PluginConfig ) ([]deprecation.Warning , error ) {
446
+ // ValidateImageConfig validates the given image configuration
447
+ func ValidateImageConfig (ctx context.Context , c * ImageConfig ) ([]deprecation.Warning , error ) {
442
448
var warnings []deprecation.Warning
443
- if c .ContainerdConfig .Runtimes == nil {
444
- c .ContainerdConfig .Runtimes = make (map [string ]Runtime )
445
- }
446
-
447
- // Validation for default_runtime_name
448
- if c .ContainerdConfig .DefaultRuntimeName == "" {
449
- return warnings , errors .New ("`default_runtime_name` is empty" )
450
- }
451
- if _ , ok := c .ContainerdConfig .Runtimes [c .ContainerdConfig .DefaultRuntimeName ]; ! ok {
452
- return warnings , fmt .Errorf ("no corresponding runtime configured in `containerd.runtimes` for `containerd` `default_runtime_name = \" %s\" " , c .ContainerdConfig .DefaultRuntimeName )
453
- }
454
-
455
- for k , r := range c .ContainerdConfig .Runtimes {
456
- if ! r .PrivilegedWithoutHostDevices && r .PrivilegedWithoutHostDevicesAllDevicesAllowed {
457
- return warnings , errors .New ("`privileged_without_host_devices_all_devices_allowed` requires `privileged_without_host_devices` to be enabled" )
458
- }
459
- // If empty, use default podSandbox mode
460
- if len (r .Sandboxer ) == 0 {
461
- r .Sandboxer = string (ModePodSandbox )
462
- c .ContainerdConfig .Runtimes [k ] = r
463
- }
464
- }
465
449
466
450
useConfigPath := c .Registry .ConfigPath != ""
467
451
if len (c .Registry .Mirrors ) > 0 {
@@ -500,20 +484,49 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W
500
484
log .G (ctx ).Warning ("`auths` is deprecated, please use `ImagePullSecrets` instead" )
501
485
}
502
486
503
- // Validation for stream_idle_timeout
504
- if c .StreamIdleTimeout != "" {
505
- if _ , err := time .ParseDuration (c .StreamIdleTimeout ); err != nil {
506
- return warnings , fmt .Errorf ("invalid stream idle timeout: %w" , err )
507
- }
508
- }
509
-
510
487
// Validation for image_pull_progress_timeout
511
488
if c .ImagePullProgressTimeout != "" {
512
489
if _ , err := time .ParseDuration (c .ImagePullProgressTimeout ); err != nil {
513
490
return warnings , fmt .Errorf ("invalid image pull progress timeout: %w" , err )
514
491
}
515
492
}
516
493
494
+ return warnings , nil
495
+ }
496
+
497
+ // ValidatePluginConfig validates the given plugin configuration.
498
+ func ValidatePluginConfig (ctx context.Context , c * PluginConfig ) ([]deprecation.Warning , error ) {
499
+ var warnings []deprecation.Warning
500
+ if c .ContainerdConfig .Runtimes == nil {
501
+ c .ContainerdConfig .Runtimes = make (map [string ]Runtime )
502
+ }
503
+
504
+ // Validation for default_runtime_name
505
+ if c .ContainerdConfig .DefaultRuntimeName == "" {
506
+ return warnings , errors .New ("`default_runtime_name` is empty" )
507
+ }
508
+ if _ , ok := c .ContainerdConfig .Runtimes [c .ContainerdConfig .DefaultRuntimeName ]; ! ok {
509
+ return warnings , fmt .Errorf ("no corresponding runtime configured in `containerd.runtimes` for `containerd` `default_runtime_name = \" %s\" " , c .ContainerdConfig .DefaultRuntimeName )
510
+ }
511
+
512
+ for k , r := range c .ContainerdConfig .Runtimes {
513
+ if ! r .PrivilegedWithoutHostDevices && r .PrivilegedWithoutHostDevicesAllDevicesAllowed {
514
+ return warnings , errors .New ("`privileged_without_host_devices_all_devices_allowed` requires `privileged_without_host_devices` to be enabled" )
515
+ }
516
+ // If empty, use default podSandbox mode
517
+ if len (r .Sandboxer ) == 0 {
518
+ r .Sandboxer = string (ModePodSandbox )
519
+ c .ContainerdConfig .Runtimes [k ] = r
520
+ }
521
+ }
522
+
523
+ // Validation for stream_idle_timeout
524
+ if c .StreamIdleTimeout != "" {
525
+ if _ , err := time .ParseDuration (c .StreamIdleTimeout ); err != nil {
526
+ return warnings , fmt .Errorf ("invalid stream idle timeout: %w" , err )
527
+ }
528
+ }
529
+
517
530
// Validation for drain_exec_sync_io_timeout
518
531
if c .DrainExecSyncIOTimeout != "" {
519
532
if _ , err := time .ParseDuration (c .DrainExecSyncIOTimeout ); err != nil {
0 commit comments