Description

This page will explain how to start an automated upgrade in k3s

Steps

  1. Install system-upgrader kubectl apply -f https://github.com/rancher/system-upgrade-controller/releases/latest/download/system-upgrade-controller.yaml
    • This will install the system-upgrader in the namespace system-upgrade
  2. Configure Plans
    • It is recommended to configure a separate plan for the Server ( master ) and the agent ( worker ) nodes. Check out Plans for more info.
    • When deciding what version to use, check out K3S Releases

Plans

Important options:

  • concurency indicates how many nodes at a time can be upgraded. A good value here is one.
  • prepare as indicated in the Agent Plan will force the Server Plan to go first, before upgrading the agents.
  • version should be the same for the agent and the server. This is the Kubernetes version that we will be upgrading to. Check out K3S Releases

Server Plan

# Server plan
apiVersion: upgrade.cattle.io/v1
kind: Plan
metadata:
  name: server-plan
  namespace: system-upgrade
spec:
  concurrency: 1
  cordon: true
  nodeSelector:
    matchExpressions:
    - key: node-role.kubernetes.io/master
      operator: In
      values:
      - "true"
  serviceAccountName: system-upgrade
  upgrade:
    image: rancher/k3s-upgrade
  version: v1.23.4+k3s1

Agent Plan

# Agent plan
apiVersion: upgrade.cattle.io/v1
kind: Plan
metadata:
  name: agent-plan
  namespace: system-upgrade
spec:
  concurrency: 1
  cordon: true
  nodeSelector:
    matchExpressions:
    - key: node-role.kubernetes.io/master
      operator: DoesNotExist
  prepare:
    args:
    - prepare
    - server-plan
    image: rancher/k3s-upgrade
  serviceAccountName: system-upgrade
  upgrade:
    image: rancher/k3s-upgrade
  version: v1.23.4+k3s1

Troubleshooting

Upgrade for node is stuck

This happens when the workloads for that specific node cannot be terminated on time.

~ Solution ~

Restart and uncordon the node.


Links: HomeLab Example