k3s-simplified: Effortless Kubernetes Clusters on Hetzner Cloud

website·Indexed 30 days ago

https://k3s-simplified.easystartup.io/

A tool for deploying and managing k3s Kubernetes clusters on Hetzner Cloud. Documentation covers installation, basic and private cluster setup, NAT gateway and jump box configuration, node autoscaling, binary and OS upgrades, and configuration references.

Tokens
8.5K
Snippets
45
Records
67
Agent score
50%

What's inside k3s-simplified

  1. Overview of k3s-simplified CLI

    k3s-simplified is a streamlined CLI tool designed to set up and manage production-grade Kubernetes clusters on Hetzner Cloud using Rancher's K3s. It supports Linux, macOS, and Windows (via WSL). A key security feature is the ability to facilitate private network Kubernetes nodes that do not require public IPs.
  2. Overview of k3s-simplified for Hetzner Cloud

    k3s-simplified is a standalone, Java-based command-line tool designed to streamline the deployment of Kubernetes clusters on Hetzner Cloud. It serves as a cross-platform, drop-in replacement for hetzner-k3s. The tool focuses on production-ready environments by emphasizing privacy and security, such as keeping the API load balancer private. It leverages k3s (a lightweight Kubernetes distribution by Rancher) to minimize resource consumption and accelerate deployment.
  3. Understand the purpose of an Access Box (Jump Box)

    An Access Box, or jump box, is a secure intermediary server used to access other devices or servers within a separate security zone. In the context of k3s-simplified, it provides a secure method to connect to a Kubernetes cluster using private network IPs, reducing the attack surface by funneling traffic through a single controlled entry point.
  4. Configure mandatory options for k3s cluster setup

    To set up a k3s cluster, the following mandatory configuration fields must be provided. These settings handle authentication with Hetzner, cluster identification, SSH access, and node pool definitions.
    # Mandatory Cluster Configuration
    hetzner_token: "<your_hetzner_token>"
    cluster_name: "<your_cluster_name>"
    public_ssh_key_path: "/path/to/id_rsa.pub"
    private_ssh_key_path: "/path/to/id_rsa"
    masters_pool:
      # Define instance type, count, and location
      instance_type: "cx22"
      count: 1
      location: "fsn1"
    
    # Optional overrides for mandatory fields
    kubeconfig_path: "./kubeconfig" # Default: ./kubeconfig
    k3s_version: "v1.29.2+k3s1"     # Default: v1.29.2+k3s1
    ssh_allowed_networks: ["0.0.0.0/0"] # Default: ["0.0.0.0/0"]
    api_allowed_networks: ["0.0.0.0/0"] # Default: ["0.0.0.0/0"]
  5. Create a K3s cluster using k3s-simplified

    To provision a K3s cluster on Hetzner, you need kubectl, Helm, and the k3s-simplified tool. The process involves defining a cluster_config.yaml file to specify the cluster name, Hetzner token, node pools (masters and workers), and SSH keys.
    hetzner_token: YOUR_HETZNER_TOKEN
    cluster_name: hello-world
    kubeconfig_path: "./kubeconfig"
    k3s_version: v1.29.2+k3s1
    public_ssh_key_path: "~/.ssh/id_rsa.pub"
    private_ssh_key_path: "~/.ssh/id_rsa"
    use_ssh_agent: true
    ssh_allowed_networks:
      - 0.0.0.0/0
    api_allowed_networks:
      - 0.0.0.0/0
    schedule_workloads_on_masters: false
    masters_pool:
      instance_type: cx21
      instance_count: 3
      location: nbg1
    worker_node_pools:
    - name: small
      instance_type: cpx21
      instance_count: 4
      location: hel1

    Create the cluster

    k3s-simplified create --config cluster_config.yaml

    Configure kubectl access

    export KUBECONFIG=./kubeconfig

  6. Configure k3s cluster networking and CNI

    Manage the network identity and CNI for the k3s cluster using the following configuration options:

    • disable_flannel (default: false): Set to true to install a different CNI instead of Flannel.
    • cluster_cidr (default: 10.244.0.0/16): Custom IPv4/IPv6 network CIDR for pod IPs.
    • service_cidr (default: 10.43.0.0/16): Custom IPv4/IPv6 network CIDR for service IPs.
    • cluster_dns (default: 10.43.0.10): IPv4 Cluster IP for CoreDNS; must be within the service_cidr range.
    • private_network_subnet (default: 10.0.0.0/16): Subnet for the private network. Ensure no overlap with other project networks.
  7. Upgrade k3s cluster to a newer version

    To upgrade a k3s cluster for the first time, use the hetzner-k3s upgrade command. You must provide the configuration file and the target k3s version as arguments. The process automatically updates the configuration file to the new version. Note that single master clusters will experience temporary API server downtime during the control plane upgrade.
    # Upgrade to a specific version
    hetzner-k3s upgrade --config cluster_config.yaml --new-k3s-version v1.29.2+k3s1
    
    # List available k3s versions
    hetzner-k3s releases
  8. Create a NAT Gateway using k3s-simplified CLI

    Run the create-nat-gateway command referencing your configuration file to deploy the access box. The command will output the IP address of the NAT gateway, which should then be added to the post-install scripts of your master and worker nodes to enable public internet access for k3s upgrades and image pulls.
    k3s-simplified create-nat-gateway --config cluster_config.yaml
  9. Install k3s-simplified on macOS and Linux

    Install the k3s-simplified binary on macOS or Linux (supporting Apple Silicon, M1, amd64, and aarch64) by downloading the latest release, extracting the archive, and running the installation script with sudo privileges.
    wget https://github.com/easystartup-io/k3s-simplified/releases/latest/download/k3s-simplified.tar.gz -O k3s-simplified.tar.gz --backups=0  
    tar -xf k3s-simplified.tar.gz  
    cd k3s-simplified  
    chmod +x install.sh  
    sudo ./install.sh  
    cd ..