Perform an Automated Upgrade

The .spec.ttspec.imageUpgradeStrategy datum of a TimesTenClassic object determines the upgrade strategy. You can use the kubectl get ttc -o yaml command to determine the value of this datum for any TimesTenClassic object. For example, let's assume there is a sample TimesTenClassic object in our namespace. Let's review the setting for the .spec.ttspec.imageUpgradeStrategy datum for sample.

kubectl get ttc sample -o yaml

The output is similar to the following. Note: Not all output is shown.

apiVersion: timesten.oracle.com/v1
kind: TimesTenClassic
metadata:
    ...
  name: sample
  namespace: mynamespace
  resourceVersion: "74826407"
  uid: 76038b9b-4635-4974-88cf-385739499ec4
spec:
  ...
  ttspec:
    additionalMemoryRequest: 1Gi
    automaticMemoryRequests: true
    daemonLogCPURequest: 200m
    daemonLogMemoryRequest: 20Mi
    dbConfigMap:
    - sample
    exporterCPURequest: 200m
    exporterMemoryRequest: 200Mi
    ...
    imageUpgradeStrategy: Auto
    memoryWarningPercent: 90
...

The value for .spec.ttspec.imageUpgradeStrategy is Auto.

Let's walk through the steps for an automated upgrade.

Note:

Recall that when you do an automated upgrade, your databases are taken down, restarted, and failed over immediately. Do not perform this procedure at the busiest time of your production day. Applications see short outages and perhaps reduced performance as a result of the upgrade procedure.

Modify a TimesTenClassic Object: Automated Upgrade

