Skip to content

Commit

Permalink
Merge pull request #103 from ananace/update-repos
Browse files Browse the repository at this point in the history
Use pkgs.k8s.io repos instead of kubic
  • Loading branch information
ananace authored Sep 24, 2024
2 parents 39fe76a + a8b9035 commit 4fb8826
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 127 deletions.
100 changes: 50 additions & 50 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
### Classes

* [`k8s`](#k8s): Sets up a Kubernetes instance - either as a node or as a server
* [`k8s::install::cni_plugins`](#k8s--install--cni_plugins): manages the installation of the cni plugins
* [`k8s::install::container_runtime`](#k8s--install--container_runtime): manages the installation of cri
* [`k8s::install::cni_plugins`](#k8s--install--cni_plugins): Manages the installation of CNI plugins
* [`k8s::install::container_runtime`](#k8s--install--container_runtime): Manages the installation of a container runtime / CRI
* [`k8s::install::crictl`](#k8s--install--crictl): installs the crictl debugging tool
* [`k8s::install::kubeadm`](#k8s--install--kubeadm): Installs the kubeadm binary
* [`k8s::install::kubectl`](#k8s--install--kubectl): Installs the kubectl binary
Expand Down Expand Up @@ -493,7 +493,7 @@ Default value: `'1.28.14'`

### <a name="k8s--install--cni_plugins"></a>`k8s::install::cni_plugins`

Class: k8s::install::cni_plugins
Manages the installation of CNI plugins

#### Parameters

Expand All @@ -503,111 +503,111 @@ The following parameters are available in the `k8s::install::cni_plugins` class:
* [`method`](#-k8s--install--cni_plugins--method)
* [`version`](#-k8s--install--cni_plugins--version)
* [`download_url_template`](#-k8s--install--cni_plugins--download_url_template)
* [`package_name`](#-k8s--install--cni_plugins--package_name)

##### <a name="-k8s--install--cni_plugins--ensure"></a>`ensure`

Data type: `K8s::Ensure`

set ensure for installation or deinstallation
Set ensure for installation or deinstallation

Default value: `$k8s::ensure`

##### <a name="-k8s--install--cni_plugins--method"></a>`method`

Data type: `String[1]`

installation method
The installation method to use

Default value: `$k8s::native_packaging`

##### <a name="-k8s--install--cni_plugins--version"></a>`version`

Data type: `String[1]`

sets the version to use
The version of CNI plugins to install - if applicable

Default value: `'v1.2.0'`

##### <a name="-k8s--install--cni_plugins--download_url_template"></a>`download_url_template`

Data type: `String[1]`

template string for the cni_plugins download url
Template string for the cni_plugins download url

Default value: `'https://github.com/containernetworking/plugins/releases/download/%{version}/cni-plugins-linux-%{arch}-%{version}.tgz'`

##### <a name="-k8s--install--cni_plugins--package_name"></a>`package_name`

Data type: `Optional[String[1]]`

Package name for the CNI plugins, will use OS default if omitted

Default value: `undef`

### <a name="k8s--install--container_runtime"></a>`k8s::install::container_runtime`

Class: k8s::install::container_runtime
Manages the installation of a container runtime / CRI

#### Parameters

The following parameters are available in the `k8s::install::container_runtime` class:

* [`manage_repo`](#-k8s--install--container_runtime--manage_repo)
* [`container_manager`](#-k8s--install--container_runtime--container_manager)
* [`containerd_package`](#-k8s--install--container_runtime--containerd_package)
* [`crio_package`](#-k8s--install--container_runtime--crio_package)
* [`k8s_version`](#-k8s--install--container_runtime--k8s_version)
* [`manage_repo`](#-k8s--install--container_runtime--manage_repo)
* [`package_ensure`](#-k8s--install--container_runtime--package_ensure)
* [`containerd_package`](#-k8s--install--container_runtime--containerd_package)
* [`runc_version`](#-k8s--install--container_runtime--runc_version)
* [`package_ensure`](#-k8s--install--container_runtime--package_ensure)

##### <a name="-k8s--install--container_runtime--container_manager"></a>`container_manager`
##### <a name="-k8s--install--container_runtime--manage_repo"></a>`manage_repo`

Data type: `K8s::Container_runtimes`
Data type: `Boolean`

set the cri to use
Whether to manage the repo or not

Default value: `$k8s::container_manager`
Default value: `$k8s::manage_repo`

##### <a name="-k8s--install--container_runtime--containerd_package"></a>`containerd_package`
##### <a name="-k8s--install--container_runtime--container_manager"></a>`container_manager`

Data type: `Optional[String[1]]`
Data type: `K8s::Container_runtimes`

the containerd package anme
The CRI implementation to install

Default value: `$k8s::containerd_package`
Default value: `$k8s::container_manager`

##### <a name="-k8s--install--container_runtime--crio_package"></a>`crio_package`

Data type: `Optional[String[1]]`

cri-o the package name
The CRI-o package name

Default value: `$k8s::crio_package`

##### <a name="-k8s--install--container_runtime--k8s_version"></a>`k8s_version`
##### <a name="-k8s--install--container_runtime--containerd_package"></a>`containerd_package`

Data type: `String[1]`
Data type: `Optional[String[1]]`

the k8s version
The containerd package name

Default value: `$k8s::version`
Default value: `$k8s::containerd_package`

##### <a name="-k8s--install--container_runtime--manage_repo"></a>`manage_repo`
##### <a name="-k8s--install--container_runtime--runc_version"></a>`runc_version`

Data type: `Boolean`
Data type: `String[1]`

whether to manage the repo or not
The runc version

Default value: `$k8s::manage_repo`
Default value: `$k8s::runc_version`

##### <a name="-k8s--install--container_runtime--package_ensure"></a>`package_ensure`

Data type: `String[1]`

the ensure value to set on the cri package
The ensure value to set on the cri package

Default value: `installed`

##### <a name="-k8s--install--container_runtime--runc_version"></a>`runc_version`

Data type: `String[1]`

the runc version

Default value: `$k8s::runc_version`

### <a name="k8s--install--crictl"></a>`k8s::install::crictl`

Class: k8s::install::crictl
Expand Down Expand Up @@ -1249,9 +1249,17 @@ Handles repositories for the container runtime

The following parameters are available in the `k8s::repo` class:

* [`container_manager`](#-k8s--repo--container_manager)
* [`crio_version`](#-k8s--repo--crio_version)
* [`manage_container_manager`](#-k8s--repo--manage_container_manager)
* [`container_manager`](#-k8s--repo--container_manager)
* [`major_version`](#-k8s--repo--major_version)

##### <a name="-k8s--repo--manage_container_manager"></a>`manage_container_manager`

Data type: `Boolean`

Whether to add the CRI-o repository or not

Default value: `$k8s::manage_container_manager`

##### <a name="-k8s--repo--container_manager"></a>`container_manager`

Expand All @@ -1261,22 +1269,14 @@ The name of the container manager

Default value: `$k8s::container_manager`

##### <a name="-k8s--repo--crio_version"></a>`crio_version`
##### <a name="-k8s--repo--major_version"></a>`major_version`

Data type: `String[1]`

version o cri-o
The major version of Kubernetes to deploy repos for

Default value: `$k8s::version.split('\.')[0, 2].join('.')`

##### <a name="-k8s--repo--manage_container_manager"></a>`manage_container_manager`

Data type: `Boolean`

whether to add cri-o repository or not

Default value: `$k8s::manage_container_manager`

### <a name="k8s--server"></a>`k8s::server`

Sets up a Kubernetes server instance
Expand Down
51 changes: 33 additions & 18 deletions manifests/install/cni_plugins.pp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Class: k8s::install::cni_plugins
# @summary Manages the installation of CNI plugins
#
# @summary manages the installation of the cni plugins
#
# @param ensure set ensure for installation or deinstallation
# @param method installation method
# @param version sets the version to use
# @param download_url_template template string for the cni_plugins download url
# @param ensure Set ensure for installation or deinstallation
# @param method The installation method to use
# @param version The version of CNI plugins to install - if applicable
# @param download_url_template Template string for the cni_plugins download url
# @param package_name Package name for the CNI plugins, will use OS default if omitted
#
class k8s::install::cni_plugins (
K8s::Ensure $ensure = $k8s::ensure,
String[1] $version = 'v1.2.0',
String[1] $method = $k8s::native_packaging,
String[1] $download_url_template = 'https://github.com/containernetworking/plugins/releases/download/%{version}/cni-plugins-linux-%{arch}-%{version}.tgz',
K8s::Ensure $ensure = $k8s::ensure,
String[1] $version = 'v1.2.0',
String[1] $method = $k8s::native_packaging,
String[1] $download_url_template = 'https://github.com/containernetworking/plugins/releases/download/%{version}/cni-plugins-linux-%{arch}-%{version}.tgz',
Optional[String[1]] $package_name = undef,
) {
file {
default:
Expand Down Expand Up @@ -43,17 +43,32 @@
require => File['/opt/cni/bin'],
}
}
'package':{
ensure_packages(['containernetworking-plugins',])
'package': {
if $k8s::manage_repo or $package_name == 'kubernetes-cni' {
$_package_name = pick($package_name, 'kubernetes-cni')
} else {
if fact('os.family') == 'suse' {
$_package_name = pick($package_name, 'cni-plugins')
} else {
$_package_name = pick($package_name, 'containernetworking-plugins')
}

file { '/opt/cni/bin':
ensure => link,
target => '/usr/lib/cni',
require => Package['containernetworking-plugins'],
if fact('os.family') == 'RedHat' {
$_target = '/usr/libexec/cni'
} else {
$_target = '/usr/lib/cni'
}

file { '/opt/cni/bin':
ensure => link,
target => $_target,
require => Package[$_package_name],
}
}
ensure_packages([$_package_name,])

if $k8s::manage_repo {
Class['k8s::repo'] -> Package['containernetworking-plugins']
Class['k8s::repo'] -> Package[$_package_name]
}
}
default: {
Expand Down
45 changes: 18 additions & 27 deletions manifests/install/container_runtime.pp
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
# Class: k8s::install::container_runtime
# @summary Manages the installation of a container runtime / CRI
#
# @summary manages the installation of cri
#
# @param container_manager set the cri to use
# @param containerd_package the containerd package anme
# @param crio_package cri-o the package name
# @param k8s_version the k8s version
# @param manage_repo whether to manage the repo or not
# @param package_ensure the ensure value to set on the cri package
# @param runc_version the runc version
# @param manage_repo Whether to manage the repo or not
# @param container_manager The CRI implementation to install
# @param crio_package The CRI-o package name
# @param containerd_package The containerd package name
# @param runc_version The runc version
# @param package_ensure The ensure value to set on the cri package
#
class k8s::install::container_runtime (
Boolean $manage_repo = $k8s::manage_repo,
K8s::Container_runtimes $container_manager = $k8s::container_manager,
Optional[String[1]] $crio_package = $k8s::crio_package,
Optional[String[1]] $containerd_package = $k8s::containerd_package,
String[1] $k8s_version = $k8s::version,
String[1] $runc_version = $k8s::runc_version,
String[1] $package_ensure = installed,
) {
case $container_manager {
'crio': {
if fact('os.family') == 'Debian' {
$_crio_version = $k8s_version.split('\.')[0, 2].join('.')
if versioncmp($_crio_version, '1.17') < 0 {
$pkg = pick($crio_package, "cri-o-${_crio_version}")
} else {
$pkg = pick($crio_package, 'cri-o')
}

# This is needed by cri-o, but it is not a dependency of the package
# This is required for cri-o, but it is not guaranteed to be a dependency of the package
package { 'runc':
ensure => $runc_version,
}

# Avoid a potential issue with some CRI-o versions
# Avoid a potential packaging issue
file { ['/usr/lib/cri-o-runc/sbin', '/usr/lib/cri-o-runc']:
ensure => directory,
}
Expand All @@ -44,9 +33,8 @@
target => '/usr/sbin/runc',
replace => false,
}
} else {
$pkg = pick($crio_package, 'cri-o')
}
$pkg = pick($crio_package, 'cri-o')

file { '/usr/libexec/crio/conmon':
ensure => link,
Expand All @@ -60,11 +48,14 @@
require => Package['k8s container manager'],
}

file_line { 'K8s crio cgroup manager':
path => '/etc/crio/crio.conf',
line => 'cgroup_manager = "systemd"',
match => '^cgroup_manager',
require => Package['k8s container manager'],
file { ['/etc/crio', '/etc/crio/crio.conf.d']:
ensure => directory;
}
file { 'K8s crio cgroup manager':
path => '/etc/crio/crio.conf.d/10-systemd.conf',
content => "[crio.runtime]\ncgroup_manager = \"systemd\"",
# TODO - Necessary/wanted to force it?
# notify => Service[crio],
}
}
'containerd': {
Expand Down
Loading

0 comments on commit 4fb8826

Please sign in to comment.