K3s Service#

K3s Service Class#

Classes:

K3s(master, agent[, version, data_dir, ...])

Deploy a single K3s cluster.

class enoslib.service.k3s.k3s.K3s(master: Iterable[Host], agent: Iterable[Host], version: str = 'latest', data_dir='/var/lib/rancher/k3s', dashboard=True)#

Deploy a single K3s cluster.

Note

In order to deploy multiple (independent) nodes, please do so by creating multiple instances of this service.

Reference:

https://docs.k3s.io/quick-start

This is a basic setup for now. Let us know if something is needed here: https://framateam.org/enoslib

For instance

  • automatic deployment of the dashboard

  • private registry configuration (e.g G5k registry)

Parameters:
  • master – Iterable[Host] Host(s) where the K3s master (control plane) will be installed. These nodes will run the Kubernetes control plane components.

  • agent – Iterable[Host] Host(s) where the K3s agent (worker nodes) will be installed. These nodes will join the cluster as worker nodes.

  • version – str, optional (default: “latest”) The version of K3s to install. To see available versions, follow this link: k3s-io/k3s

  • data_dir – str, optional The base directory where K3s will store its data (default: “/var/lib/rancher/k3s”). Includes: - Cluster state (including containerd images) - Default local storage path (automatically derived as <data_dir>/storage)

  • dashboard – bool, optional (default: True) Deploy the kubernetes dashboard. See: kubernetes/dashboard

Examples

 1import logging
 2from pathlib import Path
 3
 4import enoslib as en
 5
 6en.init_logging(level=logging.INFO)
 7en.check()
 8
 9job_name = Path(__file__).name
10
11# claim the resources
12conf = (
13    en.G5kConf.from_settings(job_name=job_name, walltime="0:45:00", job_type=[])
14    .add_machine(roles=["master"], cluster="paradoxe", nodes=1)
15    .add_machine(roles=["agent"], cluster="paradoxe", nodes=10)
16    .finalize()
17)
18
19
20provider = en.G5k(conf)
21# Get actual resources
22roles, networks = provider.init()
23
24# Available Versions here : https://github.com/k3s-io/k3s/releases
25k3s = en.K3s(
26    master=roles["master"],
27    agent=roles["agent"],
28    data_dir="/tmp/k3s_state",
29    version="v1.32.5+k3s1",
30    dashboard=True,
31)
32
33k3s.deploy()
backup()#

(abstract) Backup the service.

deploy()#

(abstract) Deploy the service.

destroy()#

(abstract) Destroy the service.