Approach 1: Use Specific Datum for Requests and Limits

In this approach, the TimesTen Operator automatically determines the appropriate memory request and limit for the tt containers. This is the default behavior (.spec.ttspec.automaticMemoryRequests is set to true by default) for a TimesTenClassic or TimesTenScaleout object.

For the remaining TimesTen containers, the TimesTen Operator uses specific datum in the .spec.ttspec section of the TimesTenClassic and TimesTenScaleout object definitions to determine the memory request and limit and the CPU request and limit for each of the TimesTen containers. The TimesTen Operator either uses the default values for the datum or uses a value that you specify. The exception is the CPU request and limit for the tt container. Since there is no default, if you want to define a CPU request and limit, you must manually specify a value in the .spec.ttspec.databaseCPURequest datum of your TimesTenClassic and TimesTenScaleout objects. The TimesTen Operator then supplies all this information for memory and CPU requests and limits to Kubernetes.

For details about these datum, including defaults, see TimesTenClassicSpecSpec and TimesTenScaleoutSpecSpec.

It is essential that the value for the memory request for the tt container that holds the TimesTen database be accurate.

Recall that the memory request for the tt container is based on:
  • Shared memory for the database: This is dependent on the size of the database.

  • Additional memory: This is the memory required in addition to the database. It includes memory that is used for the TimesTen daemon, subdaemons, agents, Client/Server server.

The TimesTen Operator provides the .spec.ttspec.databaseMemorySize and .spec.ttspec.additionalMemoryRequest datum for these specific memory requirements. The .spec.ttspec.databaseMemorySize is used to specify the size of the database and the .spec.ttspec.additionalMemoryRequest is used for the additional memory.

The TimesTen Operator adds the value of .spec.ttspec.additionalMemoryRequest to the value of .spec.ttspec.databaseMemorySize. The sum is the memory request and memory limit to Kubernetes.

You do not have to specifically specify the .spec.ttspec.databaseMemorySize datum for a TimesTenClassic or TimesTenScaleout object. If not specified, the TimesTen Operator attempts to determine the appropriate value.

TimesTen provides the ttShmSize utility to determine the shared memory requirements of a database, given its sys.odbc.ini entry. For information about ttShmSize, see ttShmSize in the Oracle TimesTen In-Memory Database Reference.

The equivalent for a TimesTen sys.odbc.ini file is the TimesTen Operator db.ini metadata file. You can provide the db.ini file in several ways:
  • Embed in a ConfigMap referenced in .spec.ttspec.dbConfigMap.

  • Embed in a Secret referenced in .spec.ttspec.dbSecret.

  • Use an init container.

For details about the facilities that you can use to provide metadata files, see Populate the /ttconfig Directory.

TimesTen recommends that you provide the db.ini metadata file in either a ConfigMap or a Secret. The TimesTen Operator examines the Configmaps and Secrets, if any, in your TimesTenClassic or TimesTenScaleout objects. If the db.ini is found in a Configmap or Secret, the TimesTen Operator uses the TimesTen ttShmSize utility to determine the appropriate amount of shared memory to request based on your database definition. This value is then used for the .spec.ttspec.databaseMemorySize value. With this approach, the TimesTen Operator does the database sizing for you.

Let's look at an example:
kind: ConfigMap
metadata:
  name: resource9
data:
  adminUser: |
    adminuser/adminuserpwd
  schema.sql: |
    create user sampleuser identified by sampleuserpwd;
    grant admin to sampleuser;
    create table sampleuser.a (b number not null primary key, c number, d timestamp);  
    insert into sampleuser.a values(-1, -1, sysdate);
  db.ini: |
    Permsize=32768
    TempSize=4096
    LogBufMB=1024
    Connections=2048
    DatabaseCharacterSet=AL32UTF8
---
apiVersion: timesten.oracle.com/v1
kind: TimesTenClassic
metadata:
  name: recommendedoption
spec:
  ttspec:
    dbConfigMap:
    - option1
    storageClassName: standard
    storageSize: 200Gi
    image: container-registry.oracle.com/timesten/timesten:22.1.1.19.0
    imagePullSecret: sekret
    prometheus:
      insecure: true
In this case, the TimesTen Operator runs ttShmSize against your provided db.ini file and determines the value for .spec.ttspec.databaseMemorySize automatically. The TimesTen Operator then adds this value to the value for .spec.ttspec.additionalMemoryRequest. The sum is the memory request and memory limit to Kubernetes.

If you provide the db.ini file by using an init container or other mechanism, the TimesTen Operator cannot determine the value for .spec.ttspec.databaseMemorySize. By the time the Pod is provisioned and the init container is executed, the Pod has already been created and its memory requirements defined. In such cases, you must manually provide the .spec.ttspec.databaseMemorySize as part of your YAML.

TimesTen recommends that you use the ttShmSize utility in a TimesTen instance outside of Kubernetes to determine the appropriate value for .spec.ttspec.databaseMemorySize. You do not need to create the database.

This example assumes you have created a TimesTen instance outside of Kubernetes and have created a DSN in your sys.odbc.ini file with the name database1. Use the ttShmSize utility based on provided values for the PermSize, TempSize, LogBufMB, and Connections connection attributes.

ttShmSize -connstr "DSN=database1;PermSize=32768;TempSize=4096;LogBufMB=1024;Connections=2048" 
The required shared memory size is 39991547720 bytes.

Specify this value in the .spec.ttspec.databaseMemorySize datum.

Let's look at an example that uses an init container and uses the calculated value for .spec.ttspec.databaseMemorySize.
apiVersion: timesten.oracle.com/v1
kind: TimesTenClassic
metadata:
  name: init1
spec:
  ttspec:
    databaseMemorySize: 41Gi
    storageClassName: standard
    storageSize: 200Gi
    image: container-registry.oracle.com/timesten/timesten:22.1.1.19.0
    imagePullSecret: sekret
    prometheus:
      insecure: true
  template:
    spec:
      initContainers:
      - name: init1a
         command:
        - sh
        - "-c"
        - |
          /bin/bash <<'EOF'
          echo adminuser/adminuserpwd > /ttconfig/adminUser
          echo PermSize=32768 > /ttconfig/db.ini
          echo TempSize=4096 > /ttconfig/db.ini
          echo LogBufMB=1024 > /ttconfig/db.ini
          echo Connections=2048 > /ttconfig/db.ini
          echo DatabaseCharacterSet=AL32UTF8 >> /ttconfig/db.ini
          ls -l /ttconfig
          EOF
        volumeMounts:
        - name: tt-config
          mountPath: /ttconfig
      volumes:
      - name: tt-config
        emptyDir: {}  

In this case, the TimesTen Operator uses the value you specified for .spec.ttspec.databaseMemorySize to determine the size of the shared memory segment to hold the TimesTen database. The TimesTen Operator then adds this value to the value for .spec.ttspec.additionalMemoryRequest. The sum is the memory request and memory limit to Kubernetes.

Note:

In TimesTen Scaleout, the sys.odbc.ini file (and corresponding db.ini file) define the size of a single element of the database, not the entire database. When provisioning a TimesTenScaleout object, the TimesTen Operator uses the provided data in the same manner as it does for a TimesTenClassic object.