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

WIP: Set all containerd config in config.toml #878

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
TEST_VERSION_UPGRADE_MIN_RELEASE: "1.31"
TEST_MIRROR_LIST: '[{"name": "ghcr.io", "port": 5000, "remote": "https://ghcr.io", "username": "${{ github.actor }}", "password": "${{ secrets.GITHUB_TOKEN }}"}, {"name": "docker.io", "port": 5001, "remote": "https://registry-1.docker.io", "username": "", "password": ""}, {"name": "rocks.canonical.com", "port": 5002, "remote": "https://rocks.canonical.com/cdk"}]'
run: |
cd tests/integration && sg lxd -c 'tox -e integration -- --tags pull_request'
cd tests/integration && sg lxd -c 'tox -e integration -- -k test_node_cleanup_new_containerd_path'
- name: Prepare inspection reports
if: failure()
run: |
Expand Down
23 changes: 15 additions & 8 deletions src/k8s/pkg/k8sd/setup/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@ import (
const defaultPauseImage = "ghcr.io/canonical/k8s-snap/pause:3.10"

func defaultContainerdConfig(
containerdRootDir string,
containerdSocketPath string,
containerdStateDir string,
cniConfDir string,
cniBinDir string,
importsDir string,
registryConfigDir string,
pauseImage string,
) map[string]any {
return map[string]any{
"version": 2,
"oom_score": 0,
"imports": []string{filepath.Join(importsDir, "*.toml")},
"version": 2,
"oom_score": 0,
"imports": []string{filepath.Join(importsDir, "*.toml")},
"root": containerdRootDir,
"state": containerdStateDir,
"plugin_dir": filepath.Join(containerdRootDir, "plugins"),

"grpc": map[string]any{
"address": containerdSocketPath,
"uid": 0,
"gid": 0,
"max_recv_message_size": 16777216,
Expand All @@ -38,7 +45,7 @@ func defaultContainerdConfig(
"debug": map[string]any{
"uid": 0,
"gid": 0,
"address": "",
"address": "/home/ubuntu/k8s-containerd/debug.sock",
"level": "",
},

Expand Down Expand Up @@ -92,6 +99,9 @@ func defaultContainerdConfig(
// Optionally, a number of registry mirrors and auths can be configured.
func Containerd(snap snap.Snap, extraContainerdConfig map[string]any, extraArgs map[string]*string) error {
configToml := defaultContainerdConfig(
snap.ContainerdRootDir(),
snap.ContainerdSocketPath(),
snap.ContainerdStateDir(),
snap.CNIConfDir(),
snap.CNIBinDir(),
snap.ContainerdExtraConfigDir(),
Expand All @@ -113,10 +123,7 @@ func Containerd(snap snap.Snap, extraContainerdConfig map[string]any, extraArgs
}

if _, err := snaputil.UpdateServiceArguments(snap, "containerd", map[string]string{
"--address": snap.ContainerdSocketPath(),
"--config": filepath.Join(snap.ContainerdConfigDir(), "config.toml"),
"--root": snap.ContainerdRootDir(),
"--state": snap.ContainerdStateDir(),
"--config": filepath.Join(snap.ContainerdConfigDir(), "config.toml"),
}, nil); err != nil {
return fmt.Errorf("failed to write arguments file: %w", err)
}
Expand Down
Loading