Perform an Automated Upgrade of a Non-Replicated TimesTenClassic Object

Let's perform an automated upgrade for a non-replicated TimesTenClassic object consisting of three independent TimesTen databases.
  1. Review the TimesTenClassic objects running in your namespace.
    kubectl get ttc

    The output is similar to the following:

    NAME             STATE              ACTIVE        AGE
    mannorepsample   AllReplicasReady   N/A           3h47m
    norepsample      AllReplicasReady   N/A           4d10s
    repsample        Normal             repsample-0   5d23h

    One of the non-replicated TimesTenClassic objects is norepsample. Its high level state is AllReplicasReady, indicating all replicas are ready and available. TimesTen databases are up and running and functioning properly.

  2. Review the image upgrade strategy and rolling update partition values for the object.
    kubectl get ttc norepsample -o yaml | grep 'imageUpgradeStrategy\|rollingUpdatePartition'

    The output is the following:

    imageUpgradeStrategy: Auto
    rollingUpdatePartition: 2

    The image upgrade strategy is Auto (also the default), indicating an automated upgrade strategy. The value for rollingUpdatePartition is 2, indicating that Kubernetes upgrades Pods with an ordinal value greater than or equal to 2. For the norepsample object, since the value of replicas is 3, there are three Pods named norepsample-0, norepsample-1, and norepsample-2. Therefore, Kubernetes only upgrades the norepsample-2 Pod. Let's verify this by performing the upgrade.

  3. On your development host, edit the TimesTenClassic object's .spec.ttspec.image datum with the container image you want to use for the upgrade. This example uses container-registry.oracle.com/timesten/timesten:22.1.1.35.0.
    1. Edit the file, replacing the image value with container-registry.oracle.com/timesten/timesten:22.1.1.35.0.
       kubectl edit ttc norepsample
      
      # Please edit the object below. Lines beginning with a '#' will be ignored,
      # and an empty file will abort the edit. If an error occurs while saving this file will be
      # reopened with the relevant failures.
      #
      apiVersion: timesten.oracle.com/v4
      kind: TimesTenClassic
      ...
          image: container-registry.oracle.com/timesten/timesten:22.1.1.35.0
      ...
    2. Save the file and exit from the editor.
  4. Confirm the StatefulSet contains the new image.
    kubectl describe statefulset norepsample | grep Image

    The output is the following:

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

    When the TimesTen Operator detects that there is an update to the TimesTenClassic's .spec.ttspec.image datum, it modifies the StatefulSet with the new image. Since this is an automated upgrade, the TimesTen Operator takes no further action, but Kubernetes does take action. Kubernetes automatically begins to terminate Pods and replace them with new ones. These new Pods run the new image. Since rollingUpdatePartition is 2, you should expect to see only the norepsample-2 Pod upgraded with the new image.

  5. Monitor the progress.
    kubectl get ttc norepsample

    The output is similar to the following:

    NAME          STATE               ACTIVE   AGE
    norepsample   SomeReplicasReady   N/A      16m

    The object is in the SomeReplicasReady state.

    Wait a few minutes. Then, monitor again.

    kubectl get ttc norepsample

    The output is similar to the following:

    NAME          STATE              ACTIVE   AGE
    norepsample   AllReplicasReady   N/A      19m

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

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

    The output is similar to the following:

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

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

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

      The output is similar to the following:

      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.34.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.34.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.34.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.34.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 norepsample-0 Pod.
      kubectl describe pod norepsample-0 | grep Image

      The output is similar to the following:

      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.34.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.34.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.34.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.34.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.
  8. Edit the TimesTenClassic object's .spec.ttspec.rollingUpdatePartition datum and change the value from 2 to 0.
    1. Edit the file, replacing the rollingUpdatePartition value with 2.
       kubectl edit ttc norepsample
      
      # Please edit the object below. Lines beginning with a '#' will be ignored,
      # and an empty file will abort the edit. If an error occurs while saving this file will be
      # reopened with the relevant failures.
      #
      apiVersion: timesten.oracle.com/v4
      kind: TimesTenClassic
      ...
          rollingUpdatePartition: 0
      ...
    2. Save the file and exit from the editor.

    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 norepsample-1 and norepsample-0 Pods upgraded with the new image.

  9. Monitor the progress.
    1. TimesTenClassic object:
      kubectl get ttc norepsample

      The output is similar to the following

      NAME          STATE               ACTIVE   AGE
      norepsample   SomeReplicasReady   N/A      51m
    2. Pods:
      kubectl get pods

      The output is similar to the following:

      NAME                                 READY   STATUS     RESTARTS   AGE
      ...
      norepsample-0                        3/3     Running    0          53m
      norepsample-1                        0/3     Init:0/1   0          106s
      norepsample-2                        3/3     Running    0          36m

      Kubernetes replaces the norepsample-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
      ...
      norepsample-0                        0/3     Init:0/1   0          46s
      norepsample-1                        3/3     Running    0          3m41s
      norepsample-2                        3/3     Running    0          38m
      

      Kubernetes replaced the norepsample-1 Pod and is in the process of replacing the norepsample-0 Pod.

      Check again.

      kubectl get pods

      The output is similar to the following:

      NAME                                 READY   STATUS    RESTARTS   AGE
      ...
      norepsample-0                        3/3     Running   0          5m59s
      norepsample-1                        3/3     Running   0          8m54s
      norepsample-2                        3/3     Running   0          43m
      

      All Pods are running.

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

    Pod norepsample-1:

    kubectl describe pod norepsample-1 | grep Image

    The output is similar to the following:

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

    Pod norepsample-0:

    kubectl describe pod norepsample-0 | grep Image

    The output is similar to the following:

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

    The Pods are running the new image.

  11. (Optional) Confirm the state of the TimesTenClassic object.
    kubectl get ttc norepsample

    The output is similar to the following:

    NAME          STATE              ACTIVE   AGE
    norepsample   AllReplicasReady   N/A      62m
  12. Verify the databases are running the correct release.
    1. Establish a shell in the -0 Pod.
      kubectl exec -it norepsample-0 -c tt -- /bin/bash
    2. Run the TimesTen ttVersion utility.
      ttVersion
      The output is similar to the following:
      TimesTen Release 22.1.1.35.0 (64 bit Linux/x86_64) (instance1:6624) 2025-01-16T15:16:01Z
        Instance admin: timesten
        Instance home directory: /tt/home/timesten/instances/instance1
        Group owner: timesten
        Daemon home directory: /tt/home/timesten/instances/instance1/info
        PL/SQL enabled.
      
    3. Exit from the shell.
    4. Establish a shell in the -1 Pod.
      kubectl exec -it norepsample-1 -c tt -- /bin/bash
    5. Run the TimesTen ttVersion utility.
      ttVersion
      The output is similar to the following:
      TimesTen Release 22.1.1.35.0 (64 bit Linux/x86_64) (instance1:6624) 2025-01-16T15:16:01Z
        Instance admin: timesten
        Instance home directory: /tt/home/timesten/instances/instance1
        Group owner: timesten
        Daemon home directory: /tt/home/timesten/instances/instance1/info
        PL/SQL enabled.
      
    6. Exit from the shell.
    7. Establish a shell in the -2 Pod.
      kubectl exec -it norepsample-2 -c tt -- /bin/bash
    8. Run the TimesTen ttVersion utility.
      ttVersion
      The output is similar to the following:
      TimesTen Release 22.1.1.35.0 (64 bit Linux/x86_64) (instance1:6624) 2025-01-16T15:16:01Z
        Instance admin: timesten
        Instance home directory: /tt/home/timesten/instances/instance1
        Group owner: timesten
        Daemon home directory: /tt/home/timesten/instances/instance1/info
        PL/SQL enabled.
      
    9. Exit from the shell.
    The TimesTen databases are running the correct release of TimesTen.

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.