1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

IBMCloud IKS(Kubernetes)へのObject Storageの接続 Part2

Last updated at Posted at 2024-04-23

目的

IBMCloudにてIKSクラスタへオブジェクトストレージを接続するには、サービスの注文から
セキュリティ設定、オブジェクトストレージ接続のプラグイン導入の設定が必要となる。
これらの操作について、スクリーンショットやCLIコマンドの交えて解説する

全体の流れ

1.IKSクラスタの作成(この部分は対象外とする)

Part1の内容に関しては、こちらの記事で説明
2. IBM Cloud Object Storage のセットアップ:Part1

今回の記事は「3. [IBM Cloud Object Storage プラグインのインストール]」の内容を記載
3. IBM Cloud Object Storage プラグインのインストール:Part2

Part3の内容に関しては、こちらの記事で説明
4. アプリへのオブジェクト・ストレージの追加: Part3

IBM Cloud Object Storage プラグインのインストール

①②ワーカーノードへのセキュリティパッチの適用

前提としてワーカーノードのマイナーバージョンの最新化が必要となるため、アップデートを実施する

以下、IBMCloud Docsより抜粋
ワーカー・ノードを最新のセキュリティー設定で実行するために、ワーカー・ノードに、使用しているマイナー・バージョンに対する最新パッチが適用されていることを確認します。 パッチのバージョンから、ワーカー・ノードの root のパスワードが更新されたかどうかも確認できます

現在のワーカーノードのパッチ適用状況を確認
Versionにて*が表示されており、最新バージョンが別にあることがわかる

% ibmcloud ks worker ls --cluster co9j451t0t7uths6kb10
OK
ID                                                       Primary IP     Flavor    State    Status   Zone       Version
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000175   10.244.xx.xx    cx2.2x4   normal   Ready    jp-tok-2   1.27.12_1570*
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000216   10.244.yyy.yy   cx2.2x4   normal   Ready    jp-tok-3   1.27.12_1570*

* To update to 1.27.12_1571 version, run 'ibmcloud ks worker replace'. Review and make any required version changes before you update: 'https://ibm.biz/upworker'

以下、IBMCloud Docsより抜粋
ワーカー・ノードで、最新のパッチ・バージョンが適用されていない場合は、CLI 出力の Version* 列にアスタリスク (**) が表示されます。

ibmcloud ks worker replaceコマンドにてワーカーノードのアップデートを実施

 % ibmcloud ks worker replace --cluster co9j45xxxxxxxx --worker kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000175 --update
The replacement worker node is created in the same zone with the same flavor, but gets new public or private IP addresses. During the replacement, all pods might be rescheduled onto other worker nodes and data is deleted if not stored outside the pod. To avoid downtime, ensure that you have enough worker nodes to handle your workload while the selected worker nodes are being replaced.
Replace worker node kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000175? [y/N]> y
Deleting worker node kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000175 and creating a new worker node in cluster co9j45xxxxxxxx...

進捗確認、コマンドにて進捗状況(Status)が確認できる
ibmcloud ks worker ls --cluster [cluster_name_or_ID]

 % ibmcloud ks worker ls --cluster co9j45xxxxxxxx
OK
ID                                                       Primary IP     Flavor    State      Status               Zone       Version
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000175   10.244.xx.xx    cx2.2x4   deleting   Worker is deleting   jp-tok-2   1.27.12_1570*
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000216   10.244.yyy.yy   cx2.2x4   normal     Ready                jp-tok-3   1.27.12_1570*

* To update to 1.27.12_1571 version, run 'ibmcloud ks worker replace'. Review and make any required version changes before you update: 'https://ibm.biz/upworker'

 % ibmcloud ks worker ls --cluster co9j45xxxxxxxx