The automated upgrade process requires you to modify the .spec.ttspec.image datum of a TimesTenClassic object to reference the new TimesTen container image. After you modify the TimesTenClassic object to reference the new TimesTen image, the Operator notices the change and modifies the StatefulSet that it created. The Operator then starts the upgrade process. You can use the kubectl describe command to monitor this upgrade process.

  1. On your development host, edit the sample TimesTenClassic object, changing the .spec.ttspec.image datum to reference the new TimesTen container image. In this example, the location and name of the new container image is container-registry.oracle.com/timesten/timesten:22.1.1.19.0.

    Note: Not all output is shown.

    kubectl edit timestenclassic sample
    
    # 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/v1
    kind: TimesTenClassic
    metadata:
      ...
      name: sample
      namespace: mynamespace
      resourceVersion: "74909603"
      uid: 76038b9b-4635-4974-88cf-385739499ec4
    spec:
    ...
      ttspec:
        additionalMemoryRequest: 1Gi
        automaticMemoryRequests: true
        daemonLogCPURequest: 200m
        daemonLogMemoryRequest: 20Mi
        dbConfigMap:
        - sample
        exporterCPURequest: 200m
        exporterMemoryRequest: 200Mi
        image: container-registry.oracle.com/timesten/timesten:22.1.1.19.0
        imagePullPolicy: Always
        imagePullSecret: sekret
        imageUpgradeStrategy: Auto
        memoryWarningPercent: 90
        storageClassName: oci-bv
        storageSize: 250G
    The output is the following.
    timestenclassic.timesten.oracle.com/sample edited
  2. Verify that the Operator has modified the sample StatefulSet and replaced the image with the new image.
    kubectl describe statefulset sample

    The output is similar to the following.

    Name:               sample
    Namespace:          mynamespace
    ...
    Replicas:           2 desired | 2 total
    Update Strategy:    OnDelete
    Pods Status:        1 Running / 1 Waiting / 0 Succeeded / 0 Failed
    Pod Template:
      Labels:       app=sample
                    database.timesten.oracle.com=sample
      Annotations:  TTC: 76038b9b-4635-4974-88cf-385739499ec4
      Init Containers:
       ttinit:
        Image:       container-registry.oracle.com/timesten/timesten:22.1.1.19.0
        Ports:       8443/TCP, 6624/TCP, 6625/TCP, 4444/TCP
        Host Ports:  0/TCP, 0/TCP, 0/TCP, 0/TCP
        Environment:
          TT_OPERATOR_MANAGED:      1
          TIMESTEN_HOME:            /tt/home/timesten/instances/instance1
          LD_LIBRARY_PATH:          /tt/home/timesten/instances/instance1/ttclasses/lib:/tt/home/timesten/instances/instance1/install/lib:/tt/home/timesten/instances/instance1/install/ttoracle_home/instantclient_11_2:/tt/home/timesten/instances/instance1/install/ttoracle_home/instantclient
          TT_REPLICATION_TOPOLOGY:  activeStandbyPair
          TT_INIT_CONTAINER:        1
          TTC_UID:                  76038b9b-4635-4974-88cf-385739499ec4
        Mounts:
          /tt from tt-persistent (rw)
          /ttagent from tt-agent (rw)
          /ttconfig from tt-config (rw)
      Containers:
       tt:
        Image:       container-registry.oracle.com/timesten/timesten:22.1.1.19.0
        Ports:       8443/TCP, 6624/TCP, 6625/TCP, 4444/TCP
        Host Ports:  0/TCP, 0/TCP, 0/TCP, 0/TCP
        Environment:
          TT_OPERATOR_MANAGED:      1
          TIMESTEN_HOME:            /tt/home/timesten/instances/instance1
          LD_LIBRARY_PATH:          /tt/home/timesten/instances/instance1/ttclasses/lib:/tt/home/timesten/instances/instance1/install/lib:/tt/home/timesten/instances/instance1/install/ttoracle_home/instantclient_11_2:/tt/home/timesten/instances/instance1/install/ttoracle_home/instantclient
          TT_REPLICATION_TOPOLOGY:  activeStandbyPair
        Mounts:
          /tt from tt-persistent (rw)
          /ttagent from tt-agent (rw)
          /ttconfig from tt-config (rw)
       daemonlog:
        Image:      container-registry.oracle.com/timesten/timesten:22.1.1.19.0
        Port:       <none>
        Host Port:  <none>
        Command:
          sh
          -c
          /bin/bash <<'EOF'
          while [ 1 ] ; do tail --follow=name /tt/home/timesten/instances/instance1/diag/ttmesg.log --max-unchanged-stats=5; sleep 1; done
          exit 0
          EOF
        Requests:
          cpu:     100m
          memory:  20Mi
        Environment:
          TIMESTEN_HOME:        /tt/home/timesten/instances/instance1
          TT_OPERATOR_MANAGED:  1
          LD_LIBRARY_PATH:      /tt/home/timesten/instances/instance1/ttclasses/lib:/tt/home/timesten/instances/instance1/install/lib:/tt/home/timesten/instances/instance1/install/ttoracle_home/instantclient_11_2:/tt/home/timesten/instances/instance1/install/ttoracle_home/instantclient
        Mounts:
          /tt from tt-persistent (rw)
      Volumes:
       tt-agent:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  tt76038b9b-4635-4974-88cf-385739499ec4
        Optional:    false
       tt-config:
        Type:               Projected (a volume that contains injected data from multiple sources)
        ConfigMapName:      sample
        ConfigMapOptional:  <nil>
    Volume Claims:
      Name:          tt-persistent
      StorageClass:  oci-bv
      Labels:        <none>
      Annotations:   <none>
      Capacity:      50G
      Access Modes:  [ReadWriteOnce]
    Events:
      Type    Reason            Age                From                    Message
      ----    ------            ----               ----                    -------
      Normal  SuccessfulCreate  22s (x2 over 18h)  statefulset-controller  create Pod sample-1 in StatefulSet sample successful
    

You have modified the sample TimesTenClassic object to use the new TimesTen container image. You are now ready to monitor the automated upgrade process performed by the Operator.

Monitor an Automated Upgrade

