- Kubernetesオペレータ・ユーザーズ・ガイド
- TimesTen Kubernetesオペレータ環境でのHelmの使用
- アップグレード
- レプリケートされないTimesTenデータベースのアップグレード
レプリケートされないTimesTenデータベースのアップグレード
3つの独立したTimesTenデータベースで構成される、レプリケートされないTimesTenClassicオブジェクトのアップグレードを実行します。
-
YAMLファイルを作成します。このファイルでは、TimesTenの新しいリリースを含むコンテナ・イメージを指定します。
-
アップグレードに
helm
values
コマンドを使用します。この例は、この方法を示しています。
また、この例では、rollingUpdatePartition
変数の値を変更する方法を示します。
- 開発ホストで、新しいHelmチャートを含む
helm
ディレクトリに移動します。cd new_kube_files/helm
- YAMLファイルを作成し、そのファイルにアップグレードに使用するTimesTenイメージの名前を指定します。
vi customyaml/upgradenonreplicated.yaml image: repository: container-registry.oracle.com/timesten/timesten tag: "22.1.1.28.0"
- アップグレードの前に、次の手順を実行します:
- レプリケートされないTimesTenClassicオブジェクトがネームスペースに存在することを確認します。
kubectl get ttc
出力は、次のようになります。NAME STATE ACTIVE AGE norepsamplehelm AllReplicasReady N/A 10h repsamplehelm Normal repsamplehelm-1 13h
norepsamplehelm
TimesTenClassicオブジェクトが存在し、AllReplicasReady
状態です。 - イメージおよび
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-0
、norepsamplehelm-1
およびnorepsamplehelm-2
という3つのポッドがあります。したがって、Kubernetesはnorepsamplehelm-2
ポッドのみをアップグレードします。
- レプリケートされないTimesTenClassicオブジェクトがネームスペースに存在することを確認します。
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
- 新しいリリースにアップグレードします。新しいリリースの
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
です。
-
- 進捗を監視します。
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データベースは稼働中であり、正しく機能しています。 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
ポッド内のコンテナでは、新しいコンテナ・イメージが実行されています。
norepsamplehelm-1
およびnorepsamplehelm-0
ポッドのイメージを確認します。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
ポッド内のコンテナでは、新しいイメージは実行されていません。
2
のrollingUpdatePartition
値により、Kubernetesはこのポッドを新しいイメージでアップグレードしません。これは正常な動作です。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
ポッド内のコンテナでは、新しいイメージは実行されていません。
2
のrollingUpdatePartition
値により、Kubernetesはこのポッドを新しいイメージでアップグレードしません。これは正常な動作です。
アップグレードが機能していることを確認したら、残りのポッドをアップグレードできます。- YAMLファイルを作成し、そのファイルに
rollingUpdatePartition
変数を指定し、値を0
に設定します。vi customyaml/changerollingupdate.yaml rollingUpdatePartition: 0
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
ポッドが表示されます。- 進捗を監視します。
- TimesTenClassicオブジェクト:
kubectl get ttc norepsamplehelm
出力は次のようになります
NAME STATE ACTIVE AGE norepsamplehelm SomeReplicasReady N/A 11h
- 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
ポッドが置き換わりました。すべてのポッドが実行されています。
- TimesTenClassicオブジェクト:
- ポッドが新しいコンテナ・イメージを実行していることを確認します。
ポッド
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
ポッドでは、新しいイメージが実行されています。
- TimesTenClassicオブジェクトの状態を確認します。
kubectl get ttc norepsamplehelm
出力は、次のようになります。
NAME STATE ACTIVE AGE norepsamplehelm AllReplicasReady N/A 11h
おめでとうございます。レプリケートされないTimesTenClassicオブジェクトの自動アップグレードが正常に実行されました。すべてのレプリカが準備でき、使用可能になります。ポッドでは、新しいTimesTenコンテナ・イメージが実行されています。TimesTenデータベースはアップグレードされ、完全に動作しています。