OK
ID                                                       Primary IP     Flavor    State      Status                                                              Zone       Version
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000175   10.244.xx.xx    cx2.2x4   deleting   Preparing to deregister worker from IBM Cloud Resource Controller   jp-tok-2   1.27.12_1570*
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000216   10.244.yyy.yy   cx2.2x4   normal     Ready                                                               jp-tok-3   1.27.12_1570*

* To update to 1.27.12_1571 version, run 'ibmcloud ks worker replace'. Review and make any required version changes before you update: 'https://ibm.biz/upworker'
 % ibmcloud ks worker ls --cluster co9j45xxxxxxxx
OK
ID                                                       Primary IP     Flavor    State               Status   Zone       Version
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000216   10.244.yyy.yy   cx2.2x4   normal              Ready    jp-tok-3   1.27.12_1570*
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000375   -              cx2.2x4   provision_pending   -        jp-tok-2   -

* To update to 1.27.12_1571 version, run 'ibmcloud ks worker replace'. Review and make any required version changes before you update: 'https://ibm.biz/upworker'

 % ibmcloud ks worker ls --cluster co9j45xxxxxxxx
OK
ID                                                       Primary IP     Flavor    State       Status   Zone       Version
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000216   10.244.yyy.yy   cx2.2x4   normal      Ready    jp-tok-3   1.27.12_1570*
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000375   10.244.64.12   cx2.2x4   deploying   -        jp-tok-2   -

* To update to 1.27.12_1571 version, run 'ibmcloud ks worker replace'. Review and make any required version changes before you update: 'https://ibm.biz/upworker'

 % ibmcloud ks worker ls --cluster co9j45xxxxxxxx
OK
ID                                                       Primary IP     Flavor    State       Status                       Zone       Version
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000216   10.244.yyy.yy   cx2.2x4   normal      Ready                        jp-tok-3   1.27.12_1570*
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000375   10.244.64.12   cx2.2x4   deploying   Starting worker deployment   jp-tok-2   -

* To update to 1.27.12_1571 version, run 'ibmcloud ks worker replace'. Review and make any required version changes before you update: 'https://ibm.biz/upworker'

 % ibmcloud ks worker ls --cluster co9j45xxxxxxxx
OK
ID                                                       Primary IP     Flavor    State    Status   Zone       Version
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000216   10.244.yyy.yy   cx2.2x4   normal   Ready    jp-tok-3   1.27.12_1570*
kube-co9j45xxxxxxxx-acspaasclus-lowspec-00000375   10.244.64.12   cx2.2x4   normal   Ready    jp-tok-2   1.27.12_1571

* To update to 1.27.12_1571 version, run 'ibmcloud ks worker replace'. Review and make any required version changes before you update: 'https://ibm.biz/upworker'

同様にもう一台のワーカーノードのアップデートも実施しておく

③ Helm クライアントをローカル・マシンにインストール)

クラスターへの Helm 3 のインストールのページを参考に、ローカルコンピュータにインストールする

macの場合は、homebrewで実施すれば最新版となり簡単です
Homebrew から (macOS)

brew install helm

④⑤⑥⑦Helm リポジトリの追加、更新およびダウンロード

④IBM Cloud Helm リポジトリーをクラスターに追加します。
IBM Cloud上で動作するKubernetesクラスターに対して、Helmを使用してアプリケーションやサービスを簡単にデプロイおよび管理するための環境を整える作業

% helm repo add ibm-helm https://raw.githubusercontent.com/IBM/charts/master/repo/ibm-helm
"ibm-helm" has been added to your repositories

⑤Helmで使用するリポジトリのデータを更新する
ローカルにキャッシュされたリポジトリのインデックス情報を最新の状態に同期
これにより、最新のHelmチャートを取得して使用することが可能になる

% helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "ibm-helm" chart repository
Update Complete. ⎈Happy Helming!⎈

リポジトリ(repository)とは?
データやファイル、コードなどを保存し、管理するための場所やシステムのことを指します。リポジトリは多くの分野で用いられますが、特にソフトウェア開発においては、以下のような形で広く利用されています。

