Skip to content

Commit f22040d

Browse files
committed
crio: add support for --imagestore
Allow cri-o users to split the filesystem of containers vs image store, imagestore if configured will pull images in image storage instead of the graphRoot while keeping the other parts still in the originally configured graphRoot. Signed-off-by: Aditya R <[email protected]>
1 parent fe9ed4e commit f22040d

File tree

8 files changed

+55
-0
lines changed

8 files changed

+55
-0
lines changed

completions/bash/crio

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ h
6161
--hooks-dir
6262
--hostnetwork-disable-selinux
6363
--image-volumes
64+
--imagestore
6465
--infra-ctr-cpuset
6566
--insecure-registry
6667
--internal-repair

completions/fish/crio.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ complete -c crio -n '__fish_crio_no_subcommand' -f -l image-volumes -r -d 'Image
8888
2. bind: A directory is created inside container state directory and bind
8989
mounted into the container for the volumes.
9090
3. ignore: All volumes are just ignored and no action is taken.'
91+
complete -c crio -n '__fish_crio_no_subcommand' -l imagestore -r -d 'Store newly pulled images in the specified path, rather than the path provided by --root.'
9192
complete -c crio -n '__fish_crio_no_subcommand' -f -l infra-ctr-cpuset -r -d 'CPU set to run infra containers, if not specified CRI-O will use all online CPUs to run infra containers.'
9293
complete -c crio -n '__fish_crio_no_subcommand' -f -l insecure-registry -r -d 'Enable insecure registry communication, i.e., enable un-encrypted and/or untrusted communication.
9394
1. List of insecure registries can contain an element with CIDR notation to

completions/zsh/_crio

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ it later with **--config**. Global options will modify the output.'
6868
'--hooks-dir'
6969
'--hostnetwork-disable-selinux'
7070
'--image-volumes'
71+
'--imagestore'
7172
'--infra-ctr-cpuset'
7273
'--insecure-registry'
7374
'--internal-repair'

docs/crio.8.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ crio
5959
[--hooks-dir]=[value]
6060
[--hostnetwork-disable-selinux]
6161
[--image-volumes]=[value]
62+
[--imagestore]=[value]
6263
[--infra-ctr-cpuset]=[value]
6364
[--insecure-registry]=[value]
6465
[--internal-repair]
@@ -280,6 +281,8 @@ crio [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]
280281
mounted into the container for the volumes.
281282
3. ignore: All volumes are just ignored and no action is taken. (default: "mkdir")
282283

284+
**--imagestore**="": Store newly pulled images in the specified path, rather than the path provided by --root.
285+
283286
**--infra-ctr-cpuset**="": CPU set to run infra containers, if not specified CRI-O will use all online CPUs to run infra containers.
284287

285288
**--insecure-registry**="": Enable insecure registry communication, i.e., enable un-encrypted and/or untrusted communication.

docs/crio.conf.5.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ CRI-O reads its storage defaults from the containers-storage.conf(5) file locate
5454
It is used to check if crio wipe should wipe images, which should
5555
only happen when CRI-O has been upgraded
5656

57+
**imagestore**=""
58+
Store newly pulled images in the specified path, rather than the path provided by --root.
59+
5760
**internal_wipe**=true
5861
**This option is currently DEPRECATED, and will be removed in the future.**
5962
Whether CRI-O should wipe containers after a reboot and images after an upgrade when the server starts.

internal/criocli/criocli.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ func mergeConfig(config *libconfig.Config, ctx *cli.Context) error {
156156
if ctx.IsSet("selinux") {
157157
config.SELinux = ctx.Bool("selinux")
158158
}
159+
if ctx.IsSet("imagestore") {
160+
config.ImageStore = ctx.String("imagestore")
161+
}
159162
if ctx.IsSet("seccomp-profile") {
160163
config.SeccompProfile = ctx.String("seccomp-profile")
161164
}
@@ -569,6 +572,13 @@ func getCrioFlags(defConf *libconfig.Config) []cli.Flag {
569572
EnvVars: []string{"CONTAINER_RUNROOT"},
570573
TakesFile: true,
571574
},
575+
&cli.StringFlag{
576+
Name: "imagestore",
577+
Usage: "Store newly pulled images in the specified path, rather than the path provided by --root.",
578+
Value: defConf.ImageStore,
579+
EnvVars: []string{"CONTAINER_IMAGESTORE"},
580+
TakesFile: true,
581+
},
572582
&cli.StringFlag{
573583
Name: "storage-driver",
574584
Aliases: []string{"s"},

pkg/config/template.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ func initCrioTemplateConfig(c *Config) ([]*templateConfigValue, error) {
115115
group: crioRootConfig,
116116
isDefaultValue: simpleEqual(dc.RunRoot, c.RunRoot),
117117
},
118+
{
119+
templateString: templateStringCrioImageStore,
120+
group: crioRootConfig,
121+
isDefaultValue: simpleEqual(dc.ImageStore, c.ImageStore),
122+
},
118123
{
119124
templateString: templateStringCrioStorageDriver,
120125
group: crioRootConfig,
@@ -728,6 +733,11 @@ const templateStringCrioRunroot = `# Path to the "run directory". CRI-O stores a
728733
729734
`
730735

736+
const templateStringCrioImageStore = `# Path to the "imagestore". If CRI-O stores all of its images in this directory differently than Root.
737+
{{ $.Comment }}imagestore = "{{ .ImageStore }}"
738+
739+
`
740+
731741
const templateStringCrioStorageDriver = `# Storage driver used to manage the storage of images and containers. Please
732742
# refer to containers-storage.conf(5) to see all available storage drivers.
733743
{{ $.Comment }}storage_driver = "{{ .Storage }}"

test/image.bats

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,32 @@ function teardown() {
9696
cleanup_images
9797
}
9898

99+
@test "image pull and list using imagestore" {
100+
# Start crio with imagestore
101+
mkdir -p "$TESTDIR/imagestore"
102+
CONTAINER_IMAGESTORE="$TESTDIR/imagestore" start_crio
103+
104+
FEDORA="registry.fedoraproject.org/fedora"
105+
crictl pull $FEDORA
106+
imageid=$(crictl images --quiet "$FEDORA")
107+
[ "$imageid" != "" ]
108+
109+
output=$(crictl images @"$imageid")
110+
[[ "$output" == *"$FEDORA"* ]]
111+
112+
output=$(crictl images --quiet "$imageid")
113+
[ "$output" != "" ]
114+
115+
stop_crio
116+
unset CONTAINER_IMAGESTORE
117+
# start crio without imagestore
118+
start_crio
119+
imageid=$(crictl images --quiet "$FEDORA")
120+
# no image must be found on default root
121+
[[ "$imageid" == "" ]]
122+
cleanup_images
123+
}
124+
99125
@test "image pull with signature" {
100126
skip "registry has some issues"
101127
start_crio

0 commit comments

Comments
 (0)