Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename [Cc]ontainerD to containerd #4044

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/airgap-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ You can install k0s in an environment with restricted Internet access. Airgap in

## Prerequisites

In order to create your own image bundle, you need
In order to create your own image bundle, you need:

- A working cluster with at least one controller, to be used to build the image bundle. For more information, refer to the [Quick Start Guide](install.md).
- The containerd CLI management tool `ctr`, installed on the worker machine (refer to the ContainerD [getting-started](https://containerd.io/docs/getting-started/) guide).
- A working cluster with at least one controller that will be used to build the
image bundle. See the [Quick Start Guide] for more information.
- The containerd CLI management tool `ctr`, installed on the worker node. See
the [containerd Getting Started Guide] for more information.

[Quick Start Guide]: install.md
[containerd Getting Started Guide]: https://github.com/containerd/containerd/blob/v1.7.13/docs/getting-started.md

## 1. Create your own image bundle (optional)

Expand Down
2 changes: 1 addition & 1 deletion docs/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Following chapters provide some examples how to configure different runtimes for

Refer to the [gVisor install docs](https://gvisor.dev/docs/user_guide/install/) for more information.

2. Prepare the config for `k0s` managed containerD, to utilize gVisor as additional runtime:
2. Prepare the config for `k0s` managed containerd, to utilize gVisor as additional runtime:

```shell
cat <<EOF | sudo tee /etc/k0s/containerd.d/gvisor.toml
Expand Down
12 changes: 6 additions & 6 deletions inttest/containerdimports/containerd_imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type ContainerDImportsSuite struct {
type ContainerdImportsSuite struct {
common.BootlooseSuite
}

func (s *ContainerDImportsSuite) TestK0sGetsUp() {
func (s *ContainerdImportsSuite) TestK0sGetsUp() {
ctx := s.Context()
ssh, err := s.SSH(ctx, s.ControllerNode(0))
s.Require().NoError(err)
Expand All @@ -55,7 +55,7 @@ func (s *ContainerDImportsSuite) TestK0sGetsUp() {
s.T().Log("waiting to see kube-router pods ready")
s.NoError(common.WaitForKubeRouterReady(ctx, kc), "kube-router did not start")

s.addContainerDRuntime()
s.addContainerdRuntime()
s.T().Log("Creating new RuntimeClass for foo runtime")
runtimeClassName := "foo"

Expand Down Expand Up @@ -107,7 +107,7 @@ func (s *ContainerDImportsSuite) TestK0sGetsUp() {

}

func (s *ContainerDImportsSuite) addContainerDRuntime() {
func (s *ContainerdImportsSuite) addContainerdRuntime() {
ctx := s.Context()
s.T().Log("Setting up alternative runtime and config")
workerSSH, err := s.SSH(ctx, s.WorkerNode(0))
Expand All @@ -121,8 +121,8 @@ func (s *ContainerDImportsSuite) addContainerDRuntime() {
s.PutFile(s.WorkerNode(0), "/etc/k0s/containerd.d/foo.toml", fooRuntimeConfig)
}

func TestContainerDImportsSuite(t *testing.T) {
s := ContainerDImportsSuite{
func TestContainerdImportsSuite(t *testing.T) {
s := ContainerdImportsSuite{
common.BootlooseSuite{
LaunchMode: common.LaunchModeOpenRC, // so we can easily restart k0s
ControllerCount: 1,
Expand Down
40 changes: 20 additions & 20 deletions pkg/component/worker/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const magicMarker = "# k0s_managed=true"

const confTmpl = `
# k0s_managed=true
# This is a placeholder configuration for k0s managed containerD.
# This is a placeholder configuration for k0s managed containerd.
# If you wish to override the config, remove the first line and replace this file with your custom configuration.
# For reference see https://github.com/containerd/containerd/blob/main/docs/man/containerd-config.toml.5.md
version = 2
Expand All @@ -68,8 +68,8 @@ const confPathWindows = "C:\\Program Files\\containerd\\config.toml"
const importsPathPosix = "/etc/k0s/containerd.d/"
const importsPathWindows = "C:\\etc\\k0s\\containerd.d\\"

// ContainerD implement the component interface to manage containerd as k0s component
type ContainerD struct {
// Containerd implements the component interface to manage containerd as a k0s component.
type Containerd struct {
supervisor supervisor.Supervisor
LogLevel string
K0sVars *config.CfgVars
Expand All @@ -80,8 +80,8 @@ type ContainerD struct {
importsPath string
}

func NewContainerd(logLevel string, vars *config.CfgVars, profile *workerconfig.Profile) *ContainerD {
c := &ContainerD{
func NewContainerd(logLevel string, vars *config.CfgVars, profile *workerconfig.Profile) *Containerd {
c := &Containerd{
LogLevel: logLevel,
K0sVars: vars,
Profile: profile,
Expand All @@ -99,10 +99,10 @@ func NewContainerd(logLevel string, vars *config.CfgVars, profile *workerconfig.
return c
}

var _ manager.Component = (*ContainerD)(nil)
var _ manager.Component = (*Containerd)(nil)

// Init extracts the needed binaries
func (c *ContainerD) Init(ctx context.Context) error {
func (c *Containerd) Init(ctx context.Context) error {
g, _ := errgroup.WithContext(ctx)
for _, bin := range c.binaries {
b := bin
Expand All @@ -116,7 +116,7 @@ func (c *ContainerD) Init(ctx context.Context) error {
return g.Wait()
}

func (c *ContainerD) windowsInit() error {
func (c *Containerd) windowsInit() error {
if runtime.GOOS != "windows" {
return nil
}
Expand All @@ -126,9 +126,9 @@ func (c *ContainerD) windowsInit() error {
return winExecute(command)
}

// Run runs containerD
func (c *ContainerD) Start(ctx context.Context) error {
logrus.Info("Starting containerD")
// Run runs containerd.
func (c *Containerd) Start(ctx context.Context) error {
logrus.Info("Starting containerd")

if err := c.setupConfig(); err != nil {
return fmt.Errorf("failed to setup containerd config: %w", err)
Expand Down Expand Up @@ -162,21 +162,21 @@ func (c *ContainerD) Start(ctx context.Context) error {
return nil
}

func (c *ContainerD) windowsStart(_ context.Context) error {
func (c *Containerd) windowsStart(_ context.Context) error {
if err := winExecute("Start-Service containerd"); err != nil {
return fmt.Errorf("failed to start Windows Service %q: %w", "containerd", err)
}
return nil
}

func (c *ContainerD) windowsStop() error {
func (c *Containerd) windowsStop() error {
if err := winExecute("Stop-Service containerd"); err != nil {
return fmt.Errorf("failed to stop Windows Service %q: %w", "containerd", err)
}
return nil
}

func (c *ContainerD) setupConfig() error {
func (c *Containerd) setupConfig() error {
// Check if the config file is user managed
// If it is, we should not touch it

Expand All @@ -195,9 +195,9 @@ func (c *ContainerD) setupConfig() error {
if err := dir.Init(filepath.Dir(c.importsPath), 0755); err != nil {
return fmt.Errorf("can't create containerd config imports dir: %w", err)
}
containerDConfigurer := containerd.NewConfigurer(c.Profile.PauseImage, filepath.Join(c.importsPath, "*.toml"))
containerdConfigurer := containerd.NewConfigurer(c.Profile.PauseImage, filepath.Join(c.importsPath, "*.toml"))

imports, err := containerDConfigurer.HandleImports()
imports, err := containerdConfigurer.HandleImports()
if err != nil {
return fmt.Errorf("can't handle imports: %w", err)
}
Expand All @@ -217,7 +217,7 @@ func (c *ContainerD) setupConfig() error {
return file.WriteContentAtomically(c.confPath, output.Bytes(), 0644)
}

func (c *ContainerD) watchDropinConfigs(ctx context.Context) {
func (c *Containerd) watchDropinConfigs(ctx context.Context) {
log := logrus.WithField("component", "containerd")
watcher, err := fsnotify.NewWatcher()
if err != nil {
Expand Down Expand Up @@ -265,7 +265,7 @@ func (c *ContainerD) watchDropinConfigs(ctx context.Context) {
}
}

func (c *ContainerD) restart() {
func (c *Containerd) restart() {
log := logrus.WithFields(logrus.Fields{"component": "containerd", "phase": "restart"})

log.Info("restart requested")
Expand All @@ -292,8 +292,8 @@ func (c *ContainerD) restart() {
}
}

// Stop stops containerD
func (c *ContainerD) Stop() error {
// Stop stops containerd.
func (c *Containerd) Stop() error {
if runtime.GOOS == "windows" {
return c.windowsStop()
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/worker/containerd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ version = 2
tmpDir := t.TempDir()
configPath := filepath.Join(tmpDir, "containerd.toml")
cfg := `
# This is a placeholder configuration for k0s managed containerD.
# This is a placeholder configuration for k0s managed containerd.
# If you wish to customize the config replace this file with your custom configuration.
# For reference see https://github.com/containerd/containerd/blob/main/docs/man/containerd-config.toml.5.md
version = 2
Expand Down
Loading