2022-04-08 17:44:40 +00:00
|
|
|
//go:build linux
|
2021-06-10 19:27:00 +00:00
|
|
|
|
|
|
|
package templates
|
|
|
|
|
|
|
|
import (
|
|
|
|
"text/template"
|
|
|
|
)
|
|
|
|
|
|
|
|
const ContainerdConfigTemplate = `
|
2023-11-30 02:14:01 +00:00
|
|
|
{{- /* */ -}}
|
2023-03-13 20:42:17 +00:00
|
|
|
# File generated by {{ .Program }}. DO NOT EDIT. Use config.toml.tmpl instead.
|
2022-10-13 16:03:02 +00:00
|
|
|
version = 2
|
2021-06-10 19:27:00 +00:00
|
|
|
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.internal.v1.opt"]
|
|
|
|
path = "{{ .NodeConfig.Containerd.Opt }}"
|
|
|
|
[plugins."io.containerd.grpc.v1.cri"]
|
2021-06-10 19:27:00 +00:00
|
|
|
stream_server_address = "127.0.0.1"
|
|
|
|
stream_server_port = "10010"
|
|
|
|
enable_selinux = {{ .NodeConfig.SELinux }}
|
2022-07-28 08:53:56 +00:00
|
|
|
enable_unprivileged_ports = {{ .EnableUnprivileged }}
|
|
|
|
enable_unprivileged_icmp = {{ .EnableUnprivileged }}
|
2021-06-10 19:27:00 +00:00
|
|
|
|
|
|
|
{{- if .DisableCgroup}}
|
|
|
|
disable_cgroup = true
|
|
|
|
{{end}}
|
|
|
|
{{- if .IsRunningInUserNS }}
|
|
|
|
disable_apparmor = true
|
|
|
|
restrict_oom_score_adj = true
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{- if .NodeConfig.AgentConfig.PauseImage }}
|
|
|
|
sandbox_image = "{{ .NodeConfig.AgentConfig.PauseImage }}"
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{- if .NodeConfig.AgentConfig.Snapshotter }}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.grpc.v1.cri".containerd]
|
2021-06-10 19:27:00 +00:00
|
|
|
snapshotter = "{{ .NodeConfig.AgentConfig.Snapshotter }}"
|
2021-09-01 23:27:42 +00:00
|
|
|
disable_snapshot_annotations = {{ if eq .NodeConfig.AgentConfig.Snapshotter "stargz" }}false{{else}}true{{end}}
|
2023-11-21 20:38:56 +00:00
|
|
|
{{ if .NodeConfig.DefaultRuntime }}default_runtime_name = "{{ .NodeConfig.DefaultRuntime }}"{{end}}
|
2021-09-01 23:27:42 +00:00
|
|
|
{{ if eq .NodeConfig.AgentConfig.Snapshotter "stargz" }}
|
|
|
|
{{ if .NodeConfig.AgentConfig.ImageServiceSocket }}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.snapshotter.v1.stargz"]
|
2021-09-01 23:27:42 +00:00
|
|
|
cri_keychain_image_service_path = "{{ .NodeConfig.AgentConfig.ImageServiceSocket }}"
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.snapshotter.v1.stargz".cri_keychain]
|
2021-09-01 23:27:42 +00:00
|
|
|
enable_keychain = true
|
|
|
|
{{end}}
|
|
|
|
{{ if .PrivateRegistryConfig }}
|
|
|
|
{{ if .PrivateRegistryConfig.Mirrors }}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.snapshotter.v1.stargz".registry.mirrors]{{end}}
|
2021-09-01 23:27:42 +00:00
|
|
|
{{range $k, $v := .PrivateRegistryConfig.Mirrors }}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.snapshotter.v1.stargz".registry.mirrors."{{$k}}"]
|
2021-09-01 23:27:42 +00:00
|
|
|
endpoint = [{{range $i, $j := $v.Endpoints}}{{if $i}}, {{end}}{{printf "%q" .}}{{end}}]
|
|
|
|
{{if $v.Rewrites}}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.snapshotter.v1.stargz".registry.mirrors."{{$k}}".rewrite]
|
2021-09-01 23:27:42 +00:00
|
|
|
{{range $pattern, $replace := $v.Rewrites}}
|
|
|
|
"{{$pattern}}" = "{{$replace}}"
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{range $k, $v := .PrivateRegistryConfig.Configs }}
|
|
|
|
{{ if $v.Auth }}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.snapshotter.v1.stargz".registry.configs."{{$k}}".auth]
|
2021-09-01 23:27:42 +00:00
|
|
|
{{ if $v.Auth.Username }}username = {{ printf "%q" $v.Auth.Username }}{{end}}
|
|
|
|
{{ if $v.Auth.Password }}password = {{ printf "%q" $v.Auth.Password }}{{end}}
|
|
|
|
{{ if $v.Auth.Auth }}auth = {{ printf "%q" $v.Auth.Auth }}{{end}}
|
|
|
|
{{ if $v.Auth.IdentityToken }}identitytoken = {{ printf "%q" $v.Auth.IdentityToken }}{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{ if $v.TLS }}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.snapshotter.v1.stargz".registry.configs."{{$k}}".tls]
|
2021-09-01 23:27:42 +00:00
|
|
|
{{ if $v.TLS.CAFile }}ca_file = "{{ $v.TLS.CAFile }}"{{end}}
|
|
|
|
{{ if $v.TLS.CertFile }}cert_file = "{{ $v.TLS.CertFile }}"{{end}}
|
|
|
|
{{ if $v.TLS.KeyFile }}key_file = "{{ $v.TLS.KeyFile }}"{{end}}
|
|
|
|
{{ if $v.TLS.InsecureSkipVerify }}insecure_skip_verify = true{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
2021-06-10 19:27:00 +00:00
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{- if not .NodeConfig.NoFlannel }}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.grpc.v1.cri".cni]
|
2021-06-10 19:27:00 +00:00
|
|
|
bin_dir = "{{ .NodeConfig.AgentConfig.CNIBinDir }}"
|
|
|
|
conf_dir = "{{ .NodeConfig.AgentConfig.CNIConfDir }}"
|
|
|
|
{{end}}
|
|
|
|
|
2023-10-26 09:51:25 +00:00
|
|
|
{{- if or .NodeConfig.Containerd.BlockIOConfig .NodeConfig.Containerd.RDTConfig }}
|
|
|
|
[plugins."io.containerd.service.v1.tasks-service"]
|
|
|
|
{{ if .NodeConfig.Containerd.BlockIOConfig }}blockio_config_file = "{{ .NodeConfig.Containerd.BlockIOConfig }}"{{end}}
|
|
|
|
{{ if .NodeConfig.Containerd.RDTConfig }}rdt_config_file = "{{ .NodeConfig.Containerd.RDTConfig }}"{{end}}
|
|
|
|
{{end}}
|
|
|
|
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
|
2021-06-10 19:27:00 +00:00
|
|
|
runtime_type = "io.containerd.runc.v2"
|
|
|
|
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
|
|
|
|
SystemdCgroup = {{ .SystemdCgroup }}
|
2022-04-18 23:06:50 +00:00
|
|
|
|
2023-11-30 02:14:01 +00:00
|
|
|
[plugins."io.containerd.grpc.v1.cri".registry]
|
|
|
|
config_path = "{{ .NodeConfig.Containerd.Registry }}"
|
2021-06-10 19:27:00 +00:00
|
|
|
|
2023-11-30 02:14:01 +00:00
|
|
|
{{ if .PrivateRegistryConfig }}
|
2021-06-10 19:27:00 +00:00
|
|
|
{{range $k, $v := .PrivateRegistryConfig.Configs }}
|
|
|
|
{{ if $v.Auth }}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.grpc.v1.cri".registry.configs."{{$k}}".auth]
|
2021-06-10 19:27:00 +00:00
|
|
|
{{ if $v.Auth.Username }}username = {{ printf "%q" $v.Auth.Username }}{{end}}
|
|
|
|
{{ if $v.Auth.Password }}password = {{ printf "%q" $v.Auth.Password }}{{end}}
|
|
|
|
{{ if $v.Auth.Auth }}auth = {{ printf "%q" $v.Auth.Auth }}{{end}}
|
|
|
|
{{ if $v.Auth.IdentityToken }}identitytoken = {{ printf "%q" $v.Auth.IdentityToken }}{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
2021-09-15 21:31:11 +00:00
|
|
|
|
|
|
|
{{range $k, $v := .ExtraRuntimes}}
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes."{{$k}}"]
|
2021-09-15 21:31:11 +00:00
|
|
|
runtime_type = "{{$v.RuntimeType}}"
|
2022-10-13 16:03:02 +00:00
|
|
|
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes."{{$k}}".options]
|
2021-09-15 21:31:11 +00:00
|
|
|
BinaryName = "{{$v.BinaryName}}"
|
2023-11-02 17:47:16 +00:00
|
|
|
SystemdCgroup = {{ $.SystemdCgroup }}
|
2021-09-15 21:31:11 +00:00
|
|
|
{{end}}
|
2021-06-10 19:27:00 +00:00
|
|
|
`
|
|
|
|
|
2023-11-30 02:14:01 +00:00
|
|
|
// Linux config templates do not need fixups
|
|
|
|
var templateFuncs = template.FuncMap{
|
|
|
|
"deschemify": func(s string) string {
|
|
|
|
return s
|
|
|
|
},
|
2021-06-10 19:27:00 +00:00
|
|
|
}
|