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

Remove containerd config.toml and use import path instead. #43

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.vscode/
os-metal
vendor
hack/tools/bin/*
hack/tools/bin/*
coverage.out
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ VERIFY := true
LEADER_ELECTION := false
IGNORE_OPERATION_ANNOTATION := false

GOLANGCI_LINT_VERSION := v1.48.0
GO_VERSION := 1.21
GOLANGCI_LINT_VERSION := v1.56.2
GO_VERSION := 1.22

ifeq ($(CI),true)
DOCKER_TTY_ARG=""
Expand All @@ -45,10 +45,14 @@ TOOLS_DIR := hack/tools
-include vendor/github.com/gardener/gardener/hack/tools.mk

.PHONY: all
all:
all: test
go build -trimpath -tags netgo -o os-metal cmd/main.go
strip os-metal

.PHONY: test
test:
go test ./... -race -coverprofile=coverage.out -covermode=atomic && go tool cover -func=coverage.out

.PHONY: clean
clean:
rm os-metal
Expand Down
2 changes: 2 additions & 0 deletions example/controller-registration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ apiVersion: core.gardener.cloud/v1beta1
kind: ControllerRegistration
metadata:
name: os-metal
annotations:
security.gardener.cloud/pod-security-enforce: baseline
spec:
deployment:
deploymentRefs:
Expand Down
40 changes: 13 additions & 27 deletions pkg/generator/ignition/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ const (
[Service]
ExecStart=
ExecStart=/usr/bin/containerd --config=/etc/containerd/config.toml
`
containerdBaselineConfig = `
# created by os-extension-metal
imports = ["/etc/containerd/conf.d/*.toml"]

version = 2

[plugins."io.containerd.grpc.v1.cri".registry]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://mirror.gcr.io"]
`
)

Expand Down Expand Up @@ -148,7 +137,10 @@ func ignitionFromOperatingSystemConfig(config *generator.OperatingSystemConfig)
},
}
cfg.Systemd.Units = append(cfg.Systemd.Units, containerdSystemdService)
cfg.Storage.Files = append(cfg.Storage.Files, additionalContainterdConfigFile(networkIsolation.RegistryMirrors))

if len(networkIsolation.RegistryMirrors) > 0 {
cfg.Storage.Files = append(cfg.Storage.Files, additionalContainterdConfigFile(networkIsolation.RegistryMirrors))
}
}
}

Expand Down Expand Up @@ -188,21 +180,7 @@ func getGardenerDecoder() runtime.Decoder {
}

func additionalContainterdConfigFile(mirrors []metalextensionv1alpha1.RegistryMirror) types.File {
containerdConfig := types.File{
Path: "/etc/containerd/config.toml",
Filesystem: "root",
Mode: &types.DefaultFileMode,
Contents: types.FileContents{
Inline: containerdBaselineConfig,
},
}
if len(mirrors) == 0 {
return containerdConfig
}

renderedContent := `# Generated by os-extension-metal
imports = ["/etc/containerd/conf.d/*.toml"]
version = 2

[plugins."io.containerd.grpc.v1.cri".registry]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
Expand All @@ -215,7 +193,15 @@ version = 2
}
}

containerdConfig.Contents.Inline = renderedContent
containerdConfig := types.File{
Path: "/etc/containerd/conf.d/isolated-clusters.toml",
Filesystem: "root",
Mode: &types.DefaultFileMode,
Contents: types.FileContents{
Inline: renderedContent,
},
}

return containerdConfig
}

Expand Down
18 changes: 2 additions & 16 deletions pkg/generator/ignition/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,6 @@ func TestIgnitionFromOperatingSystemConfig(t *testing.T) {
},
},
},
Storage: types.Storage{
Files: []types.File{
{
Filesystem: "root",
Path: "/etc/containerd/config.toml",
Contents: types.FileContents{
Inline: containerdBaselineConfig,
},
Mode: pointer.Int(0644),
},
},
},
},
},
{
Expand Down Expand Up @@ -187,7 +175,7 @@ Domain=~.
{
Path: "/etc/resolv.conf",
Contents: types.FileContents{
Inline: `# Generated by gardener-extension-provider-metal
Inline: `# Generated by os-extension-metal
nameserver 1.1.1.1
nameserver 1.0.0.1
`,
Expand All @@ -205,12 +193,10 @@ NTP=134.60.1.27 134.60.111.110
},
{
Filesystem: "root",
Path: "/etc/containerd/config.toml",
Path: "/etc/containerd/conf.d/isolated-clusters.toml",
Mode: &types.DefaultFileMode,
Contents: types.FileContents{
Inline: `# Generated by os-extension-metal
imports = ["/etc/containerd/conf.d/*.toml"]
version = 2

[plugins."io.containerd.grpc.v1.cri".registry]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
Expand Down