Note:

Upgrade the Kubernetes Version on Oracle Cloud Native Environment

Introduction

Best practices recommend upgrading your Kubernetes cluster as soon after a new release as possible. The reasons to upgrade as quickly as possible include:

This tutorial demonstrates how to upgrade the Kubernetes version used on your Oracle CNE cluster.

For more information about Oracle CNE, please refer to the current Release Documentation site.

Objectives

In this tutorial, you’ll learn to:

Prerequisites

Deploy Oracle Cloud Native Environment

Note: If running in your own tenancy, read the linux-virt-labs GitHub project README.md and complete the prerequisites before deploying the lab environment.

  1. Open a terminal on the Luna Desktop.

  2. Clone the linux-virt-labs GitHub project.

    git clone https://github.com/oracle-devrel/linux-virt-labs.git
    
  3. Change into the working directory.

    cd linux-virt-labs/ocne2
    
  4. Install the required collections.

    ansible-galaxy collection install -r requirements.yml
    
  5. Deploy the lab environment.

    ansible-playbook create_instance.yml -e localhost_python_interpreter="/usr/bin/python3.6" -e install_ocne_rpm=true
    

    The free lab environment requires the extra variable local_python_interpreter, which sets ansible_python_interpreter for plays running on localhost. This variable is needed because the environment installs the RPM package for the Oracle Cloud Infrastructure SDK for Python, located under the python3.6 modules.

    The default deployment shape uses the AMD CPU and Oracle Linux 8. To use an Intel CPU or Oracle Linux 9, add -e instance_shape="VM.Standard3.Flex" or -e os_version="9" to the deployment command.

    Important: Wait for the playbook to run successfully and reach the pause task. At this stage of the playbook, the installation of Oracle CNE is complete, and the instances are ready. Take note of the previous play, which prints the public and private IP addresses of the nodes it deploys and any other deployment information needed while running the lab.

Start a Kubernetes Cluster

We’ll use a single control plane and worker node cluster based on Kubernetes v1.30 with plans to upgrade to 1.31.

  1. Open a terminal and connect via SSH to the ocne instance.

    ssh oracle@<ip_address_of_node>
    
  2. Start the cluster.

    ocne cluster start --version 1.30 -n 1 -w 1 -u false
    
  3. Set the kubeconfig environment variable for your new cluster.

    export KUBECONFIG=$(ocne cluster show -C ocne)
    

    Where ocne is the default name for a cluster unless specified. You can then use kubectl get nodes to show the two nodes and verify that they are running version 1.30.

Update Kubernetes

Kubernetes requires you to update one version at a time, so if you need to upgrade more than one version, you’ll need to repeat these steps for each version.

  1. Stage the next Kubernetes version.

    ocne cluster stage -v 1.31
    
  2. Get a list of your cluster nodes.

    kubectl get nodes
    
  3. Check if there are updates available.

    watch ocne cluster info
    

    Monitor until you see nodes with available updates: 2 reported in the output. Enter Ctrl-c to exit the watch command.

  4. Update the control plane node.

    You must first update all control plane nodes within the cluster.

    ocne node update -N ocne-control-plane-1
    

    The update may take a few minutes to complete after the command finishes. You can use kubectl get nodes to check the version of the control plane node.

  5. Update the worker node.

    ocne node update -N ocne-worker-1 --delete-emptydir-data
    

    Repeat the command if you get a warning that an upgrade is unavailable or the cluster cannot perform it. This small cluster may take a few minutes to stabilize before you can update the worker node.

    The worker node requires the --delete-emptydir-data option because the ui Pod uses an emptyDir volume to share content across its running containers.

  6. Verify the version of the cluster nodes.

    kubectl get nodes
    

    Repeat the command until the output shows that each node is at the expected version.

Next Steps

Knowing how to keep the latest Kubernetes version deployed onto your Oracle CNE cluster ensures your cluster remains updated with all the latest security and stability fixes.

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.