Upgrade Non-Replicated TimesTen Databases

Let's perform an upgrade of a non-replicated TimesTenClassic object consisting of three independent TimesTen databases.

The upgrade process requires you to perform the following steps:
  • Create a YAML file. In this file, you specify the container image that contains the new release of TimesTen.

  • Use the helm values command for the upgrade. The example shows you how to do this.

In addition, the example shows you how to change the value for the rollingUpdatePartition variable.

  1. On your development host, change to the helm directory that contains the new Helm charts.
    cd new_kube_files/helm
  2. Create a YAML file and in it specify the name of the TimesTen image you want to use for the upgrade.
    vi customyaml/upgradenonreplicated.yaml
    
    image:
      repository: container-registry.oracle.com/timesten/timesten
      tag: "22.1.1.28.0"
  3. Before the upgrade, do the following:
    1. Confirm the non-replicated TimesTenClassic object exists in your namespace.
      kubectl get ttc 
      The output is similar to the following:
      NAME              STATE              ACTIVE            AGE
      norepsamplehelm   AllReplicasReady   N/A               10h
      repsamplehelm     Normal             repsamplehelm-1   13h

      The norepsamplehelm TimesTenClassic object exists and is in the AllReplicasReady state.

    2. Verify the image and the value of rollingUpdatePartition.
      kubectl get ttc norepsamplehelm -o yaml | grep 'image\|rollingUpdatePartition'
      The output is similar to the following:
          image: container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      ...
          rollingUpdatePartition: 2
      ...

      The value for rollingUpdatePartition is 2, indicating that Kubernetes upgrades Pods with an ordinal value greater than or equal to 2. For the norepsamplehelm object, since the value of replicas is 3, there are three Pods named norepsamplehelm-0, norepsamplehelm-1, and norepsamplehelm-2. Therefore, Kubernetes only upgrades the norepsamplehelm-2 Pod.

  4. Confirm the ttclassic chart release.
    helm list
    The output is similar to the following:
    NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION
    norepsamplehelm default         1               2024-08-04 17:42:47.180635098 +0000 UTC deployed        ttclassic-2211270.1.0   22.1.1.27.0
  5. Upgrade to the new release. Use the ttclassic chart from the new release and use the customized YAML file that references the new image.

    Note:

    We recommend the following syntax. This ensures existing customizations are preserved.
    helm get values norepsamplehelm --all > prev-values-norepttc.yaml
    helm upgrade -f prev-values-norepttc.yaml -f customyaml/upgradenonreplicated.yaml  norepsamplehelm ./ttclassic
    Let's look at this helm upgrade command:
    • The get values norepsamplehelm Helm command retrieves the values for the current release, including existing customizations. The result of this command is piped into the prev-values-norepttc.yaml file. You can choose any name for this file.

    • The helm upgrade command uses the prev-values-norepttc.yaml file with the customized upgradenonreplicated.yaml file to do the upgrade.

    Let's look at the output from the helm upgrade command.

    Release "norepsamplehelm" has been upgraded. Happy Helming!
    NAME: norepsamplehelm
    LAST DEPLOYED: Mon Aug  5 04:22:15 2024
    NAMESPACE: default
    STATUS: deployed
    REVISION: 2
    NOTES:
    Version 2211280.1.0 of the ttclassic chart has been installed.
    
    This release is named "norepsamplehelm".
    
    To learn more about the release, try:
    
      $ helm status norepsamplehelm
      $ helm get all norepsamplehelm
      $ helm history norepsamplehelm
    
    To rollback to a previous version of the chart, run:
    
      $ helm rollback norepsamplehelm <REVISION>
        - run 'helm history norepsamplehelm' for a list of revisions.
    Note the following:
    • The norepsamplehelm chart release is upgraded. The release revision is 2.

    • The status of the release is deployed.

    • The ttclassic chart version is 2211280.1.0 corresponding to TimesTen release 22.1.1.28.0.

  6. Monitor the progress.
    kubectl get ttc norepsamplehelm

    The output is similar to the following:

    NAME              STATE               ACTIVE            AGE
    norepsamplehelm   SomeReplicasReady   N/A               10h
    

    The object is in the SomeReplicasReady state.

    Wait a few minutes. Then, monitor again.

    kubectl get ttc norepsamplehelm

    The output is similar to the following:

    NAME              STATE              ACTIVE            AGE
    norepsamplehelm   AllReplicasReady   N/A               10h

    The object is in the AllReplicasReady state. All replicas are ready and available. TimesTen databases are up and running and functioning properly.

  7. Check the image that the norepsamplehelm-2 Pod is running.
    kubectl describe pod norepsamplehelm-2 | grep Image

    The output is similar to the following:

    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0

    The containers in the Pod are running the new container image.

  8. Check the image for the norepsamplehelm-1 and norepsamplehelm-0 Pods.
    1. Check the norepsamplehelm-1 Pod.
      kubectl describe pod norepsamplehelm-1 | grep Image

      The output is similar to the following:

      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0

      The containers in the Pod are not running the new image. Due to the rollingUpdatePartition value of 2, Kubernetes does not upgrade this Pod with the new image. This is correct behavior.

    2. Check the norepsamplehelm-0 Pod.
      kubectl describe pod norepsamplehelm-0 | grep Image

      The output is similar to the following:

      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0

      The containers in the Pod are not running the new image. Due to the rollingUpdatePartition value of 2, Kubernetes does not upgrade this Pod with the new image. This is correct behavior.

    After you confirm the upgrade is working, you can upgrade the remaining Pods.
  9. Create a YAML file and in it specify the rollingUpdatePartition variable and set the value to 0.
    vi customyaml/changerollingupdate.yaml
    
    rollingUpdatePartition: 0
  10. Change the rollingUpdatePartition value.

    Note:

    We recommend the following syntax. This ensures existing customizations are preserved.
    helm get values norepsamplehelm --all > prev-values-noreprolling.yaml && helm upgrade -f prev-values-noreprolling.yaml -f customyaml/changerollingupdate.yaml  norepsamplehelm ./ttclassic
    The output is similar to the following:
    Release "norepsamplehelm" has been upgraded. Happy Helming!
    NAME: norepsamplehelm
    LAST DEPLOYED: Mon Aug  5 04:56:32 2024
    NAMESPACE: default
    STATUS: deployed
    REVISION: 3
    NOTES:
    Version 2211280.1.0 of the ttclassic chart has been installed.
    
    This release is named "norepsamplehelm".
    
    To learn more about the release, try:
    
      $ helm status norepsamplehelm
      $ helm get all norepsamplehelm
      $ helm history norepsamplehelm
    
    To rollback to a previous version of the chart, run:
    
      $ helm rollback norepsamplehelm <REVISION>
        - run 'helm history norepsamplehelm' for a list of revisions.

    Kubernetes automatically begins to terminate Pods and replace them with new ones. These new Pods run the new image. Since rollingUpdatePartition is now 0, you should expect to see the norepsamplehelm-1 and norepsamplehelm-0 Pods upgraded with the new image.

  11. Monitor the progress.
    1. TimesTenClassic object:
      kubectl get ttc norepsamplehelm

      The output is similar to the following

      NAME              STATE               ACTIVE   AGE
      norepsamplehelm   SomeReplicasReady   N/A      11h
    2. Pods:
      kubectl get pods

      The output is similar to the following:

      NAME                                 READY   STATUS     RESTARTS   AGE
      norepsamplehelm-0                    3/3     Running    0          11h
      norepsamplehelm-1                    0/3     Init:0/1   0          31s
      norepsamplehelm-2                    3/3     Running    0          34m

      Kubernetes replaces the norepsamplehelm-1 Pod first. Wait a few minutes. Then monitor again.

      kubectl get pods

      The output is similar to the following:

      NAME                                 READY   STATUS    RESTARTS   AGE
      norepsamplehelm-0                    3/3     Running   0          3m14s
      norepsamplehelm-1                    3/3     Running   0          6m8s
      norepsamplehelm-2                    3/3     Running   0          40m

      Kubernetes replaced the norepsamplehelm-1 and the norepsamplehelm-0 Pods. All Pods are running.

  12. Confirm the Pods are running the new container image.

    Pod norepsamplehelm-1:

    kubectl describe pod norepsamplehelm-1 | grep Image

    The output is similar to the following:

    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0

    Pod norepsamplehelm-0:

    kubectl describe pod norepsamplehelm-0 | grep Image

    The output is similar to the following:

    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0

    The Pods are running the new image.

  13. Confirm the state of the TimesTenClassic object.
    kubectl get ttc norepsamplehelm

    The output is similar to the following:

    NAME              STATE              ACTIVE   AGE
    norepsamplehelm   AllReplicasReady   N/A      11h

Congratulations! You successfully performed an automated upgrade for a non-replicated TimesTenClassic object. All replicas are ready and available. Pods are running the new TimesTen container image. TimesTen databases are upgraded and fully operational.