⑥以前に IBM Cloud Object Storage Helm プラグインをインストールした場合は、ibmc プラグインを削除します。
以前にインストールしていないため、今回は実施しない

helm plugin uninstall ibmc

⑦Helm チャートをダウンロードして、現行ディレクトリーにチャートをアンパック
Helm チャートをダウンロードして現行ディレクトリーにチャートをアンパック(解凍)することは、リモートのHelmリポジトリからチャートを取得し、それをローカルマシン上のディレクトリに展開するプロセス。これにより、チャートの内容を確認したり、カスタマイズしたりすることができる

% helm fetch --untar ibm-helm/ibm-object-storage-plugin

⑧IBM Cloud Object Storage Helm プラグイン ibmc をインストール

% helm plugin install ./ibm-object-storage-plugin/helm-ibmc
Installed plugin: ibmc

プラグインが正常にインストールされていることを確認する
下記の場合はエラーとなった状態

% helm ibmc --help
Error: fork/exec /Users/xx/Library/helm/plugins/helm-ibmc/ibmc.sh: permission denied

このエラーは、Helmのプラグインである helm-ibmc の実行ファイル(この場合は ibmc.sh スクリプト)に実行権限がないことを示しており、この問題を解決するためには、対象のスクリプトファイルに実行権限を付与する必要がある

% chmod 755 /Users/xx/Library/helm/plugins/helm-ibmc/ibmc.sh

% helm ibmc --help
Helm version: v3.14.4+g81c902a
Install or upgrade Helm charts in IBM K8S Service(IKS)
Usage:
  helm ibmc [command]
Available Commands:
  install           Install a Helm chart
  upgrade           Upgrade the release to a new version of the Helm chart
Available Flags:
  -h, --help        (Optional) This text.
  -u, --update      (Optional) Update this plugin to the latest version
Example Usage:
    Install: helm ibmc install ibm-object-storage-plugin ibm-helm/ibm-object-storage-plugin
    Upgrade: helm ibmc upgrade [RELEASE] ibm-helm/ibm-object-storage-plugin
Note:
    1. It is always recommended to install latest version of ibm-object-storage-plugin chart.
    2. It is always recommended to have 'kubectl' client up-to-date.

➓ibm-object-storage-plugin をクラスターにインストール

⑨の手順は今回スキップします

OS X および Linux の場合の helm ibmc install コマンドの例を参考にインストールを実施

% helm ibmc install ibm-object-storage-plugin ibm-helm/ibm-object-storage-plugin --set license=true --set quotaLimit=true --set bucketAccessPolicy=false --set allowCrossNsSecret=true

Helm version: v3.14.4+g81c902a
Checking cluster type
Installing the Helm chart...
PROVIDER: IBMC-VPC
WORKER_OS: debian
PLATFORM: k8s
KUBE_DRIVER_PATH: /usr/libexec/kubernetes
CONFIG_BUCKET_ACCESS_POLICY: false
CONFIG_QUOTA_LIMIT: true
ALLOW_CROSS_NS_SECRET: true
DC: tok02
Region: jp-tok
Chart: ibm-helm/ibm-object-storage-plugin
namespace/ibm-object-s3fs created
NAME: ibm-object-storage-plugin
LAST DEPLOYED: Mon Apr 15 17:41:22 2024
NAMESPACE: ibm-object-s3fs
STATUS: deployed
REVISION: 1
NOTES:
Thank you for installing: ibm-object-storage-plugin.   Your release is named: ibm-object-storage-plugin

1. Verify that the storage classes are created successfully:

   $ kubectl get storageclass | grep 'ibmc-s3fs'

