自動アップグレードの実行

TimesTenClassicオブジェクトの.spec.ttspec.imageUpgradeStrategyデータ項目によって、アップグレード方法が決まります。kubectl get ttc -o yamlコマンドを使用すると、どのTimesTenClassicオブジェクトについてもこのデータ項目の値を確認できます。たとえば、ネームスペースにsampleというTimesTenClassicオブジェクトがあるとします。sample.spec.ttspec.imageUpgradeStrategyデータ項目の設定を確認しましょう。

kubectl get ttc sample -o yaml

出力は次のようになります。ノート: 出力のすべては示していません。

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
...

.spec.ttspec.imageUpgradeStrategyの値はAutoです。

自動アップグレードの手順を説明します。

ノート:

前述のとおり、自動アップグレードを実行するとデータベースがすぐに停止され、再起動され、フェイルオーバーされます。本番日の最も忙しい時間にこの手順を実行しないでください。アップグレード手順の結果として、アプリケーションは短期間停止され、パフォーマンスが低下する場合もあります。

TimesTenClassicオブジェクトの変更: 自動アップグレード

自動アップグレード・プロセスを利用するには、新しいTimesTenコンテナ・イメージを参照するようにTimesTenClassicオブジェクトの.spec.ttspec.imageデータ項目を変更する必要があります。新しいTimesTenイメージを参照するようにTimesTenClassicオブジェクトを変更すると、オペレータは変更を認識して、オペレータが作成したStatefulSetを変更します。その後、オペレータがアップグレード・プロセスを開始します。kubectl describeコマンドを使用して、このアップグレード・プロセスを監視できます。

  1. 開発ホストで、sample TimesTenClassicオブジェクトを編集し、新しいTimesTenコンテナ・イメージを参照するように.spec.ttspec.imageデータ項目を変更します。この例では、新しいコンテナ・イメージの場所と名前はcontainer-registry.oracle.com/timesten/timesten:22.1.1.19.0です。

    ノート: 出力のすべては示していません。

    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
    出力は次のようになります。
    timestenclassic.timesten.oracle.com/sample edited
  2. オペレータによってsampleのStatefulSetが変更されイメージが新しいイメージに置き換えられたことを確認してください。
    kubectl describe statefulset sample

    出力は次のようになります。

    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
    

新しいTimesTenコンテナ・イメージを使用するようにsample TimesTenClassicオブジェクトを変更しました。これで、オペレータが実行する自動アップグレード・プロセスを監視する準備が整いました。

自動アップグレードの監視

オペレータによって実行される自動アップグレード・プロセスを監視できます。これらのステップはオプションです。

  1. kubectl getコマンドを使用してsample TimesTenClassicオブジェクトの状態を評価します。
    kubectl get ttc sample

    初期状態がStandbyDownであることに注目してください。

    NAME     STATE         ACTIVE     AGE
    sample   StandbyDown   sample-0   18h
    

    数分間待機してから、コマンドを再実行します。

    kubectl get ttc sample

    その状態がNormalに変わったことに注目してください。

    NAME     STATE    ACTIVE     AGE
    sample   Normal   sample-1   18h

    オペレータによってsample-1がアクティブへと昇格されました。

  2. kubectl describeコマンドを使用して、オペレータがスタンバイ・データベース(sample-1)をアクティブに昇格させる方法を確認します。
    kubectl describe ttc sample

    出力は次のようになります。

    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
    

自動アップグレードが成功しました。この時点で、アクティブ・ポッドとスタンバイ・ポッドは、新しいTimesTenリリースが含まれている新しいTimesTenイメージを実行しています。