レプリケートされないTimesTenデータベースのアップグレード

3つの独立したTimesTenデータベースで構成される、レプリケートされないTimesTenClassicオブジェクトのアップグレードを実行します。

アップグレード・プロセスでは、次のステップを実行する必要があります:
  • YAMLファイルを作成します。このファイルでは、TimesTenの新しいリリースを含むコンテナ・イメージを指定します。

  • アップグレードにhelm valuesコマンドを使用します。この例は、この方法を示しています。

また、この例では、rollingUpdatePartition変数の値を変更する方法を示します。

  1. 開発ホストで、新しいHelmチャートを含むhelmディレクトリに移動します。
    cd new_kube_files/helm
  2. YAMLファイルを作成し、そのファイルにアップグレードに使用するTimesTenイメージの名前を指定します。
    vi customyaml/upgradenonreplicated.yaml
    
    image:
      repository: container-registry.oracle.com/timesten/timesten
      tag: "22.1.1.28.0"
  3. アップグレードの前に、次の手順を実行します:
    1. レプリケートされないTimesTenClassicオブジェクトがネームスペースに存在することを確認します。
      kubectl get ttc 
      出力は、次のようになります。
      NAME              STATE              ACTIVE            AGE
      norepsamplehelm   AllReplicasReady   N/A               10h
      repsamplehelm     Normal             repsamplehelm-1   13h

      norepsamplehelm TimesTenClassicオブジェクトが存在し、AllReplicasReady状態です。

    2. イメージおよびrollingUpdatePartitionの値を確認します。
      kubectl get ttc norepsamplehelm -o yaml | grep 'image\|rollingUpdatePartition'
      出力は、次のようになります。
          image: container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      ...
          rollingUpdatePartition: 2
      ...

      rollingUpdatePartitionの値は2で、Kubernetesが2以上の序数値でポッドをアップグレードすることを示します。norepsamplehelmオブジェクトの場合、replicasの値は3であるため、norepsamplehelm-0norepsamplehelm-1およびnorepsamplehelm-2という3つのポッドがあります。したがって、Kubernetesはnorepsamplehelm-2ポッドのみをアップグレードします。

  4. ttclassicチャートのリリースを確認します。
    helm list
    出力は、次のようになります。
    NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION
    norepsamplehelm default         1               2024-08-04 17:42:47.180635098 +0000 UTC deployed        ttclassic-2211270.1.0   22.1.1.27.0
  5. 新しいリリースにアップグレードします。新しいリリースのttclassicチャートを使用し、新しいイメージを参照するカスタマイズされたYAMLファイルを使用します。

    ノート:

    次の構文をお薦めします。これにより、既存のカスタマイズが保持されます。
    helm get values norepsamplehelm --all > prev-values-norepttc.yaml
    helm upgrade -f prev-values-norepttc.yaml -f customyaml/upgradenonreplicated.yaml  norepsamplehelm ./ttclassic
    次のhelm upgradeコマンドを見てみましょう。
    • get values norepsamplehelm Helmコマンドは、既存のカスタマイズを含む現在のリリースの値を取得します。このコマンドの結果は、prev-values-norepttc.yamlファイルにパイプされます。このファイルには任意の名前を選択できます。

    • helm upgradeコマンドは、カスタマイズしたupgradenonreplicated.yamlファイルとともにprev-values-norepttc.yamlファイルを使用してアップグレードを実行します。

    helm upgradeコマンドの出力を見てみましょう。

    Release "norepsamplehelm" has been upgraded. Happy Helming!
    NAME: norepsamplehelm
    LAST DEPLOYED: Mon Aug  5 04:22:15 2024
    NAMESPACE: default
    STATUS: deployed
    REVISION: 2
    NOTES:
    Version 2211280.1.0 of the ttclassic chart has been installed.
    
    This release is named "norepsamplehelm".
    
    To learn more about the release, try:
    
      $ helm status norepsamplehelm
      $ helm get all norepsamplehelm
      $ helm history norepsamplehelm
    
    To rollback to a previous version of the chart, run:
    
      $ helm rollback norepsamplehelm <REVISION>
        - run 'helm history norepsamplehelm' for a list of revisions.
    次の点に注目してください。
    • norepsamplehelmチャート・リリースがアップグレードされています。リリース・リビジョンは2です。

    • リリースのステータスはdeployedです。

    • ttclassicチャートのバージョンは、TimesTenリリース22.1.1.28.0に対応する2211280.1.0です。

  6. 進捗を監視します。
    kubectl get ttc norepsamplehelm

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

    NAME              STATE               ACTIVE            AGE
    norepsamplehelm   SomeReplicasReady   N/A               10h
    

    オブジェクトはSomeReplicasReady状態です。

    数分間待機します。次に、再度監視します。

    kubectl get ttc norepsamplehelm

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

    NAME              STATE              ACTIVE            AGE
    norepsamplehelm   AllReplicasReady   N/A               10h

    オブジェクトはAllReplicasReady状態です。すべてのレプリカが準備でき、使用可能になります。TimesTenデータベースは稼働中であり、正しく機能しています。

  7. norepsamplehelm-2ポッドが実行しているイメージを確認します。
    kubectl describe pod norepsamplehelm-2 | grep Image

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

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

    ポッド内のコンテナでは、新しいコンテナ・イメージが実行されています。

  8. norepsamplehelm-1およびnorepsamplehelm-0ポッドのイメージを確認します。
    1. norepsamplehelm-1ポッドを確認します。
      kubectl describe pod norepsamplehelm-1 | grep Image

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

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

      ポッド内のコンテナでは、新しいイメージは実行されていません。2rollingUpdatePartition値により、Kubernetesはこのポッドを新しいイメージでアップグレードしません。これは正常な動作です。

    2. norepsamplehelm-0ポッドを確認します。
      kubectl describe pod norepsamplehelm-0 | grep Image

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

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

      ポッド内のコンテナでは、新しいイメージは実行されていません。2rollingUpdatePartition値により、Kubernetesはこのポッドを新しいイメージでアップグレードしません。これは正常な動作です。

    アップグレードが機能していることを確認したら、残りのポッドをアップグレードできます。
  9. YAMLファイルを作成し、そのファイルにrollingUpdatePartition変数を指定し、値を0に設定します。
    vi customyaml/changerollingupdate.yaml
    
    rollingUpdatePartition: 0
  10. rollingUpdatePartition値を変更します。

    ノート:

    次の構文をお薦めします。これにより、既存のカスタマイズが保持されます。
    helm get values norepsamplehelm --all > prev-values-noreprolling.yaml && helm upgrade -f prev-values-noreprolling.yaml -f customyaml/changerollingupdate.yaml  norepsamplehelm ./ttclassic
    出力は、次のようになります。
    Release "norepsamplehelm" has been upgraded. Happy Helming!
    NAME: norepsamplehelm
    LAST DEPLOYED: Mon Aug  5 04:56:32 2024
    NAMESPACE: default
    STATUS: deployed
    REVISION: 3
    NOTES:
    Version 2211280.1.0 of the ttclassic chart has been installed.
    
    This release is named "norepsamplehelm".
    
    To learn more about the release, try:
    
      $ helm status norepsamplehelm
      $ helm get all norepsamplehelm
      $ helm history norepsamplehelm
    
    To rollback to a previous version of the chart, run:
    
      $ helm rollback norepsamplehelm <REVISION>
        - run 'helm history norepsamplehelm' for a list of revisions.

    Kubernetesは自動的にポッドを終了し、新しいポッドに置き換えます。これらの新しいポッドは新しいイメージを実行します。rollingUpdatePartitionは現在0であるため、新しいイメージでアップグレードされたnorepsamplehelm-1およびnorepsamplehelm-0ポッドが表示されます。

  11. 進捗を監視します。
    1. TimesTenClassicオブジェクト:
      kubectl get ttc norepsamplehelm

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

      NAME              STATE               ACTIVE   AGE
      norepsamplehelm   SomeReplicasReady   N/A      11h
    2. Pods:
      kubectl get pods

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

      NAME                                 READY   STATUS     RESTARTS   AGE
      norepsamplehelm-0                    3/3     Running    0          11h
      norepsamplehelm-1                    0/3     Init:0/1   0          31s
      norepsamplehelm-2                    3/3     Running    0          34m

      Kubernetesは、最初にnorepsamplehelm-1ポッドを置き換えます。数分間待機します。次に、再度監視します。

      kubectl get pods

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

      NAME                                 READY   STATUS    RESTARTS   AGE
      norepsamplehelm-0                    3/3     Running   0          3m14s
      norepsamplehelm-1                    3/3     Running   0          6m8s
      norepsamplehelm-2                    3/3     Running   0          40m

      Kubernetesにより、norepsamplehelm-1およびnorepsamplehelm-0ポッドが置き換わりました。すべてのポッドが実行されています。

  12. ポッドが新しいコンテナ・イメージを実行していることを確認します。

    ポッドnorepsamplehelm-1:

    kubectl describe pod norepsamplehelm-1 | grep Image

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

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

    ポッドnorepsamplehelm-0:

    kubectl describe pod norepsamplehelm-0 | grep Image

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

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

    ポッドでは、新しいイメージが実行されています。

  13. TimesTenClassicオブジェクトの状態を確認します。
    kubectl get ttc norepsamplehelm

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

    NAME              STATE              ACTIVE   AGE
    norepsamplehelm   AllReplicasReady   N/A      11h

おめでとうございます。レプリケートされないTimesTenClassicオブジェクトの自動アップグレードが正常に実行されました。すべてのレプリカが準備でき、使用可能になります。ポッドでは、新しいTimesTenコンテナ・イメージが実行されています。TimesTenデータベースはアップグレードされ、完全に動作しています。