Modify the Number of Replicas in Non-Replicated Environments

There may be situations where you want to increase or decrease the number of databases in your non-replicated environment. For example, you may want to increase the resources during a peak holiday buying season and then reduce the resources later. You can accomplish this by modifying the number of replicas for a TimesTenClassic object.

When you increase the number of replicas, Kubernetes provisions TimesTen in the new Pods.

When you decrease the number of replicas:
  • Kubernetes deletes the relevant Pods.

  • The TimesTen Operator does not delete the PVCs.

Let's walk through an example. In this example, a TimesTenClassic object is deployed in your namespace. The number of replicas is 3. The example shows you how to decrease the number of replicas to 1 and then increase the number of replicas back to 3.

  1. Confirm there is a TimesTenClassic object deployed in your namespace.
    kubectl get ttc

    The output is similar to the following:

    NAME          STATE              ACTIVE   AGE
    norepsample   AllReplicasReady   N/A      17m

    The norepsample TimesTenClassic object is deployed and is in the AllReplicasReady state. All replicas are available and running and the databases are functioning properly.

  2. Confirm the number of replicas.
    kubectl describe ttc norepsample | grep 'Replicas'

    The output is similar to the following:

        Replicas:                   3

    The number of replicas is 3.

  3. Confirm the number of Pods.
    kubectl get pods

    The output is similar to the following

    NAME                                 READY   STATUS    RESTARTS   AGE
    norepsample-0                        3/3     Running   0          18m
    norepsample-1                        3/3     Running   0          18m
    norepsample-2                        3/3     Running   0          18m
    ...

    There are three Pods running, corresponding to the number of replicas. Each replica contains a TimesTen database.

  4. Insert data into databases.
    1. Database running in the norepsample-0 Pod:
      kubectl exec -it norepsample-0 -c tt -- /bin/bash
      [timesten@norepsample-0 ~]$ ttIsql norepsample
      
      Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
      Type ? or "help" for help, type "exit" to quit ttIsql.
      
      
      
      connect "DSN=norepsample";
      Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1;
      (Default setting AutoCommit=1)
      Command> CREATE TABLE testdata (col1 TT_INTEGER);
      Command> INSERT INTO testdata values (0);
      1 row inserted.
      Command> SELECT * FROM testdata;
      < 0 >
      1 row found.
      Command> exit
      Disconnecting...
      Done.
      [timesten@norepsample-0 ~]$ exit
      exit

      There is one row in the testdata table and the value for col1 is 0.

    2. Database running in the norepsample-1 Pod:
      kubectl exec -it norepsample-1 -c tt -- /bin/bash
      [timesten@norepsample-0 ~]$ ttIsql norepsample
      
      Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
      Type ? or "help" for help, type "exit" to quit ttIsql.
      
      
      
      connect "DSN=norepsample";
      Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1;
      (Default setting AutoCommit=1)
      Command> CREATE TABLE testdata (col1 TT_INTEGER);
      Command> INSERT INTO testdata values (1);
      1 row inserted.
      Command> SELECT * FROM testdata;
      < 1 >
      1 row found.
      Command> exit
      Disconnecting...
      Done.
      [timesten@norepsample-1 ~]$ exit
      exit

      There is one row in the testdata table and the value for col1 is 1.

    3. Database running in the norepsample-2 Pod:
      kubectl exec -it norepsample-2 -c tt -- /bin/bash
      [timesten@norepsample-0 ~]$ ttIsql norepsample
      
      Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
      Type ? or "help" for help, type "exit" to quit ttIsql.
      
      
      
      connect "DSN=norepsample";
      Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1;
      (Default setting AutoCommit=1)
      Command> CREATE TABLE testdata (col1 TT_INTEGER);
      Command> INSERT INTO testdata values (2);
      1 row inserted.
      Command> SELECT * FROM testdata;
      < 2 >
      1 row found.
      Command> exit
      Disconnecting...
      Done.
      [timesten@norepsample-2 ~]$ exit
      exit

      There is one row in the testdata table and the value for col1 is 2.

  5. Decrease the number of replicas.
    1. Edit the norepsample TimesTenClassic object, changing replicas to 1.
      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
      ...
      spec:
        ttspec:
      ...
          replicas: 1
      ...
    2. Save your edit.
      The output is similar to the following:
      timestenclassic.timesten.oracle.com/norepsample edited
  6. Verify the TimesTenClassic object is in the AllReplicasReady state.
    kubectl get ttc

    The output is similar to the following:

    NAME          STATE              ACTIVE   AGE
    norepsample   AllReplicasReady   N/A      63m
  7. Confirm the number of Pods.
    kubectl get pods

    The output is similar to the following:

    NAME                                 READY   STATUS    RESTARTS   AGE
    norepsample-0                        3/3     Running   0          65m
    ...

    There is one Pod. One TimesTen database is running in the Pod.

  8. Confirm the number of PVCs.
    kubectl get pvc

    The output is similar to the following:

    
    NAME                          STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    tt-persistent-norepsample-0   Bound    csi-836f3962-cbfa-4f7d-9271-6393167b00bd   50Gi       RWO            oci-bv         67m
    tt-persistent-norepsample-1   Bound    csi-b2bfa486-6d09-463f-a8a3-25a760d1449d   50Gi       RWO            oci-bv         67m
    tt-persistent-norepsample-2   Bound    csi-820a206b-1662-4c24-821c-a947572b618a   50Gi       RWO            oci-bv         67m
    

    There are three PVCs. When you modify the number of replicas, the TimesTen Operator does not delete the PVCs associated with a TimesTenClassic object.

  9. Increase the number of replicas.
    1. Edit the norepsample TimesTenClassic object, changing replicas to 3.
      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
      ...
      spec:
        ttspec:
      ...
          replicas: 3
      ...
    2. Save your edit.
      The output is similar to the following:
      timestenclassic.timesten.oracle.com/norepsample edited
  10. Verify the TimesTenClassic object is in the AllReplicasReady state.
    kubectl get ttc

    The output is similar to the following:

    NAME          STATE              ACTIVE   AGE
    norepsample   AllReplicasReady   N/A      76m
  11. Confirm the number of Pods.
    kubectl get pods

    The output is similar to the following:

    NAME                                 READY   STATUS    RESTARTS   AGE
    norepsample-0                        3/3     Running   0          77m
    norepsample-1                        3/3     Running   0          4m
    norepsample-2                        3/3     Running   0          4m

    There are three Pods. Each Pod is running a TimesTen database.

  12. Confirm the number of PVCs.
    kubectl get pvc

    The output is similar to the following:

    NAME                          STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    tt-persistent-norepsample-0   Bound    csi-836f3962-cbfa-4f7d-9271-6393167b00bd   50Gi       RWO            oci-bv         79m
    tt-persistent-norepsample-1   Bound    csi-b2bfa486-6d09-463f-a8a3-25a760d1449d   50Gi       RWO            oci-bv         79m
    tt-persistent-norepsample-2   Bound    csi-820a206b-1662-4c24-821c-a947572b618a   50Gi       RWO            oci-bv         79m

    There are three PVCs associated with the three TimesTen databases.

  13. Verify the data in the databases.
    1. Database running in the norepsample-0 Pod:
      kubectl exec -it norepsample-0 -c tt -- /bin/bash
      [timesten@norepsample-0 ~]$ ttIsql norepsample
      
      Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
      Type ? or "help" for help, type "exit" to quit ttIsql.
      
      
      
      connect "DSN=norepsample";
      Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1;
      (Default setting AutoCommit=1)
      Command> tables;
        TIMESTEN.TESTDATA
      1 table found.
      Command> SELECT * FROM testdata;
      < 0 >
      1 row found.
      

      Since this Pod was not deleted when you decreased the number of replicas, the data in the database has not changed.

    2. Database running in the norepsample-1 Pod:
      kubectl exec -it norepsample-1 -c tt -- /bin/bash
      [timesten@norepsample-1 ~]$ ttIsql norepsample
      
      Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
      Type ? or "help" for help, type "exit" to quit ttIsql.
      
      
      
      connect "DSN=norepsample";
      Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1;
      (Default setting AutoCommit=1)
      Command> tables;
      0 tables found.
      Command> exit
      Disconnecting...
      Done.
      [timesten@norepsample-1 ~]$ exit
      exit

      The TimesTen Operator correctly provisions TimesTen in the norepsample-1 Pod and has correctly overwritten the original database.

    3. Database running in the norepsample-2 Pod:
      kubectl exec -it norepsample-2 -c tt -- /bin/bash
      [timesten@norepsample-2 ~]$ ttIsql norepsample
      
      Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
      Type ? or "help" for help, type "exit" to quit ttIsql.
      
      
      
      connect "DSN=norepsample";
      Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1;
      (Default setting AutoCommit=1)
      Command> tables;
      0 tables found.
      Command> exit
      Disconnecting...
      Done.
      [timesten@norepsample-2 ~]$ exit
      exit

      The TimesTen Operator correctly provisions TimesTen in the norepsample-2 Pod and has correctly overwritten the original database.

Congratulations! You successfully modified the number of replicas for a TimesTenClassic object in a non-replicated environment.