Merge pull request #1504 from lorenz/ignore-image-defined-volumes
Add option for ignoring volumes defined in images
This commit is contained in:
		| @@ -45,6 +45,11 @@ version = 2 | |||||||
|   # It generates a self-sign certificate unless the following x509_key_pair_streaming are both set. |   # It generates a self-sign certificate unless the following x509_key_pair_streaming are both set. | ||||||
|   enable_tls_streaming = false |   enable_tls_streaming = false | ||||||
|  |  | ||||||
|  |   # 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 | ||||||
|  |  | ||||||
|   # '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' contains a x509 valid key pair to stream with tls. | ||||||
|   [plugins."io.containerd.grpc.v1.cri".x509_key_pair_streaming] |   [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 is the filepath to the certificate paired with the "tls_key_file" | ||||||
|   | |||||||
| @@ -236,6 +236,10 @@ type PluginConfig struct { | |||||||
| 	// container requests with huge page limits if the cgroup controller for hugepages is not present. | 	// 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`) | 	// This helps with supporting Kubernetes <=1.18 out of the box. (default is `true`) | ||||||
| 	TolerateMissingHugePagesCgroupController bool `toml:"tolerate_missing_hugepages_controller" json:"tolerateMissingHugePagesCgroupController"` | 	TolerateMissingHugePagesCgroupController bool `toml:"tolerate_missing_hugepages_controller" json:"tolerateMissingHugePagesCgroupController"` | ||||||
|  | 	// IgnoreImageDefinedVolumes 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. | ||||||
|  | 	IgnoreImageDefinedVolumes bool `toml:"ignore_image_defined_volumes" json:"ignoreImageDefinedVolumes"` | ||||||
| } | } | ||||||
|  |  | ||||||
| // X509KeyPairStreaming contains the x509 configuration for streaming | // X509KeyPairStreaming contains the x509 configuration for streaming | ||||||
|   | |||||||
| @@ -66,5 +66,6 @@ func DefaultConfig() PluginConfig { | |||||||
| 		MaxConcurrentDownloads:                   3, | 		MaxConcurrentDownloads:                   3, | ||||||
| 		DisableProcMount:                         false, | 		DisableProcMount:                         false, | ||||||
| 		TolerateMissingHugePagesCgroupController: true, | 		TolerateMissingHugePagesCgroupController: true, | ||||||
|  | 		IgnoreImageDefinedVolumes:                false, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -65,6 +65,7 @@ func DefaultConfig() PluginConfig { | |||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		MaxConcurrentDownloads:    3, | 		MaxConcurrentDownloads:    3, | ||||||
|  | 		IgnoreImageDefinedVolumes: false, | ||||||
| 		// TODO(windows): Add platform specific config, so that most common defaults can be shared. | 		// TODO(windows): Add platform specific config, so that most common defaults can be shared. | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -137,8 +137,13 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta | |||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
|  |  | ||||||
| 	// Create container volumes mounts. | 	var volumeMounts []*runtime.Mount | ||||||
| 	volumeMounts := c.volumeMounts(containerRootDir, config.GetMounts(), &image.ImageSpec.Config) | 	if !c.config.IgnoreImageDefinedVolumes { | ||||||
|  | 		// Create container image volumes mounts. | ||||||
|  | 		volumeMounts = c.volumeMounts(containerRootDir, config.GetMounts(), &image.ImageSpec.Config) | ||||||
|  | 	} else if len(image.ImageSpec.Config.Volumes) != 0 { | ||||||
|  | 		log.G(ctx).Debugf("Ignoring volumes defined in image %v because IgnoreImageDefinedVolumes is set", image.ID) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	// Generate container mounts. | 	// Generate container mounts. | ||||||
| 	mounts := c.containerMounts(sandboxID, config) | 	mounts := c.containerMounts(sandboxID, config) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mike Brown
					Mike Brown