跳转至

Cluster Version Upgrade

This section will introduce how to upgrade the Kubernetes version of a cluster using kubean. The kubean/example/upgrade directory that you cloned locally provides a sample template for cluster version upgrades:

The main configuration files and their purposes in the upgrade directory are as follows:
    upgrade
    ├── ClusterOperation.yml                  # Upgrade cluster tasks
    └── VarsConfCM.yml                        # Configuration parameters for cluster version upgrades

To demonstrate the process of upgrading a cluster version, we will use the example of a single node cluster deployed using the all-in-one mode.

Note: that before upgrading the cluster version, you must have completed the deployment of a cluster using kubean.

1. Add an upgrade task

Go to the kubean/examples/upgrade/ directory and edit the ClusterOperation.yml template. Replace the following parameters with your actual parameters:

The template for ClusterOperation.yml in the kubean/examples/upgrade/ directory is as follows:

apiVersion: kubean.io/v1alpha1
kind: ClusterOperation
metadata:
  name: cluster-mini-upgrade-ops
spec:
  cluster: cluster-mini
  image: ghcr.m.daocloud.io/kubean-io/spray-job:<TAG> # Please replace <TAG> with the specified version, such as v0.4.9
  actionType: playbook
  action: upgrade-cluster.yml
Important Parameters:

  • spec.cluster: Specifies the name of the cluster to be upgraded. In the above example, the cluster named cluster-mini is the upgrade target.
  • spec.action: Specifies the kubespray playbook related to the upgrade. Here it is set to upgrade-cluster.yml.

2. Specify the upgraded version of the cluster

Go to the kubean/examples/upgrade/ directory and edit the VarsConfCM.yml template. Specify the version of the cluster upgrade by configuring the kube_version parameter.

The template for VarsConfCM.yml in the kubean/examples/upgrade/ directory is as follows:

apiVersion: v1
kind: ConfigMap
metadata:
  name: mini-vars-conf
  namespace: kubean-system
data:
  group_vars.yml: |
    kube_version: v1.25.8
    # upgrade_cluster_setup: true
    # upgrade_node_confirm: true
    # upgrade_node_pause_seconds: 60

    container_manager: containerd
    kube_network_plugin: calico
    etcd_deployment_type: kubeadm
Important Parameters:

  • kube_version: Specifies the version of the cluster to be upgraded. In the above example, it is set to upgrade to k8s v1.25.8.

Example

apiVersion: v1
kind: ConfigMap
metadata:
  name: mini-vars-conf
  namespace: kubean-system
data:
  group_vars.yml: |
    kube_version: v1.25.0
    # upgrade_cluster_setup: true
    # upgrade_node_confirm: true
    # upgrade_node_pause_seconds: 60

    container_manager: containerd
    kube_network_plugin: calico
    etcd_deployment_type: kubeadm
apiVersion: v1
kind: ConfigMap
metadata:
  name: mini-vars-conf
  namespace: kubean-system
data:
  group_vars.yml: |
    kube_version: v1.25.8
    # upgrade_cluster_setup: true
    # upgrade_node_confirm: true
    # upgrade_node_pause_seconds: 60

    container_manager: containerd
    kube_network_plugin: calico
    etcd_deployment_type: kubeadm

Bonus: kubean cluster version support mechanism:

kubean Version Recommended Kubernetes Version Supported Kubernetes Version Range
v0.5.2 v1.25.4 - "v1.27.2"
- "v1.26.5"
- "v1.26.4"
- "v1.26.3"
- "v1.26.2"
- "v1.26.1"
- "v1.26.0"
- "v1.25.10"
- "v1.25.9"
- "v1.25.8"
- "v1.25.7"
- "v1.25.6"
- "v1.25.5"
- "v1.25.4"
- "v1.25.3"
- "v1.25.2"
- "v1.25.1"
- "v1.25.0"

For more detailed information about upgrading parameters, please refer to the kubespray documentation:Updating Kubernetes with Kubespray.

3.Apply all configurations under the upgrade directory

After completing the above steps andsaving the ClusterOperation.yml and VarsConfCM.yml files, run the following command:

$ kubectl apply -f examples/upgrade/

With this, you have completed the upgrade of the Kubernetes version for a cluster.