Skip to content

Commit

Permalink
containerd: Add /etc/crictl config to enable crictl
Browse files Browse the repository at this point in the history
This configuration file means users don't have to pass the endpoint
to run crictl.
  • Loading branch information
justinsb committed Jan 15, 2021
1 parent 2ad3fd3 commit f9c43bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions nodeup/pkg/model/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
})
}
6 changes: 6 additions & 0 deletions nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ contents: ""
path: /etc/containerd/config-kops.toml
type: file
---
contents: |2
runtime-endpoint: unix:///run/containerd/containerd.sock
path: /etc/crictl.yaml
type: file
---
contents: CONTAINERD_OPTS=
path: /etc/sysconfig/containerd
type: file
Expand Down

0 comments on commit f9c43bb

Please sign in to comment.