2. Verify that plugin pods are in "Running" state:

   $ kubectl get pods -n ibm-object-s3fs -o wide | grep object

   The installation is successful when you see one `ibmcloud-object-storage-plugin` pod and one or more `ibmcloud-object-storage-driver` pods.
   The number of `ibmcloud-object-storage-driver` pods equals the number of worker nodes in your cluster. All pods must be in a `Running` state
   for the plug-in to function properly. If the pods fail, run `kubectl describe pod -n ibm-object-s3fs <pod_name>`
   to find the root cause for the failure.
######################################################
Additional steps for IBM Kubernetes Service(IKS) only:
######################################################

  1. If the plugin pods show an "ErrImagePull" or "ImagePullBackOff" error, copy the image pull secret 'all-icr-io' from "default" namespace to ibm-object-s3fs namespace of your cluster. The image pull secret 'all-icr-io' provides access to IBM Cloud Container Registry.

     a. Check the secret exists in "default" namespace

     $ kubectl get secrets -n default | grep icr-io

     Example output:
     ------------------------------------------------------------------
     all-icr-io         kubernetes.io/dockerconfigjson        1      2d
     ------------------------------------------------------------------

     b. Copy secret to ibm-object-s3fs  namespace

     $ kubectl get secret -n default all-icr-io -o yaml | sed 's/default/<namespace>/g' | kubectl -n <namespace> create -f -

     c. Verify that the image pull secret is available in the ibm-object-s3fs  namespace.

     $ kubectl get secrets -n ibm-object-s3fs | grep icr-io

  2. Verify that the state of the plugin pods changes to "Running".

     $ kubectl get pods -n ibm-object-s3fs | grep object

インストール後の動作確認方法がコマンド実行結果に記載されているので、実施する

コマンド:kubectl get storageclass | grep 'ibmc-s3fs'
このコマンドはクラスターに設定されている IBM Cloud Object Storage のストレージクラスをリストしています。それぞれのストレージクラスは「Immediate」の削除ポリシーが設定されており、これはリソース削除時にストレージがすぐに削除されることを意味する。

% kubectl get storageclass | grep 'ibmc-s3fs'
ibmc-s3fs-cold-cross-region                   ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-cold-regional                       ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-smart-cross-region                  ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-smart-perf-cross-region             ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-smart-perf-regional                 ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-smart-regional                      ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-standard-cross-region               ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-standard-perf-cross-region          ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-standard-perf-regional              ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-standard-regional                   ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-vault-cross-region                  ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s
ibmc-s3fs-vault-regional                      ibm.io/ibmc-s3fs       Delete          Immediate              false                  91s

コマンド:kubectl get pods -n ibm-object-s3fs -o wide | grep object
名前空間にデプロイされた IBM Cloud Object Storage のプラグインとドライバーポッドの状態を表示
リストされているポッドはすべて「Running」状態で、ストレージプラグインが正常に機能しており、ワーカーノードに正しくデプロイされていることを示している

% kubectl get pods -n ibm-object-s3fs -o wide | grep object
ibmcloud-object-storage-driver-t7jfg              1/1     Running   0          2m    10.244.64.13    10.244.64.13    <none>           <none>
ibmcloud-object-storage-driver-vl6bq              1/1     Running   0          2m    10.244.128.11   10.244.128.11   <none>           <none>
ibmcloud-object-storage-plugin-5565fbd668-5zbs4   1/1     Running   0          2m    172.17.0.4      10.244.128.11   <none>           <none>

コマンド:helm ls -A
Helm を使用して Kubernetes クラスターにインストールされた全てのリリースを一覧表示
・リリース名
・名前空間
・リビジョン番号
・アップデートの状態
・チャートのバージョン
・アプリのバージョン

% helm ls -A
NAME                     	NAMESPACE      	REVISION	UPDATED                             	STATUS  	CHART                           	APP VERSION
ibm-object-storage-plugin	ibm-object-s3fs	1       	2024-04-15 17:41:22.786235 +0900 JST	deployed	ibm-object-storage-plugin-2.2.24	2.2.24

続き
アプリへのオブジェクト・ストレージの追加に続く

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?