single-node-k3s-cluster-service

Description

Install a single node k3s cluster.

Variables

Name Type Default Description

create_kubectl_link

boolean True

Whether to create a symbolic link for 'kubectl'.

enabled

boolean True

Whether to enable the k3s service (default: true).

started

boolean True

Whether to start the k3s service (default: true).

users

list --

A list of users who should be members of the 'k3s' group (for acccess to the k3s config file).

version

string 0.10.2

The version of k3s.

Code

doc:
  short_help: Install a single node k3s cluster.

args:
  version:
    doc:
      short_help: The version of k3s.
    type: string
    required: false
    default: 0.10.2
  enabled:
    doc:
      short_help: 'Whether to enable the k3s service (default: true).'
    type: boolean
    default: true
    required: false
    cli:
      is_flag: true
      show_default: true
  started:
    doc:
      short_help: 'Whether to start the k3s service (default: true).'
    type: boolean
    required: false
    default: true
    cli:
      is_flag: true
      show_default: true
  create_kubectl_link:
    doc:
      short_help: Whether to create a symbolic link for 'kubectl'.
    type: boolean
    default: true
    cli:
      show_default: true
  users:
    doc:
      short_help: A list of users who should be members of the 'k3s' group (for acccess
        to the k3s config file).
    type: list
    schema:
      type: string
    empty: true
    required: false
    cli:
      param_decls:
      - --user
      - -u

frecklets:
- group-exists:
    group: k3s
- folder-exists:
    path: /etc/rancher/k3s
    owner: root
    group: k3s
    mode: '0750'
- sysctl-value-present:
    name: net.ipv4.ip_forward
    value: '1'
- sysctl-value-present:
    name: net.ipv6.conf.all.forwarding
    value: '1'
#  - path-is-absent:
#      path: "/usr/local/bin/k3s"
#      become: true
- executable-downloaded:
    url: 'https://github.com/rancher/k3s/releases/download/v{{:: version ::}}/k3s'
    dest: /usr/local/bin
    exe_name: k3s
    owner: root
    group: root
- systemd-service-unit:
    name: k3s
    unit_description: Leightweight Kubernetes
    unit_documentation: https://k3s.io
    unit_wants:
    - network-online.target
    install_wanted_by:
    - multi-user.target
    service_type: notify
    service_kill_mode: process
    service_delegate: true
    service_limit:
    - limit_type: NOFILE
      limit: infinity
    - limit_type: NOPROC
      limit: infinity
    - limit_type: CORE
      limit: infinity
    service_tasks_max: infinity
    service_timeout_start_sec: 0
    service_restart: always
    service_restart_sec: 5
    service_exec_start_pre:
    - -/sbin/modprobe br_netfilter
    - -/sbin/modprobe overlay
    service_exec_start: /usr/local/bin/k3s server --write-kubeconfig-mode 644
    enabled: '{{:: enabled ::}}'
    started: '{{:: started ::}}'
- link-exists:
    frecklet::skip: '{{:: create_kubectl_link | negate ::}}'
    dest: /usr/local/bin/kubectl
    src: /usr/local/bin/k3s
    owner: root
    group: root
- users-are-members-of-group:
    users: '{{:: users ::}}'
    group: k3s
frecklecute single-node-k3s-cluster-service --help

Usage: frecklecute single-node-k3s-cluster-service [OPTIONS]

  Install a single node k3s cluster.

Options:
  --create-kubectl-link / --no-create-kubectl-link
                                  Whether to create a symbolic link for
                                  'kubectl'.
  --enabled / --no-enabled        Whether to enable the k3s service (default:
                                  true).
  --started / --no-started        Whether to start the k3s service (default:
                                  true).
  -u, --user USERS                A list of users who should be members of the
                                  'k3s' group (for acccess to the k3s config
                                  file).
  --version VERSION               The version of k3s.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.single_node_k3s_cluster_service.SingleNodeK3sClusterService
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class SingleNodeK3sClusterService(AutoPycklet):
    """Install a single node k3s cluster.

       Args:
         create_kubectl_link: Whether to create a symbolic link for 'kubectl'.
         enabled: Whether to enable the k3s service (default: true).
         started: Whether to start the k3s service (default: true).
         users: A list of users who should be members of the 'k3s' group (for acccess to the k3s config file).
         version: The version of k3s.

    """

    FRECKLET_ID = "single-node-k3s-cluster-service"

    create_kubectl_link: bool = None
    enabled: bool = None
    started: bool = None
    users: List = None
    version: str = None


    def __post_init__(self):
        super(SingleNodeK3sClusterService, self).__init__(var_names=["create_kubectl_link", "enabled", "started", "users", "version"])


frecklet_class = SingleNodeK3sClusterService
# -*- coding: utf-8 -*-


#
# module path: pycklets.single_node_k3s_cluster_service.SingleNodeK3sClusterService
#


from pyckles import AutoPycklet

class SingleNodeK3sClusterService(AutoPycklet):
    """Install a single node k3s cluster.

       Args:
         create_kubectl_link: Whether to create a symbolic link for 'kubectl'.
         enabled: Whether to enable the k3s service (default: true).
         started: Whether to start the k3s service (default: true).
         users: A list of users who should be members of the 'k3s' group (for acccess to the k3s config file).
         version: The version of k3s.

    """

    FRECKLET_ID = "single-node-k3s-cluster-service"

    def __init__(self, create_kubectl_link=True, enabled=True, started=True, users=None, version="0.10.2"):

        super(SingleNodeK3sClusterService, self).__init__(var_names=["create_kubectl_link", "enabled", "started", "users", "version"])
        self._create_kubectl_link = create_kubectl_link
        self._enabled = enabled
        self._started = started
        self._users = users
        self._version = version

    @property
    def create_kubectl_link(self):
        return self._create_kubectl_link

    @create_kubectl_link.setter
    def create_kubectl_link(self, create_kubectl_link):
        self._create_kubectl_link = create_kubectl_link

    @property
    def enabled(self):
        return self._enabled

    @enabled.setter
    def enabled(self, enabled):
        self._enabled = enabled

    @property
    def started(self):
        return self._started

    @started.setter
    def started(self, started):
        self._started = started

    @property
    def users(self):
        return self._users

    @users.setter
    def users(self, users):
        self._users = users

    @property
    def version(self):
        return self._version

    @version.setter
    def version(self, version):
        self._version = version



frecklet_class = SingleNodeK3sClusterService