Browse Source

QoS-class resource configuration

Problem:
Configuring qos-class features in containerd requres a custom containerd configuration template.

Solution:
Look for configuration files in default locations and configure containerd to use them if they exist.

Signed-off-by: Oliver Larsson <larsson.e.oliver@gmail.com>
pull/8861/head
Oliver Larsson 1 year ago committed by Brad Davidson
parent
commit
30c8ad926d
  1. 1
      pkg/agent/config/config.go
  2. 22
      pkg/agent/config/config_linux.go
  3. 5
      pkg/agent/config/config_windows.go
  4. 6
      pkg/agent/templates/templates_linux.go
  5. 20
      pkg/daemons/config/types.go

1
pkg/agent/config/config.go

@ -558,6 +558,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
nodeConfig.Containerd.Debug = envInfo.Debug
applyContainerdStateAndAddress(nodeConfig)
applyCRIDockerdAddress(nodeConfig)
applyContainerdQoSClassConfigFileIfPresent(envInfo, nodeConfig)
nodeConfig.Containerd.Template = filepath.Join(envInfo.DataDir, "agent", "etc", "containerd", "config.toml.tmpl")
nodeConfig.Certificate = servingCert

22
pkg/agent/config/config_linux.go

@ -4,9 +4,13 @@
package config
import (
"errors"
"os"
"path/filepath"
"github.com/k3s-io/k3s/pkg/cli/cmds"
"github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/sirupsen/logrus"
)
func applyContainerdStateAndAddress(nodeConfig *config.Node) {
@ -17,3 +21,21 @@ func applyContainerdStateAndAddress(nodeConfig *config.Node) {
func applyCRIDockerdAddress(nodeConfig *config.Node) {
nodeConfig.CRIDockerd.Address = "unix:///run/k3s/cri-dockerd/cri-dockerd.sock"
}
func applyContainerdQoSClassConfigFileIfPresent(envInfo *cmds.Agent, nodeConfig *config.Node) {
blockioPath := filepath.Join(envInfo.DataDir, "agent", "etc", "containerd", "blockio_config.yaml")
// Set containerd config if file exists
if _, err := os.Stat(blockioPath); !errors.Is(err, os.ErrNotExist) {
logrus.Infof("BlockIO configuration file found")
nodeConfig.Containerd.BlockIOConfig = blockioPath
}
rdtPath := filepath.Join(envInfo.DataDir, "agent", "etc", "containerd", "rdt_config.yaml")
// Set containerd config if file exists
if _, err := os.Stat(rdtPath); !errors.Is(err, os.ErrNotExist) {
logrus.Infof("RDT configuration file found")
nodeConfig.Containerd.RDTConfig = rdtPath
}
}

5
pkg/agent/config/config_windows.go

@ -6,6 +6,7 @@ package config
import (
"path/filepath"
"github.com/k3s-io/k3s/pkg/cli/cmds"
"github.com/k3s-io/k3s/pkg/daemons/config"
)
@ -17,3 +18,7 @@ func applyContainerdStateAndAddress(nodeConfig *config.Node) {
func applyCRIDockerdAddress(nodeConfig *config.Node) {
nodeConfig.CRIDockerd.Address = "npipe:////.pipe/cri-dockerd"
}
func applyContainerdQoSClassConfigFileIfPresent(envInfo *cmds.Agent, nodeConfig *config.Node) {
// QoS-class resource management not supported on windows.
}

6
pkg/agent/templates/templates_linux.go

@ -82,6 +82,12 @@ enable_keychain = true
conf_dir = "{{ .NodeConfig.AgentConfig.CNIConfDir }}"
{{end}}
{{- 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}}
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v2"

20
pkg/daemons/config/types.go

@ -58,15 +58,17 @@ type Node struct {
}
type Containerd struct {
Address string
Log string
Root string
State string
Config string
Opt string
Template string
SELinux bool
Debug bool
Address string
Log string
Root string
State string
Config string
Opt string
Template string
BlockIOConfig string
RDTConfig string
SELinux bool
Debug bool
}
type CRIDockerd struct {

Loading…
Cancel
Save