Upgrading to a Kubernetes Minor Release

Upgrade an OCI cluster to the next Kubernetes minor release.

For clusters running on OCI, and created using the oci provider, upgrade a Kubernetes cluster to the next minor Kubernetes version when an OCK image becomes available for that version. This uses the Kubernetes Cluster API to scale nodes in and out. To perform an in place upgrade, where nodes aren't reprovisioned, use the steps in Upgrading to a Kubernetes Minor Release.

  1. Set the location of the management cluster.

    The management cluster contains the Kubernetes Cluster API controllers. The management cluster might be the same as the workload cluster. The upgrade is performed using the management cluster.

    Set the kubeconfig file location to the management cluster using an environment variable. For example:

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

    Replace cluster_name with the name of the management cluster.

  2. Set the target Kubernetes version.

    Use ocne cluster stage command to stage the target Kubernetes version. Use the configuration file used to create the workload cluster with this command. The syntax to use is:

    ocne cluster stage 
    [{-c|--config} path] 
    [{-r|--os-registry} registry]
    [{-t|--transport} transport]
    {-v|--version} version

    For more information on the syntax options, see Oracle Cloud Native Environment: CLI.

    For example:

    ocne cluster stage --version 1.31 --config mycluster.yaml

    An OCK image that includes the updated Kubernetes minor version is created, and uploaded to the OCI Object Bucket store, then converted to a custom image.

    The output of this command prints important information. For example, the output might look similar to:

    To update KubeadmControlPlane ocne-control-plane in ocne, run:
        kubectl patch -n ocne kubeadmcontrolplane ocne-control-plane --type=json -p='[{"op":"replace","path":"/spec/version","value":"1.31.5"},{"op":"replace","path":"/spec/machineTemplate/infrastructureRef/name","value":"ocne-control-plane-1"},{"op":"add","path":"/spec/kubeadmConfigSpec/joinConfiguration/patches","value":{"directory":"/etc/ocne/ock/patches"}}]'
    
    To update MachineDeployment ocne-md-0 in ocne, run:
        kubectl patch -n ocne machinedeployment ocne-md-0 --type=json -p='[{"op":"replace","path":"/spec/template/spec/version","value":"1.31.5"},{"op":"replace","path":"/spec/template/spec/infrastructureRef/name","value":"ocne-md-1"}]'
  3. Patch the KubeadmControlPlane for control plane nodes.

    Use the kubectl patch command to update the KubeadmControlPlane. Use the command printed in the output of the ocne cluster stage command. For example:

     kubectl patch -n ocne kubeadmcontrolplane ocne-control-plane --type=json -p='[{"op":"replace","path":"/spec/version","value":"1.31.5"},{"op":"replace","path":"/spec/machineTemplate/infrastructureRef/name","value":"ocne-control-plane-1"},{"op":"add","path":"/spec/kubeadmConfigSpec/joinConfiguration/patches","value":{"directory":"/etc/ocne/ock/patches"}}]'
  4. Wait for the control plane nodes to upgrade.

    The control plane nodes are reprovisioned using the new OCK image, with the new version of Kubernetes. This might take some time.

    Tip:

    Monitor new nodes are being provisioned, and old nodes are being removed, using:

     kubectl --namespace namespace get machine

    Confirm all nodes are updated in the workload cluster. Set the kubeconfig file location to the workload cluster using an environment variable. For example:

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

    Replace cluster_name with the name of the workload cluster.

    List the nodes in the cluster and confirm the VERSION column lists the new Kubernetes version number.

    kubectl get nodes
  5. Update the MachineDeployment for worker nodes.

    Set the kubeconfig file location to the management cluster. For example:

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

    Replace cluster_name with the name of the management cluster.

    Use the kubectl patch command to update the MachineDeployment for worker nodes. Use the command printed in the output of the ocne cluster stage command. For example:

    kubectl patch -n ocne machinedeployment ocne-md-0 --type=json -p='[{"op":"replace","path":"/spec/template/spec/version","value":"1.31.5"},{"op":"replace","path":"/spec/template/spec/infrastructureRef/name","value":"ocne-md-1"}]'
  6. Wait for the worker nodes to update.

    The worker nodes are reprovisioned using the new OCK image, with the new version of Kubernetes. This might take some time.

  7. Confirm Kubernetes has been upgraded.

    Confirm all nodes are updated in the workload cluster. Set the kubeconfig file location to the workload cluster using an environment variable. For example:

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

    Replace cluster_name with the name of the workload cluster.

    List the nodes in the cluster and confirm the VERSION column lists the new Kubernetes version number.

    kubectl get nodes