Back to Projects

RKE2 Ansible Role

An Ansible role to deploy and manage RKE2 Kubernetes clusters with high availability support via kube-vip.

Tech Stack

Ansible Kubernetes RKE2 kube-vip Calico

Overview

This Ansible role simplifies the deployment of RKE2 Kubernetes clusters. RKE2 is Rancher’s next-generation Kubernetes distribution, focused on security and compliance. This role automates the entire cluster lifecycle from bootstrapping to scaling.

Available on Ansible Galaxy for easy installation.

Features

  • Cluster Bootstrap: Initialize a new RKE2 control plane with a single command
  • Multi-Node Support: Add additional control plane nodes and worker nodes
  • High Availability: Configure kube-vip for a floating virtual IP on the control plane (ARP mode)
  • Dual-Stack Networking: Full IPv4/IPv6 dual-stack cluster support
  • CNI Flexibility: Calico as default CNI with configurable alternatives
  • Tooling: Optional installation of kubectl and calicoctl on all nodes
  • Kubeconfig Management: Automatically fetch kubeconfig to your local machine

Installation

Install from Ansible Galaxy:

ansible-galaxy install mtze.rke2

Or install the latest version directly from GitHub:

ansible-galaxy install git+https://github.com/Mtze/rke2-ansible.git,main

Quick Start

Bootstrap a New Cluster

First, run the role on a single node to initialize the cluster:

- hosts: server-node-1.example.com
  roles:
    - role: mtze.rke2
      vars:
        first_node_install: true

Then add remaining nodes:

- hosts: all_nodes
  roles:
    - role: mtze.rke2

High Availability with kube-vip

For production deployments, enable kube-vip for a highly available control plane:

- hosts: control_plane
  roles:
    - role: mtze.rke2
      vars:
        control_plane_vip: 10.20.30.1
        control_plane_vip_hostname: k8s.example.com
        control_plane_vip_interface: eth0

Configuration

Key variables include:

  • rke2_node_type: Set to server (control plane) or agent (worker)
  • first_node_install: Set to true for the initial bootstrap node
  • cni_plugin: CNI plugin selection (default: calico)
  • fetch_kube_config: Automatically retrieve kubeconfig (default: true)
  • cluster_cidr / service_cidr: Network configuration for dual-stack support

See the defaults folder for all available options.

License

MIT License — Contributions and issues welcome!