From 955e80ad0afafe597f2d8677aeb78e7bd3baf59f Mon Sep 17 00:00:00 2001 From: Justin SB Date: Thu, 14 Jan 2021 20:45:28 -0500 Subject: [PATCH] containerd: Add /etc/crictl config to enable crictl This configuration file means users don't have to pass the endpoint to run crictl. --- nodeup/pkg/model/containerd.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nodeup/pkg/model/containerd.go b/nodeup/pkg/model/containerd.go index e1409a9097403..c9e2c154bf46d 100644 --- a/nodeup/pkg/model/containerd.go +++ b/nodeup/pkg/model/containerd.go @@ -93,6 +93,9 @@ func (b *ContainerdBuilder) Build(c *fi.ModelBuilderContext) error { } c.AddTask(fileTask) } + + // Add configuration file for easier use of crictl + b.addCrictlConfig(c) } var containerRuntimeVersion string @@ -278,3 +281,16 @@ func (b *ContainerdBuilder) skipInstall() bool { return d.SkipInstall } + +// addCritctlConfig creates /etc/crictl.yaml, which lets crictl work out-of-the-box. +func (b *ContainerdBuilder) addCrictlConfig(c *fi.ModelBuilderContext) { + conf := ` +runtime-endpoint: unix:///run/containerd/containerd.sock +` + + c.AddTask(&nodetasks.File{ + Path: "/etc/crictl.yaml", + Contents: fi.NewStringResource(conf), + Type: nodetasks.FileType_File, + }) +}