### Ingress-Nginx HelmChartConfig Example Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/templates-reference.md Example values for the ingress-nginx-config.yml.j2 template, used to configure the ingress-nginx controller via HelmChartConfig. Renders when rke2_ingress_nginx_values has content. ```yaml controller: config: use-forwarded-headers: "true" log-format-upstream: '$remote_addr...' ``` -------------------------------- ### Download RKE2 Artifacts for Air-Gapped Installation Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md Manually download the necessary RKE2 artifact files to a local directory for air-gapped installations using the copy strategy. ```bash mkdir local_artifacts cd local_artifacts # Download these files: # - rke2.linux-amd64.tar.gz # - rke2-images.linux-amd64.tar.zst # - sha256sum-amd64.txt # - rke2.sh (install script) ``` -------------------------------- ### Check Available Memory for RKE2 Installation Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Use `free -h` to verify sufficient system memory is available. Low memory can lead to RKE2 installation script failures. ```bash free -h ``` -------------------------------- ### Traefik HelmChartConfig Example Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/templates-reference.md Example values for the traefik-config.yml.j2 template, used to configure the traefik ingress controller via HelmChartConfig. Renders when rke2_traefik_values has content. ```yaml providers: kubernetesIngressNginx: enabled: true ingressClass: "rke2-ingress-nginx-migration" ``` -------------------------------- ### Use Alternate RKE2 Installation Mirror Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Configure `rke2_install_bash_url` to point to an alternative mirror if the default RKE2 installation URL is experiencing issues. This can help bypass network or availability problems. ```yaml vars: rke2_install_bash_url: "http://rancher-mirror.rancher.cn/rke2/install.sh" ``` -------------------------------- ### RKE2 Task Execution Flow Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/task-modules.md The main entry point `tasks/main.yml` orchestrates RKE2 installation and configuration tasks conditionally. ```yaml main.yml ├── keepalived.yml (if rke2_ha_mode and rke2_ha_mode_keepalived) ├── rke2.yml ├── cis.yml (if rke2_cis_profile is set) ├── find_active_server.yml ├── kubevip.yml (if rke2_ha_mode_kubevip) ├── ingress-nginx.yml (if ingress controller configured) ├── traefik.yml (if traefik configured) ├── first_server.yml (initial cluster setup) ├── first_server_restore.yml (etcd restore scenarios) ├── download_kubeconfig.yaml (if rke2_download_kubeconf) ├── remaining_nodes.yml (join remaining cluster nodes) ├── rolling_restart.yml (version upgrade restarts) ├── change_config.yml (config change restarts) └── summary.yml ``` -------------------------------- ### Air-Gapped Installation Playbook (Download Strategy) Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md Ansible playbook for deploying RKE2 in an air-gapped environment using the download strategy, where each node attempts to download artifacts. ```yaml --- - name: Deploy RKE2 Air-Gapped (Download) hosts: all become: yes vars: rke2_airgap_mode: true rke2_airgap_implementation: download # Each node downloads artifacts rke2_version: v1.28.0+rke2r1 roles: - role: lablabs.rke2 ``` -------------------------------- ### Node-Specific Configuration (host_vars/master-01.yml) Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/inventory-and-groups.md Provides an example of node-specific configuration, such as custom labels, for a particular host like master-01. ```yaml --- # Custom settings for specific node k8s_node_label: - "master-index=1" ``` -------------------------------- ### Kubelet Configuration Options Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/templates-reference.md Example Kubelet configuration options that can be rendered from the `kubelet-config.yaml.j2` template. These settings are part of the Kubernetes KubeletConfiguration format. ```yaml imageGCHighThresholdPercent: 80 imageGCLowThresholdPercent: 70 maxPods: 250 ``` -------------------------------- ### Check Network Connectivity to RKE2 Installer Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Use `curl` to verify network access to the RKE2 installation script URL. This helps diagnose 'Timeout downloading https://get.rke2.io' errors. ```bash curl -v https://get.rke2.io ``` -------------------------------- ### Example Custom Namespace Manifest Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md This is an example of a custom Kubernetes Namespace manifest. Manifests are automatically applied by RKE2 when placed in the specified directory and support Jinja2 templating. ```yaml --- apiVersion: v1 kind: Namespace metadata: name: custom-app ``` -------------------------------- ### Minimal Single-Node RKE2 Deployment Inventory Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md An example Ansible inventory file for a minimal single-node RKE2 deployment. ```ini [k8s_cluster] [masters] master-01 ansible_host=192.168.1.10 [workers] ``` -------------------------------- ### Ansible Playbook for RKE2 Air-Gapped Installation (Copy Strategy) Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md This Ansible playbook deploys RKE2 using the air-gapped 'copy' strategy. It assumes artifacts are pre-staged in a local directory and copies them to each node before installation. ```yaml --- - name: Deploy RKE2 Air-Gapped (Copy) hosts: all become: yes vars: rke2_airgap_mode: true rke2_airgap_implementation: copy # Copy pre-staged files rke2_airgap_copy_sourcepath: local_artifacts roles: - role: lablabs.rke2 ``` -------------------------------- ### Check RKE2 Version Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Check the installed RKE2 version using the 'rke2 --version' command. ```bash rke2 --version ``` -------------------------------- ### RKE2 Inventory File Example Source: https://github.com/lablabs/ansible-role-rke2/blob/main/README.md Defines the node distribution for RKE2 masters and workers. Masters must be in the 'masters' group and workers in the 'workers' group, both children of 'k8s_cluster'. ```ini [masters] master-01 ansible_host=192.168.123.1 master-02 ansible_host=192.168.123.2 master-03 ansible_host=192.168.123.3 [workers] worker-01 ansible_host=192.168.123.11 worker-02 ansible_host=192.168.123.12 worker-03 ansible_host=192.168.123.13 [k8s_cluster:children] masters workers ``` -------------------------------- ### Check Disk Space for RKE2 Installation Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Use `df -h` to check available disk space, particularly on the `/var/lib/rancher` partition, before or after an RKE2 installation failure. Insufficient disk space is a common cause for script execution errors. ```bash df -h /var/lib/rancher ``` -------------------------------- ### Check RKE2 Kubelet Log File Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Tail the RKE2 kubelet log file (`/var/lib/rancher/rke2/agent/logs/kubelet.log`) to find specific errors during installation or runtime. This is useful for troubleshooting script execution failures. ```bash tail -f /var/lib/rancher/rke2/agent/logs/kubelet.log ``` -------------------------------- ### Ensure Required Packages for RKE2 Installation Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Verify that essential packages like `curl` are installed on the target node using Ansible. Missing dependencies can cause the RKE2 installation script to fail. ```bash ansible all -m package -a "name=curl state=present" ``` -------------------------------- ### RKE2 Environment Variables Configuration Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/templates-reference.md This example demonstrates how to configure environment variables for the RKE2 service using a Jinja2 template. It exports proxy settings and custom environment variables that are read by the RKE2 systemd service. This is rendered when the 'rke2_environment_options' variable contains at least one key-value pair. ```bash export HTTP_PROXY=http://proxy.example.com:8080 export HTTPS_PROXY=https://proxy.example.com:8443 export NO_PROXY=localhost,127.0.0.1,.example.com ``` -------------------------------- ### Example of Safe YAML Value in RKE2 Config Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Shows a corrected RKE2 configuration token value that is safe and does not require special quoting. ```yaml rke2_token: "my-safe-token-123" ``` -------------------------------- ### Example of Quoted YAML Value in RKE2 Config Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Illustrates a problematic YAML value containing colons that requires quoting in the RKE2 configuration. ```yaml rke2_token: "my-secret:with:colons" # Requires quoting ``` -------------------------------- ### Configure Kubelet Cgroup Driver Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Specify the cgroup driver for the kubelet in the RKE2 configuration. Use 'systemd' or 'cgroupfs' based on your system's cgroup setup. ```yaml rke2_kubelet_config: cgroupDriver: systemd # or 'cgroupfs' rke2_kubelet_arg: - "--cgroup-driver=systemd" ``` -------------------------------- ### Deploy Custom Manifests Playbook Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md This playbook deploys custom Kubernetes manifests during RKE2 cluster setup. The manifests are specified in the `rke2_custom_manifests` variable. ```yaml --- - name: Deploy RKE2 with Custom Manifests hosts: all become: yes vars: rke2_custom_manifests: - manifests/custom-namespace.yaml - manifests/rbac.yaml - manifests/deployments.yaml roles: - role: lablabs.rke2 ``` -------------------------------- ### Ansible Playbook for RKE2 Air-Gapped Installation (Exists Strategy) Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md This Ansible playbook deploys RKE2 using the air-gapped 'exists' strategy. It assumes that all required RKE2 artifacts are already present on the target nodes. ```yaml --- - name: Deploy RKE2 Air-Gapped (Pre-Staged) hosts: all become: yes vars: rke2_airgap_mode: true rke2_airgap_implementation: exists # Artifacts already on nodes roles: - role: lablabs.rke2 ``` -------------------------------- ### RKE2 Load Balancer IP Range Configuration Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Example configuration for the RKE2 load balancer IP range. Adjust the range to fit your network requirements. ```yaml rke2_loadbalancer_ip_range: range-global: "192.168.1.100-192.168.1.150" # Adjust range ``` -------------------------------- ### Configure Master Nodes for RKE2 Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/inventory-and-groups.md This playbook targets only the nodes in the 'masters' group for specific master node configurations. It includes a debug task to show an example variable. ```yaml --- - name: Configure Master Nodes hosts: masters become: yes tasks: # Master-specific tasks - name: Print active server debug: msg: "Active server: {{ active_server }}" ``` -------------------------------- ### RKE2 Important Variables Table Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md Key variables for configuring RKE2 installations, including version, token, HA mode, API IP, and node type. These variables are essential for customizing the RKE2 cluster setup. ```markdown | Variable | Purpose | |----------|---------| | `rke2_version` | RKE2 version to install | | `rke2_token` | Pre-shared cluster token | | `rke2_ha_mode` | Enable HA mode | | `rke2_api_ip` | Cluster VIP or API IP | | `rke2_type` | Node type (auto-set) | ``` -------------------------------- ### Check System Resources for RKE2 Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Monitor available memory and disk space, especially for the RKE2 data directory, to rule out resource exhaustion as a cause of startup failures. ```bash free -h ``` ```bash df -h /var/lib/rancher ``` -------------------------------- ### Check Cgroup Mounts Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Verify how cgroups are mounted on the system. This is crucial for diagnosing kubelet startup failures related to cgroup configuration. ```bash grep cgroup /proc/mounts ``` -------------------------------- ### RKE2 Uninstall Script Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Execute the RKE2 uninstall script for a clean removal of the installation. ```bash /usr/local/bin/rke2-uninstall.sh ``` -------------------------------- ### Deploy RKE2 with Custom Kubelet Configuration Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md Customize Kubelet settings by defining `rke2_kubelet_config` and `rke2_kubelet_arg` variables. This generates `/etc/rancher/rke2/kubelet-config.yaml` and updates `/etc/rancher/rke2/config.yaml`. ```yaml --- - name: Deploy RKE2 with Custom Kubelet Config hosts: all become: yes vars: rke2_kubelet_config: imageGCHighThresholdPercent: 85 imageGCLowThresholdPercent: 75 maxPods: 250 featureGates: DynamicResourceAllocation: true rke2_kubelet_arg: - "--system-reserved=cpu=100m,memory=100Mi" roles: - role: lablabs.rke2 ``` -------------------------------- ### Check kube-vip ConfigMap Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Inspect the kube-vip ConfigMap in the kube-system namespace for misconfigurations. ```bash kubectl get configmap -n kube-system kube-vip-config ``` -------------------------------- ### Delete Corrupted Artifact Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Use this command to remove a corrupted artifact file before re-downloading. Ensure the path is correct for your RKE2 installation. ```bash rm /rke2/artifact/rke2.linux-amd64.tar.gz ``` -------------------------------- ### Directory Structure for Inventory and Group Variables Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/inventory-and-groups.md Illustrates the recommended directory structure for organizing Ansible inventory files and group variables. ```text playbook.yml inventory/ ├── hosts.yml ├── group_vars/ │ ├── k8s_cluster.yml │ ├── masters.yml │ └── workers.yml └── host_vars/ ├── master-01.yml ├── worker-01.yml └── ... ``` -------------------------------- ### Check kube-vip Pods Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md List all kube-vip pods in the kube-system namespace to ensure they are running correctly. ```bash kubectl get pods -n kube-system | grep kube-vip ``` -------------------------------- ### Run Ansible Playbook for Deployment Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md Execute the Ansible playbook to deploy an RKE2 cluster. Ensure your inventory file and playbook are correctly configured. ```bash ansible-playbook -i inventory playbook.yml ``` -------------------------------- ### Describe Node Conditions Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Get detailed information about a specific node's status, conditions, and events. Replace `` with the actual node name. ```bash kubectl describe node ``` -------------------------------- ### Configure Custom Kubernetes API Server Arguments Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md Use this playbook to deploy RKE2 with specific arguments for the Kubernetes API server, such as audit logging paths and service account issuers. ```yaml --- - name: Deploy RKE2 with Custom API Server Args hosts: all become: yes vars: rke2_kube_apiserver_args: - "audit-log-path=/var/log/kubernetes/audit.log" - "audit-max-age=30" - "service-account-issuer=https://kubernetes.default" roles: - role: lablabs.rke2 ``` -------------------------------- ### List Artifacts in Directory Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Check the contents of the artifact directory to verify that the expected RKE2 artifact file exists. This is a crucial step when troubleshooting 'Artifact not found' errors. ```bash ls -la /rke2/artifact/ ``` -------------------------------- ### HA Cluster RKE2 Deployment Inventory Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md An example Ansible inventory file for a High Availability (HA) RKE2 cluster with 3 masters and 3 workers. ```ini [k8s_cluster] [masters] master-01 ansible_host=192.168.1.10 master-02 ansible_host=192.168.1.11 master-03 ansible_host=192.168.1.12 [workers] worker-01 ansible_host=192.168.1.20 worker-02 ansible_host=192.168.1.21 worker-03 ansible_host=192.168.1.22 ``` -------------------------------- ### RKE2 Server Node Taints Configuration Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Example configuration for RKE2 server node taints. Modify the taint effect (e.g., remove `:NoExecute`) for testing purposes. ```yaml rke2_server_node_taints: - "workload-type=control-plane:NoSchedule" # Remove :NoExecute for test workloads ``` -------------------------------- ### Playbook for Deploying Multiple RKE2 Clusters Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/inventory-and-groups.md This playbook demonstrates deploying RKE2 on multiple clusters defined in the inventory. It uses distinct variables for each cluster to specify group names for servers and agents. ```yaml --- - name: Deploy Production RKE2 hosts: prod_cluster become: yes vars: rke2_cluster_group_name: prod_cluster rke2_servers_group_name: prod_masters rke2_agents_group_name: prod_workers roles: - role: lablabs.rke2 - name: Deploy Staging RKE2 hosts: staging_cluster become: yes vars: rke2_cluster_group_name: staging_cluster rke2_servers_group_name: staging_masters rke2_agents_group_name: staging_workers roles: - role: lablabs.rke2 ``` -------------------------------- ### Deploy RKE2 Air-Gapped Playbook Source: https://github.com/lablabs/ansible-role-rke2/blob/main/README.md Deploys RKE2 in air-gapped mode using the 'copy' implementation. Transfers local artifact files to target nodes. Supports Multus and Calico CNI. ```yaml - name: Deploy RKE2 hosts: all become: yes vars: rke2_airgap_mode: true rke2_airgap_implementation: copy rke2_cni: - multus - calico rke2_artifact: - sha256sum-{{ rke2_architecture }}.txt - rke2.linux-{{ rke2_architecture }}.tar.gz - rke2-images.linux-{{ rke2_architecture }}.tar.zst rke2_airgap_copy_additional_tarballs: - rke2-images-multus.linux-{{ rke2_architecture }} - rke2-images-calico.linux-{{ rke2_architecture }} roles: - role: lablabs.rke2 ``` -------------------------------- ### Deploy RKE2 with Node Taints and Labels Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md Configure node taints for workload scheduling and labels for identification during RKE2 deployment. ```yaml --- - name: Deploy RKE2 with Node Configuration hosts: all become: yes vars: rke2_server_node_taints: - 'workload-type=control-plane:NoSchedule' - 'CriticalAddonsOnly=true:NoExecute' rke2_agent_node_taints: - 'workload-type=application:NoSchedule' k8s_node_label: - 'node-type=worker' - 'environment=production' roles: - role: lablabs.rke2 ``` -------------------------------- ### Configure ingress-nginx with Custom Values Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md Use this playbook to deploy RKE2 with custom configurations for the ingress-nginx controller. Specify custom values for controller settings and resource requests. ```yaml --- - name: Deploy RKE2 with Custom ingress-nginx hosts: all become: yes vars: rke2_ingress_controller: ingress-nginx rke2_ingress_nginx_values: controller: config: use-forwarded-headers: "true" proxy-body-size: "100m" resources: requests: cpu: 100m memory: 128Mi roles: - role: lablabs.rke2 ``` -------------------------------- ### Get RKE2 Nodes using kubectl Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Use kubectl with the RKE2 kubeconfig to check if the API server is running and nodes are registered. This is useful for diagnosing API server reachability issues. ```bash kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get nodes ``` -------------------------------- ### Serial Deployment for Large RKE2 Clusters in Ansible Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/inventory-and-groups.md Configure a playbook to deploy RKE2 to a large cluster in serial batches to manage resource load. This example deploys 10 hosts at a time. ```yaml --- - name: Deploy RKE2 Large Cluster hosts: k8s_cluster serial: 10 # 10 hosts at a time become: yes roles: - role: lablabs.rke2 ``` -------------------------------- ### Validate RKE2 Configuration Syntax Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Display the RKE2 configuration file to manually check for YAML syntax errors. Ensure correct indentation and key-value pairs. ```bash cat /etc/rancher/rke2/config.yaml ``` -------------------------------- ### Check RKE2 Service Status Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Use this command to check the current status of the rke2-server service. This is a common first step in diagnosing startup failures. ```bash systemctl status rke2-server.service ``` -------------------------------- ### Configure RKE2 S3 Backup Options Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Configure RKE2 etcd snapshot options for S3 backups, including endpoint, access key, and secret key. ```yaml rke2_etcd_snapshot_s3_options: s3_endpoint: "https://minio.example.com:9000" access_key: "correct_key" secret_key: "correct_secret" ``` -------------------------------- ### Bypass RKE2 Downgrade Prevention Check Source: https://github.com/lablabs/ansible-role-rke2/blob/main/README.md Use this variable when rerunning an RKE2 upgrade playbook that failed due to an interrupted upgrade. It allows the playbook to proceed even if the new version is not yet started. ```yaml rke2_allow_downgrade: true ``` -------------------------------- ### Deploy RKE2 HA Control-Plane with Keepalived Source: https://github.com/lablabs/ansible-role-rke2/blob/main/README.md Deploys RKE2 with HA server control-plane and agent nodes. Installs keepalived on control-plane nodes for VIP, taints server nodes for workload distribution, and downloads the kubeconfig. ```yaml - name: Deploy RKE2 hosts: all become: yes vars: rke2_ha_mode: true rke2_api_ip : 192.168.123.100 rke2_download_kubeconf: true rke2_server_node_taints: - 'CriticalAddonsOnly=true:NoExecute' roles: - role: lablabs.rke2 ``` -------------------------------- ### Check Pod Tolerations Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Inspect the tolerations defined for a specific pod to understand why it might not be scheduling on certain nodes. Replace `` with the actual pod name. ```bash kubectl describe pod | grep -A5 Tolerations ``` -------------------------------- ### RKE2 Architecture Overview Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md Visual representation of the Ansible role's execution flow, from the deployment playbook and inventory to the various tasks executed by the role and the final RKE2 cluster state. ```markdown Deployment Playbook ↓ [Inventory: masters, workers, k8s_cluster groups] ↓ Role Entry: tasks/main.yml ├→ keepalived.yml (HA setup) ├→ rke2.yml (core installation) ├→ cis.yml (security hardening) ├→ find_active_server.yml (cluster detection) ├→ kubevip.yml (kube-vip setup) ├→ ingress-nginx.yml (ingress setup) ├→ traefik.yml (traefik setup) ├→ first_server.yml (cluster init) ├→ remaining_nodes.yml (node joining) ├→ rolling_restart.yml (upgrades) └→ summary.yml (final report) ↓ [RKE2 Cluster: Running on all nodes] ``` -------------------------------- ### Manual RKE2 Cleanup Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Perform manual cleanup by stopping, disabling services, and removing RKE2 directories. ```bash systemctl stop rke2-server.service systemctl stop rke2-agent.service systemctl disable rke2-server.service systemctl disable rke2-agent.service rm -rf /var/lib/rancher/ rm -rf /etc/rancher/ rm -rf /opt/rke2/ ``` -------------------------------- ### Check RKE2 Config Directory Permissions Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Verify if the RKE2 configuration directory exists and check its permissions. ```bash ls -ld /etc/rancher/rke2/ ``` -------------------------------- ### Enable Debug Logging for RKE2 Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md Enable verbose logging for RKE2 by setting `rke2_debug: true`. This is useful for debugging deployment issues. ```yaml rke2_debug: true ``` -------------------------------- ### Configure Etcd Backups to S3 Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md Deploy RKE2 with automatic etcd backups scheduled to S3-compatible storage. Configure S3 endpoint, credentials, bucket, region, folder, and snapshot retention. ```yaml --- - name: Deploy RKE2 with S3 Etcd Backups hosts: all become: yes vars: rke2_etcd_snapshot_schedule: "0 */6 * * *" # Every 6 hours rke2_etcd_snapshot_s3_options: s3_endpoint: "https://minio.example.com:9000" access_key: "{{ vault_aws_access_key }}" secret_key: "{{ vault_aws_secret_key }}" bucket: "rke2-etcd-backups" region: "us-east-1" folder: "production" s3_retention: 10 # Keep last 10 snapshots roles: - role: lablabs.rke2 ``` -------------------------------- ### Minimal Single-Node RKE2 Deployment Playbook Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md An Ansible playbook to deploy the RKE2 role on a single node. ```yaml --- - name: Deploy RKE2 hosts: all become: yes roles: - role: lablabs.rke2 ``` -------------------------------- ### Configure Firewall for RKE2 Ports Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Ensure that the necessary RKE2 ports (6443 for API, 9345 for registration) are open in the firewall. This is essential for cluster communication. ```bash # Allow ports 6443 (API) and 9345 (registration) ufw allow 6443/tcp ufw allow 9345/tcp ``` -------------------------------- ### Display Keepalived Configuration Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Review the Keepalived configuration file to ensure it is correctly set up for VIP management. ```bash cat /etc/keepalived/keepalived.conf ``` -------------------------------- ### Manually Render RKE2 Config Template Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Manually render the RKE2 configuration template to a temporary file for debugging. ```bash ansible localhost -m template -a "src=templates/config.yaml.j2 dest=/tmp/config.yaml" ``` -------------------------------- ### Ansible Kubernetes Dynamic Inventory Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/inventory-and-groups.md Set up Ansible to dynamically inventory resources from an existing Kubernetes cluster. Requires a valid kubeconfig. ```yaml --- plugin: kubernetes.core.k8s connections: - kubeconfig: /etc/kubernetes/admin.conf context: prod ``` -------------------------------- ### Copy Artifacts to Target Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Transfer RKE2 artifact files from your local machine to the target server using `scp`. This is necessary when artifacts are not present on the target system. ```bash scp local_artifacts/* user@target:/rke2/artifact/ ``` -------------------------------- ### Enable RKE2 Debug Mode Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Set the 'rke2_debug' variable to true to enable verbose logging for RKE2 and kubelet. ```yaml vars: rke2_debug: true ``` -------------------------------- ### Check Node Allocated Resources Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md View the resources (CPU, memory) allocated and requested by pods on a specific node. Replace `` with the actual node name. ```bash kubectl describe node | grep -A5 "Allocated resources" ``` -------------------------------- ### Check RKE2 Server Service Logs Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md Check the system journal for logs related to the RKE2 server service. This is a common step for debugging deployment issues. ```bash journalctl -u rke2-server.service ``` -------------------------------- ### Verify Etcd Snapshot Existence Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Use this command to list files in the etcd snapshot directory to verify the snapshot file exists. ```bash ls -la etcd_snapshots/ ``` -------------------------------- ### Minimal Single-Node RKE2 Deployment Command Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/README.md The command to execute the Ansible playbook for a minimal RKE2 deployment. ```bash ansible-playbook -i hosts.ini playbook.yml ``` -------------------------------- ### Check RKE2 Server Endpoint in Config Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/error-conditions.md Inspect the RKE2 configuration file to confirm the server address and port are correctly specified. This is relevant if the API server is not reachable. ```bash cat /etc/rancher/rke2/config.yaml | grep server: ``` -------------------------------- ### Deploy RKE2 with Multiple CNI Plugins Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/usage-patterns.md Deploy an RKE2 cluster with multiple CNI plugins, such as Multus and Calico. Ensure required additional tarball images are available for air-gapped environments. ```yaml --- - name: Deploy RKE2 with Multus and Calico hosts: all become: yes vars: rke2_cni: - multus - calico rke2_airgap_copy_additional_tarballs: - "rke2-images-multus.linux-amd64.tar.zst" - "rke2-images-calico.linux-amd64.tar.zst" roles: - role: lablabs.rke2 ``` -------------------------------- ### Static Inventory for Large RKE2 Clusters Source: https://github.com/lablabs/ansible-role-rke2/blob/main/_autodocs/inventory-and-groups.md Define a static inventory for large-scale RKE2 clusters, organizing nodes by zones and using Ansible's range and host pattern syntax for efficient definition. ```ini [k8s_cluster] [masters] master-us-west-1a ansible_host=10.0.1.10 zone=us-west-1a master-us-west-1b ansible_host=10.0.2.10 zone=us-west-1b master-us-west-1c ansible_host=10.0.3.10 zone=us-west-1c [workers] # Zone 1a (40 nodes) worker-us-west-1a-[01:40] ansible_hosts=10.0.1.[20:59] zone=us-west-1a # Zone 1b (40 nodes) worker-us-west-1b-[01:40] ansible_hosts=10.0.2.[20:59] zone=us-west-1b # Zone 1c (40 nodes) worker-us-west-1c-[01:40] ansible_hosts=10.0.3.[20:59] zone=us-west-1c ``` -------------------------------- ### Deploy RKE2 Single Node Playbook Source: https://github.com/lablabs/ansible-role-rke2/blob/main/README.md Deploys RKE2 to a single node acting as both server and agent, using the RKE2 version defined in the role defaults. ```yaml - name: Deploy RKE2 hosts: node01 become: yes roles: - role: lablabs.rke2 ```