### Installing Raspberry Pi Imager Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration This command installs the Raspberry Pi Imager tool using Homebrew. This tool is recommended for installing the OS on Raspberry Pi nodes. ```shell brew install --cask raspberry-pi-imager ``` -------------------------------- ### Verify Helm Installation Source: https://context7.com/axivo/k3s-cluster/llms.txt Commands to verify Helm installation and plugin status on a server node. Confirms Helm is available in the PATH and checks the installed versions. ```bash # Helm is installed as part of the kubernetes play ansible-playbook provisioning.yaml --tags kubernetes # Verify installation on a server node kubectl get nodes # confirms Helm is available on PATH helm version # v3.20.0-1 helm plugin list # diff v3.15.6 ``` -------------------------------- ### Install Ansible Collections Source: https://context7.com/axivo/k3s-cluster/llms.txt Install all required Ansible collections listed in `collections/requirements.yaml` using the `ansible-galaxy` command. ```bash # Install all required Ansible collections ansible-galaxy collection install -r collections/requirements.yaml ``` -------------------------------- ### Query VictoriaMetrics and Check Health Endpoints Source: https://context7.com/axivo/k3s-cluster/llms.txt Examples for querying metrics from VictoriaMetrics, checking Grafana API health, and listing firing alerts from Alertmanager. ```bash # Query VictoriaMetrics directly via vmselect curl -G 'https://metrics.example.com/api/v1/query' \ --data-urlencode 'query=node_memory_MemAvailable_bytes' \ --data-urlencode 'time=now' # Returns Prometheus-compatible JSON # Check Grafana datasource health curl -u admin: https://grafana.example.com/api/health # {"commit":"...","database":"ok","version":"..."} # List firing alerts curl -s https://alertmanager.example.com/api/v1/alerts | jq '.data[] | .labels' ``` -------------------------------- ### Provision K3s Cluster Source: https://context7.com/axivo/k3s-cluster/llms.txt Execute the main provisioning playbook `provisioning.yaml` to deploy the K3s cluster. Use tags to target specific plays like OS baseline, load balancer, K3s installation, or Helm chart deployments. ```bash # Full cluster provisioning (all plays) ansible-playbook provisioning.yaml # Only OS baseline + load balancer ansible-playbook provisioning.yaml --tags cluster # Only K3s binary + service installation ansible-playbook provisioning.yaml --tags kubernetes # Only Helm chart deployments ansible-playbook provisioning.yaml --tags charts ``` -------------------------------- ### Stream Live Logs with VictoriaLogs Source: https://context7.com/axivo/k3s-cluster/llms.txt Example using curl to stream live logs from VictoriaLogs. Adjust the query to filter logs as needed. ```bash # Stream live logs curl -G 'https://logs.example.com/select/logsql/tail' \ --data-urlencode 'query=kubernetes.namespace_name:"kube-system"' ``` -------------------------------- ### Query Logs with VictoriaLogs LogsQL Source: https://context7.com/axivo/k3s-cluster/llms.txt Example using curl to query logs from VictoriaLogs. Ensure the subdomain in the URL matches your configuration. ```bash # Query logs for a specific pod (VictoriaLogs LogsQL) curl -G 'https://logs.example.com/select/logsql/query' \ --data-urlencode 'query=kubernetes.pod_name:"cilium*" AND level:error' \ --data-urlencode 'start=1h' \ --data-urlencode 'limit=50' ``` -------------------------------- ### Install/Upgrade K3s Binary Source: https://context7.com/axivo/k3s-cluster/llms.txt Command to install or upgrade the K3s binary using Ansible. The role checks the running version against the desired version and schedules a reboot if necessary. ```bash # Install/upgrade K3s binary only ansible-playbook provisioning.yaml --tags kubernetes # After upgrade, role checks running version vs desired version and # schedules a node reboot (via /var/run/reboot-required) only if changed. ``` -------------------------------- ### Ansible Playbook Batch Size for Reset Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration Configures the batch size for the reset playbook. This example is for a 4-node cluster (3 server, 1 agent). ```yaml serial: - 3 - 1 ``` -------------------------------- ### Helm Package Manager Configuration Source: https://context7.com/axivo/k3s-cluster/llms.txt Default variables for Helm installation, including environment settings, plugin configurations (like helm-diff), and repository details for the Helm release. ```yaml # roles/helm/defaults/main.yaml helm_vars: environment: HELM_NAMESPACE: default plugins: - name: diff enabled: true packages: - python3-jsonpatch repository: url: https://github.com/databus23/helm-diff version: v3.15.6 release: helm: distro: channel: any name: debian key: helm-archive-keyring.gpg repository: channel: stable key: gpgkey url: https://packages.buildkite.com/helm-linux/helm-debian version: v3.20.0-1 ``` -------------------------------- ### Run Cluster OS Baseline with Ansible Source: https://context7.com/axivo/k3s-cluster/llms.txt Execute the Ansible playbook to apply the 'cluster' role, which validates hardware, upgrades packages, and configures system services. This command ensures the OS baseline is established before further cluster setup. ```bash # Run only the cluster OS baseline ansible-playbook provisioning.yaml --tags cluster # Expected: validates hardware product, upgrades apt packages, # configures user, SSH, firewall, and system services. ``` -------------------------------- ### Regenerate Role README Locally with helm-docs Source: https://context7.com/axivo/k3s-cluster/llms.txt Locally regenerate a role's README file from its template using the helm-docs command. Ensure helm-docs is installed before running this command. ```bash # Locally regenerate a role's README from its template (requires helm-docs) helm-docs --chart-search-root roles/cilium --output-file README.md ``` -------------------------------- ### Ansible Playbook Batch Size for Server Nodes Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration Configures the batch size for deploying K3S services on server nodes. This example shows a batch size for a 4-node cluster (3 server, 1 agent). ```yaml serial: - 1 server type node, token generated on apollo - 2 server type nodes, token copied to boreas, cerus - 5 agent type nodes, token copied to chaos, crios, helios, hermes, hypnos ``` ```yaml serial: - 1 - 2 - 1 ``` -------------------------------- ### Create PersistentVolumeClaim with Longhorn Source: https://context7.com/axivo/k3s-cluster/llms.txt Apply a PersistentVolumeClaim definition to create a new volume using the Longhorn storage class. Ensure the namespace and storage class name match your cluster setup. ```yaml # Create a PersistentVolumeClaim using the Longhorn storage class kubectl apply -f - <' --name 'ansible_password' ``` -------------------------------- ### Login to Argo CD Source: https://context7.com/axivo/k3s-cluster/llms.txt Command to log in to the Argo CD API server using the CLI. Replace 'argocd.example.com' with your domain and provide the correct username and password. ```bash argocd login argocd.example.com --username alice --password ``` -------------------------------- ### Sync and Get Argo CD Application Status Source: https://context7.com/axivo/k3s-cluster/llms.txt Commands to synchronize an Argo CD application and retrieve its current status. Useful for verifying deployment and sync operations. ```bash argocd app sync my-app argocd app get my-app ``` -------------------------------- ### Argo CD Configuration Variables Source: https://context7.com/axivo/k3s-cluster/llms.txt Key settings for deploying Argo CD. Configure admin access, exec terminal, application set controller, controller sharding, and autoscaling for repo-server and server. Also includes settings for Redis HA and server ingress. ```yaml argocd_vars: kubernetes: configs: cm: admin: enabled: false # built-in admin disabled; use Dex SSO exec: enabled: true # web-based terminal enabled params: applicationsetcontroller: progressive_syncs: enabled: true controller: log_level: warn sharding: algorithm: consistent-hashing controller: dynamic_cluster_distribution: enabled: true replicas: 1 helm: chart: name: argo-cd version: v9.5.2 repository: name: argo-helm org: argoproj url: https://argoproj.github.io namespace: kube-system redis: ha: enabled: false # set true when >= 3 worker nodes storage: enabled: false class: longhorn size: 10Gi repo_server: autoscaling: enabled: true min_replicas: 1 max_replicas: 3 target: utilization_percentage: memory: 80 server: autoscaling: enabled: true min_replicas: 1 max_replicas: 3 ingress: subdomain: api: argocd # exposed at https://argocd. grpc: grpc.argocd release: file: argocd-linux-arm64 version: v3.3.7 ``` -------------------------------- ### Determine Hardware Product Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration Use 'lshw' to identify the hardware product, such as the Raspberry Pi model. This is used for the 'cluster_vars.hardware.product' setting. ```shell ~$ lshw -class system -quiet | grep product product: Raspberry Pi 4 Model B Rev 1.5 ``` -------------------------------- ### Check Longhorn and PVC Status Source: https://context7.com/axivo/k3s-cluster/llms.txt Use `longhornctl` for preflight checks and `kubectl` to verify the status and details of your PersistentVolumeClaims. ```bash # Check volume and replica health longhornctl check preflight kubectl get pvc -n default # NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE # my-data Bound pvc-abc123... 10Gi RWO longhorn 30s ``` -------------------------------- ### Verify Cert-Manager API and ClusterIssuer Source: https://context7.com/axivo/k3s-cluster/llms.txt Commands to check cert-manager API readiness and list ClusterIssuers. The selfsigned-issuer should be ready shortly after deployment. ```bash # Verify cert-manager and the self-signed ClusterIssuer cmctl check api # Expected: The cert-manager API is ready kubectl get clusterissuer -n kube-system # NAME READY AGE # selfsigned-issuer True 5m # Check certificate status for a workload cmctl status certificate hubble-server-certs -n kube-system ``` -------------------------------- ### Configure VictoriaLogs Variables Source: https://context7.com/axivo/k3s-cluster/llms.txt Default variables for deploying VictoriaLogs, including Helm chart details, repository information, and server configurations for ingress, logging, retention, and storage. ```yaml victorialogs_vars: kubernetes: helm: chart: alias: vls name: victoria-logs-single version: v0.12.0 repository: name: helm-charts org: VictoriaMetrics url: https://victoriametrics.github.io namespace: kube-system server: ingress: subdomain: logs # https://logs. log_level: WARN retention_period: 7d storage: enabled: true class: longhorn size: 5Gi vector: enabled: true autoscaling: enabled: true min_replicas: 1 max_replicas: 3 target: utilization_percentage: memory: 80 ``` -------------------------------- ### Cert-Manager Configuration Variables Source: https://context7.com/axivo/k3s-cluster/llms.txt Default variables for deploying cert-manager. Configure replicas, resources, and Helm chart details here. Ensure the namespace is set correctly. ```yaml certmanager_vars: kubernetes: cainjector: resources: limits: memory: 128Mi requests: cpu: 10m memory: 128Mi controller: replicas: 2 resources: limits: memory: 128Mi requests: cpu: 10m memory: 128Mi helm: chart: name: cert-manager version: v1.20.2 repository: name: cert-manager org: jetstack url: https://charts.jetstack.io global: log_level: 2 namespace: kube-system webhook: replicas: 1 release: checksum: checksums.txt file: cmctl_linux_arm64 repository: name: cmctl org: cert-manager version: v2.4.1 ``` -------------------------------- ### Deploy and Verify Cilium Source: https://context7.com/axivo/k3s-cluster/llms.txt Command to deploy Cilium as part of the charts play using Ansible. Includes verification steps using `cilium status --wait`. ```bash # Deploy Cilium as part of the charts play ansible-playbook provisioning.yaml --tags charts # Verify Cilium status after deployment cilium status --wait # Expected output: # /¯¯\ # /¯¯\__/¯¯\ Cilium: OK # \__/¯¯\__/ Operator: OK # /¯¯\__/¯¯\ Envoy DaemonSet: OK # \__/¯¯\__/ Hubble Relay: OK # \__/ ClusterMesh: disabled ``` -------------------------------- ### Configure CoreDNS Variables Source: https://context7.com/axivo/k3s-cluster/llms.txt Default variables for deploying CoreDNS, including Helm chart details, repository information, and HPA settings for memory-based autoscaling. ```yaml # roles/coredns/defaults/main.yaml corendns_vars: kubernetes: helm: chart: name: coredns version: v1.45.2 repository: name: helm org: coredns url: https://coredns.github.io hpa: enabled: true min_replicas: 1 max_replicas: 3 resource: name: memory target: utilization: 80 deployment: legacy: false # set true to use kube-dns label selectors namespace: kube-system ``` -------------------------------- ### Configure Ansible Defaults Source: https://context7.com/axivo/k3s-cluster/llms.txt Set default Ansible configurations, including inventory path, Python interpreter, and SSH settings, in the `ansible.cfg` file at the project root. ```ini # ansible.cfg [defaults] callback_result_format = yaml callbacks_enabled = ansible.posix.profile_tasks display_skipped_hosts = false host_key_checking = false interpreter_python = auto_silent inventory = ./inventory/cluster/hosts.yaml ``` -------------------------------- ### Verify Metrics API Availability with kubectl top nodes Source: https://context7.com/axivo/k3s-cluster/llms.txt Command to verify that the Metrics Server is functioning by displaying current resource usage for all nodes in the cluster. ```bash # Verify metrics API availability kubectl top nodes # NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% # apollo 312m 7% 1847Mi 23% # boreas 287m 7% 1703Mi 21% ``` -------------------------------- ### Determine Hardware Product Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration Shell command to determine the hardware product of a node. The output should be used to update the `cluster_vars.hardware.product` setting. ```shell ~$ lshw -class system -quiet | grep product product: Raspberry Pi 4 Model B Rev 1.5 ``` -------------------------------- ### Verify USB Device Name Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration Use 'lsusb' with 'grep' to verify the device name, specifically checking for the chipset like 'ASMedia Technology'. This confirms the 'cluster_vars.device.name' setting. ```shell ~$ lsusb -s '2:2' | grep 'ASMedia Technology' Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge, ASM1153E SATA 6Gb/s bridge ``` -------------------------------- ### Test SSD Device Performance Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration Use 'dd' command to test read and write speeds of an SSD device. Ensure 'sync' is run before 'dd' to flush caches. Remove the temporary file afterwards. ```shell ~$ sync; dd if=/dev/zero of=tempfile bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 5.12844 s, 209 MB/s ``` ```shell ~$ sync; dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.931618 s, 1.2 GB/s ``` ```shell ~$ rm -f tempfile ``` -------------------------------- ### Verify ExternalDNS Record Synchronization Source: https://context7.com/axivo/k3s-cluster/llms.txt Check the logs of the external-dns pods to verify that DNS records are being updated. Look for messages indicating record creation and successful updates. ```bash # After provisioning, verify ExternalDNS is picking up records kubectl logs -n kube-system -l app.kubernetes.io/name=external-dns --tail=20 # Expected: time="..." level=info msg="Applying provider record filter for zones: [example.com]" time="..." level=info msg="Desired change: CREATE argocd.example.com A [...]" time="..." level=info msg="1 record(s) in zone example.com were successfully updated" ``` -------------------------------- ### GitHub Actions Workflow for Documentation Generation Source: https://context7.com/axivo/k3s-cluster/llms.txt This GitHub Actions workflow triggers on pull requests that modify specific files related to role defaults, chart information, or README templates. It uses helm-docs to regenerate README files from templates and commits the changes back to the PR. ```yaml # .github/workflows/release.yml (key steps) on: pull_request: paths: - roles/*/defaults/main.yaml - roles/*/Chart.yaml - roles/*/README.md.gotmpl jobs: update: steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: 24 - run: npm install handlebars - name: Install helm-docs uses: actions/github-script@v9 with: script: | const { Workflow } = require('./.github/actions/handlers'); const workflow = new Workflow({ github, context, core, exec }); await workflow.installHelmDocs('1.14.2'); - name: Process releases uses: actions/github-script@v9 with: script: | const { Workflow } = require('./.github/actions/handlers'); const workflow = new Workflow({ github, context, core, exec }); await workflow.processReleases(); ``` -------------------------------- ### Verify Metrics API Availability with kubectl top pods Source: https://context7.com/axivo/k3s-cluster/llms.txt Command to list the top pods by memory usage within the kube-system namespace, useful for identifying resource-intensive pods after Metrics Server deployment. ```bash kubectl top pods -n kube-system --sort-by=memory | head -10 ``` -------------------------------- ### Ansible Playbook Structure for Provisioning Source: https://context7.com/axivo/k3s-cluster/llms.txt This YAML defines Ansible tasks for playbook validation and Kubernetes/Charts provisioning. It includes host targeting, serial execution, role application, and post-task includes. ```yaml - name: Playbook Validation hosts: localhost tasks: - name: Validate tags ansible.builtin.fail: msg: "Invalid tag. Valid tags: {{ global_map.tags.play | join(', ') }}" when: - ansible_run_tags not in [(), ('all',)] - ansible_run_tags | difference(global_map.tags.play) | length > 0 - name: Validate version ansible.builtin.fail: msg: "Invalid Ansible version, minimum requirement is '{{ global_map.ansible.version }}'." when: ansible_version.full is not version(global_map.ansible.version, '>=') - name: Kubernetes Provisioning hosts: cluster serial: - 1 # first node only - 2 # then two nodes in parallel - 5 # then up to five nodes roles: - helm - k3s tags: kubernetes - name: Charts Provisioning hosts: server roles: - cilium - coredns - cert-manager - external-dns - argo-cd - kured - longhorn - metrics-server - victoria-logs - victoria-metrics post_tasks: - name: Perform post-install tasks ansible.builtin.include_role: name: '{{ postinstall }}' tasks_from: postinstall loop: - argo-cd - cert-manager - cilium - coredns - external-dns - kured - longhorn - metrics-server - victoria-logs tags: charts ``` -------------------------------- ### Configure Kured Variables for Node Reboots Source: https://context7.com/axivo/k3s-cluster/llms.txt Default variables for deploying Kured, specifying reboot concurrency, check periods, reboot delays, and maintenance window times. ```yaml # roles/kured/defaults/main.yaml kured_vars: kubernetes: configuration: concurrency: 1 # reboot one node at a time period: 15m # how often to check /var/run/reboot-required reboot_delay: 60s # drain/cordon delay before reboot slack: enabled: true messages: enabled: false # set true to send custom drain/reboot/uncordon messages notify_url: # set via vault in group_vars/all.yaml time: start: '04:00' end: '08:00' zone: UTC helm: chart: name: kured version: v5.11.0 repository: name: charts org: kubereboot url: https://kubereboot.github.io namespace: kube-system ``` -------------------------------- ### List USB Devices Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration Shell command to list connected USB devices. This output is used to identify device IDs and names for storage validation in K3s cluster configuration. ```shell ~$ lsusb Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge, ASM1153E SATA 6Gb/s bridge Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub ``` -------------------------------- ### Ansible Reset Playbook Configuration Source: https://context7.com/axivo/k3s-cluster/llms.txt The reset.yaml playbook is configured to prompt the user for confirmation before removing apt packages. It then includes a 'reset' role to perform the teardown tasks across the cluster. ```yaml # reset.yaml (abridged) - name: Cluster Reset hosts: cluster serial: - 3 - 5 vars_prompt: - name: prompt_remove_packages prompt: Remove installed apt packages? [Y/n] default: 'n' private: false tasks: - name: Reset cluster ansible.builtin.include_role: name: '{{ reset }}' tasks_from: reset loop: - cluster - k3s - argo-cd - cert-manager - cilium - coredns - external-dns - kured - longhorn - metrics-server - victoria-logs - victoria-metrics - helm ``` -------------------------------- ### SSH Key Files Listing Source: https://github.com/axivo/k3s-cluster/wiki/Cluster:-Configuration This output shows the generated SSH private and public key files in the default .ssh directory. The private key (id_ed25519) should be kept secure. ```shell ~$ pwd /Users/username ~$ ls -lah .ssh/ total 24 drwx------ 5 username staff 160B 25 Sep 2023 . drwxr-xr-x 22 username staff 704B 20 Feb 15:54 .. -rw------- 1 username staff 411B 25 Dec 2022 id_ed25519 -rw-r--r-- 1 username staff 98B 25 Dec 2022 id_ed25519.pub ``` -------------------------------- ### Test Internal DNS Resolution with CoreDNS Source: https://context7.com/axivo/k3s-cluster/llms.txt Command to test internal DNS resolution from within a pod using CoreDNS. This verifies that the cluster's DNS is functioning correctly. ```bash # Test internal DNS resolution from within a pod kubectl run dns-test --image=busybox --restart=Never --rm -it -- \ nslookup kubernetes.default.svc.cluster.local # Server: 10.43.0.10 # Address 1: 10.43.0.10 kube-dns.kube-system.svc.cluster.local # Name: kubernetes.default.svc.cluster.local # Address 1: 10.43.0.1 ``` -------------------------------- ### Watch Kured Logs for Reboot Orchestration Source: https://context7.com/axivo/k3s-cluster/llms.txt Command to stream Kured logs in real-time to monitor the node reboot process, including draining, rebooting, and uncordoning stages. ```bash # Watch Kured log for reboot orchestration kubectl logs -n kube-system -l name=kured -f # time="..." msg="Reboot required" node="apollo" # time="..." msg="Draining node" node="apollo" # time="..." msg="Rebooting node" node="apollo" # time="..." msg="Uncordoning node" node="apollo" ```