Puppet Class: containerd::configuration

Defined in:
modules/containerd/manifests/configuration.pp

Summary

Configure containerd

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: present) —

    Ensure containerd configuration is present

  • sandbox_image (String) (defaults to: 'docker-registry.discovery.wmnet/pause:3.6-1') —

    The sandbox (Kubernetes pause) image to use

  • dragonfly_enabled (Boolean) (defaults to: false) —

    Whether to configure containerd to use dragonfly dfdaemon as a registry mirror

  • registry_username (Optional[String]) (defaults to: undef) —

    The username to use when accessing the container registry

  • registry_password (Optional[String]) (defaults to: undef) —

    The password to use when accessing the container registry

    @param runsc_config A hash of runsc configuration options to configure gVisor as a container runtime for containerd. If empty, gVisor will not be configured.

  • runsc_config (Hash[String, Hash[String, String]]) (defaults to: {})


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'modules/containerd/manifests/configuration.pp', line 24

class containerd::configuration (
    Wmflib::Ensure $ensure = present,
    String $sandbox_image = 'docker-registry.discovery.wmnet/pause:3.6-1',
    Boolean $dragonfly_enabled = false,
    Optional[String] $registry_username = undef,
    Optional[String] $registry_password = undef,
    Hash[String, Hash[String, String]] $runsc_config = {},
) {
    file { '/etc/containerd':
        ensure => stdlib::ensure($ensure, 'directory'),
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
    }

    if $registry_username and $registry_password {
        # uses strict_encode64 since encode64 adds newlines?!
        $registry_auth = inline_template("<%= require 'base64'; Base64.strict_encode64('${registry_username}:${registry_password}') -%>")
    } else {
        $registry_auth = undef
    }

    # On Trixie containerd runs with a different cni bin dir default: /usr/lib/cni
    # Our calico debian packages deploy the calico binaries to /opt/cni/bin.
    if debian::codename::ge('trixie') {
        $cni_bin_dir = '/opt/cni/bin'
    } else {
        $cni_bin_dir = undef
    }

    file { '/etc/containerd/config.toml':
        ensure  => stdlib::ensure($ensure, 'file'),
        owner   => 'root',
        group   => 'root',
        mode    => '0440',
        content => template('containerd/containerd-config.toml.erb'),
        notify  => Service['containerd'],
    }

    $runsc_config.each |$label, $config| {
        file { "/etc/containerd/runsc-${label}.toml":
            ensure  => stdlib::ensure($ensure, 'file'),
            owner   => 'root',
            group   => 'root',
            mode    => '0440',
            content => template('containerd/runsc-config.toml.erb'),
            notify  => Service['containerd'],
        }
    }
}