You can monitor the automated upgrade process performed by the Operator. These steps are optional.

  1. Use the kubectl get command to assess the state of the sample TimesTenClassic object.
    kubectl get ttc sample

    Note that the initial state is StandbyDown.

    NAME     STATE         ACTIVE     AGE
    sample   StandbyDown   sample-0   18h
    

    Wait a few minutes, then run the command again.

    kubectl get ttc sample

    Note that the state has changed to Normal.

    NAME     STATE    ACTIVE     AGE
    sample   Normal   sample-1   18h

    The Operator promoted sample-1 to be the active.

  2. Use the kubectl describe command to observe how the Operator promoted the standby database (sample-1) to be the active.
    kubectl describe ttc sample

    The output is similar to the following.

    Name:         sample
    Namespace:    mynamespace
    
    Kind:         TimesTenClassic
    Metadata:
        ...
    Spec:
      ...
      Ttspec:
        Additional Memory Request:  1Gi
        Automatic Memory Requests:  true
        Daemon Log CPU Request:     200m
        Daemon Log Memory Request:  20Mi
        Db Config Map:
          sample
        Exporter CPU Request:     200m
        Exporter Memory Request:  200Mi
        Image:                    container-registry.oracle.com/timesten/timesten:22.1.1.19.0
        Image Pull Policy:        Always
        Image Pull Secret:        sekret
        Image Upgrade Strategy:   Auto
        Memory Warning Percent:   90
        Storage Class Name:       oci-bv
        Storage Size:             250G
    Status:
      ...
      Pod Status:
        Active:           false
        Admin User File:  true
        Cache Status:
          Cache Agent:        Not Running
          Cache UID Pwd Set:  true
          N Cache Groups:     0
        Cache User File:      false
        Cg File:              false
        Db Status:
          Db:  Loaded
          ...
        Disable Return:                                       false
        Has Been Seen:                                        true
        High Level State:                                     Healthy
        Initialized:                                          true
        Intended State:                                       Standby
        Last High Level State Switch:                         1673208466
        Local Commit:                                         false
        Name:                                                 sample-0
        Pod Status:
          Agent:                Up
          Last Time Reachable:  1673208466
          Pod IP:               192.0.2.1 
          Pod Phase:            Running
        Prev Active:            false
        Prev High Level State:  Healthy
        Prev Image:             container-registry.oracle.com/timesten/timesten:22.1.1.9.0
        Prev Intended State:    Active
        Prev Ready:             true
        Ready:                  true
        Replication Status:
          Last Time Rep State Changed:  1673208234
          Rep Agent:                    Running
          Rep Peer P State:             start
          Rep Scheme:                   Exists
          Rep State:                    STANDBY
        Scaleout Status:
          Instance Type:  classic
        Schema File:      true
        Timesten Status:
          Daemon:         Up
          Instance:       Exists
          Release:        22.1.1.19.0
        Tt Pod Type:      Database
        Using Twosafe:    false
        Active:           true
        Admin User File:  true
        Cache Status:
          Cache Agent:        Not Running
          Cache UID Pwd Set:  true
          N Cache Groups:     0
        Cache User File:      false
        Cg File:              false
        Db Status:
          Db:  Loaded
          ...
        Name:                   sample-1
        Pod Status:
          Agent:                Up
          Last Time Reachable:  1673208466
          Pod IP:               192.0.2.2
          Pod Phase:            Running
        Prev Active:            true
        Prev High Level State:  Healthy
        Prev Image:             container-registry.oracle.com/timesten/timesten:22.1.1.9.0
        Prev Intended State:    Standby
        Prev Ready:             true
        Ready:                  true
        Replication Status:
          Last Time Rep State Changed:  1673208191
          Rep Agent:                    Running
          Rep Peer P State:             start
          Rep Scheme:                   Exists
          Rep State:                    ACTIVE
        Scaleout Status:
          Instance Type:  classic
        Schema File:      true
        Timesten Status:
          Daemon:             Up
          Instance:           Exists
          Release:            22.1.1.19.0
        Tt Pod Type:          Database
        Using Twosafe:        false
      Prev High Level State:  StandbyDown
      Prev Reexamine:
      Prev Stop Managing:
      Rep Create Statement:   create active standby pair "sample" on "sample-0.sample.mynamespace.svc.cluster.local", "sample" on "sample-1.sample.mynamespace.svc.cluster.local" NO RETURN store "sample" on "sample-0.sample.mynamespace.svc.cluster.local" PORT 4444 FAILTHRESHOLD 0 store "sample" on "sample-1.sample.mynamespace.svc.cluster.local" PORT 4444 FAILTHRESHOLD 0
      Rep Port:               4444
      Rep Start Fail Count:   0
      Standby Cache Agent:    Not Running
      Standby Down Standby AS:
        Async Id:           5f083b21-20a9-4b93-93bf-8a42a160a0bc
        Destroy Db:         true
        Id:                 8bd89bbd-fb69-4249-822d-4dd729443e4b
        Pod Name:           sample-0
        Rep Duplicate:      true
        Start Rep Agent:    true
        Status:             complete
      Standby Perm In Use:  17134
      Standby Perm Size:    200
      Standby Rep Agent:    Running
      Status Version:       1.0
      Using Twosafe:        false
    Events:
      Type     Reason       Age    From      Message
      ----     ------       ----   ----      -------
      Normal   Upgrade      6m41s  timesten  Image updated, automatic upgrade started
      Normal   Upgrade      6m41s  timesten  Deleted standby pod sample-1 during upgrade
      Normal   Info         6m29s  timesten  Pod sample-1 Agent Down
      Normal   StateChange  6m29s  timesten  Pod sample-1 is Not Ready
      Warning  StateChange  6m29s  timesten  TimesTenClassic was Normal, now ActiveTakeover
      Normal   StateChange  6m23s  timesten  TimesTenClassic was ActiveTakeover, now StandbyDown
      Normal   Info         5m4s   timesten  Pod sample-1 Agent Up
      Normal   Info         5m4s   timesten  Pod sample-1 Instance Exists
      Normal   Info         5m4s   timesten  Pod sample-1 Daemon Down
      Normal   Info         5m3s   timesten  Pod sample-1 Daemon Up
      Normal   Info         5m3s   timesten  Pod sample-1 Database Unloaded
      Normal   Info         5m1s   timesten  Pod sample-1 Database None
      Normal   StateChange  4m46s  timesten  Pod sample-1 RepState IDLE
      Normal   Info         4m46s  timesten  Pod sample-1 Database Loaded
      Normal   Info         4m46s  timesten  Pod sample-1 RepScheme Exists
      Normal   Info         4m46s  timesten  Pod sample-1 RepAgent Not Running
      Normal   Info         4m40s  timesten  Pod sample-1 RepAgent Running
      Normal   StateChange  4m40s  timesten  TimesTenClassic was StandbyDown, now StandbyStarting
      Normal   StateChange  4m40s  timesten  TimesTenClassic was StandbyStarting, now StandbyCatchup
      Normal   StateChange  4m35s  timesten  Pod sample-1 RepState STANDBY
      Normal   StateChange  4m34s  timesten  TimesTenClassic was StandbyCatchup, now Normal
      Normal   Upgrade      4m3s   timesten  Deleted active pod sample-0 during upgrade
      Normal   Info         3m52s  timesten  Pod sample-0 Agent Down
      Normal   StateChange  3m52s  timesten  Pod sample-0 is Not Ready
      Normal   StateChange  3m52s  timesten  Pod sample-0 is Not Active Ready
      Warning  StateChange  3m52s  timesten  TimesTenClassic was Normal, now ActiveDown
      Normal   StateChange  3m52s  timesten  Pod sample-1 is Ready
      Normal   Info         3m50s  timesten  Pod sample-1 Database Updatable
      Normal   StateChange  3m50s  timesten  Pod sample-1 RepState ACTIVE
      Normal   StateChange  3m50s  timesten  Pod sample-1 is Not Ready
      Normal   StateChange  3m50s  timesten  TimesTenClassic was ActiveDown, now ActiveTakeover
      Normal   StateChange  3m45s  timesten  Pod sample-1 is Ready
      Normal   StateChange  3m45s  timesten  Pod sample-1 is Active Ready
      Normal   StateChange  3m45s  timesten  TimesTenClassic was ActiveTakeover, now StandbyDown
      Normal   Info         3m1s   timesten  Pod sample-0 Agent Up
      Normal   Info         3m1s   timesten  Pod sample-0 Instance Exists
      Normal   Info         3m1s   timesten  Pod sample-0 Daemon Down
      Normal   Info         3m1s   timesten  Pod sample-0 Daemon Up
      Normal   Info         3m1s   timesten  Pod sample-0 Database Unloaded
      Normal   Info         2m58s  timesten  Pod sample-0 Database None
      Normal   Info         2m43s  timesten  Pod sample-0 Database Loaded
      Normal   Info         2m43s  timesten  Pod sample-0 RepAgent Not Running
      Normal   Info         2m43s  timesten  Pod sample-0 RepScheme Exists
      Normal   StateChange  2m43s  timesten  Pod sample-0 RepState IDLE
      Normal   Info         2m37s  timesten  Pod sample-0 RepAgent Running
      Normal   StateChange  2m37s  timesten  Pod sample-0 RepState STANDBY
      Normal   StateChange  2m37s  timesten  Pod sample-0 is Ready
      Normal   Upgrade      2m37s  timesten  Upgrade of active complete
      Normal   Upgrade      2m37s  timesten  Upgrade completed in 244 secs
      Normal   StateChange  2m37s  timesten  TimesTenClassic was StandbyDown, now Normal
    

The automated upgrade is successful. The active and standby Pods are running the new TimesTen image, which contains the new TimesTen release.