vm.gowatana.jp

NEOにほんごVMware(仮)

VCF 9.0 で Foundation LB の vSphere Supervisor を構成してみる。Part-05:kubectl のインストール

VMware Cloud Foundation(VCF)9.0 の vCenter で、Foundation ロード バランサを使用したスーパーバイザーを有効化してみます。今回は、kubectl をダウンロードしてインストールします。

前回はこちら。

 

今回の内容です。

 

1. kubectl と kubectl-vsphere プラグインのダウンロード

スーパーバイザー制御プレーンから、kubectl と kubectl-vsphere プラグインの .zip ファイルをダウンロードします。

ダウンロード ページは VCF CLIと同じなので、vSphere 名前空間の「サマリ」タブにある「開く」リンクから開きます。

 

もしく、スーパーバイザー制御プレーン IP アドレス(https で)を Web ブラウザで開きます。ダウンロード ページのアドレスは、すべての vSphere 名前空間で共通です。

 

ページ後半にある、「kubectl-vsphere plugin」を開きます。kubectl-vsphere が廃止されることが記載されていますが、Kubernetes の操作で kubectl を使用するのでここから ,zip ファイルをダウンロードしておきます。

 

デフォルトでは、Windows 用ファイルのダウンロード リンクが表示されています。

 

「LINUX」を選択して、「DOWNLOAD CLI PLUGIN FOR LINUX」をクリックすると「vsphere-plugin.zip」ファイルをダウンロードできます。

 

Linux マシンの curl コマンドでは、下記のようにダウロードします。

  • スーパーバイザー制御プレーンのアドレスは 192.168.79.180 です。
$ curl -kLO https://192.168.79.180/wcp/plugin/linux-amd64/vsphere-plugin.zip

 

2. kubectl のインストール

vsphere-plugin.zip をホーム ディレクトリで展開します。

$ unzip vsphere-plugin.zip
Archive:  vsphere-plugin.zip
  inflating: bin/kubectl-vsphere
  inflating: bin/kubectl

 

この Linux マシンでは、$HOME/bin をコマンドのサーチ パス(PATH 環境変数)に含めてあるため、そのまま kubectl が実行可能になります。

$ kubectl version
Client Version: v1.30.5+vmware.4-fips
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
The connection to the server localhost:8080 was refused - did you specify the right host or port?

 

3. スーパーバイザーへの接続

前回の投稿で、VCF CLI でスーパーバイザーに接続してあります。

 

コンテキストは、以前の投稿で作成した vSphere 名前空間のものに切り替えます。

  • vSphere 名前空間:demo-ns-01
  • コンテキスト:sv-01:demo-ns-01
$ vcf context use sv-01:demo-ns-01
[ok] Token is still active. Skipped the token refresh for context "sv-01:demo-ns-01"
[i] Successfully activated context 'sv-01:demo-ns-01' (Type: kubernetes)
[i] Fetching recommended plugins for active context 'sv-01:demo-ns-01'...
[i] Installing the following plugins recommended by context 'sv-01:demo-ns-01':
  NAME                INSTALLING
  cluster             v3.3.1
  kubernetes-release  v3.3.1
  namespaces          v9.0.0
  package             v3.3.1
  registry-secret     v3.3.1
  vm                  v9.0.0
[i] Installed plugin 'cluster:v3.3.1'
[i] Installed plugin 'kubernetes-release:v3.3.1'
[i] Installed plugin 'namespaces:v9.0.0'
[i] Installed plugin 'package:v3.3.1'
[i] Installed plugin 'registry-secret:v3.3.1'
[i] Installed plugin 'vm:v9.0.0'
[ok] Successfully installed all recommended plugins.

 

現在のコンテキストが「sv-01:demo-ns-01」に切り換えられていること(CURRENT: true)を確認します。

$ vcf context list
  NAME                         CURRENT  TYPE
  sv-01                        false    kubernetes
  sv-01:demo-ns-01             true     kubernetes
  sv-01:svc-tkg-domain-c10     false    kubernetes
  sv-01:svc-velero-domain-c10  false    kubernetes

[i] Use '--wide' to view additional columns.

 

kubectl でも、現在のコンテキストが「sv-01:demo-ns-01」切り換えられていることを確認します。

$ kubectl config get-contexts
CURRENT   NAME                          CLUSTER                AUTHINFO                                           NAMESPACE
          sv-01                         sv-01:192.168.79.180   sv-01:Administrator@vsphere.local@192.168.79.180
*         sv-01:demo-ns-01              sv-01:192.168.79.180   sv-01:Administrator@vsphere.local@192.168.79.180   demo-ns-01
          sv-01:svc-tkg-domain-c10      sv-01:192.168.79.180   sv-01:Administrator@vsphere.local@192.168.79.180   svc-tkg-domain-c10
          sv-01:svc-velero-domain-c10   sv-01:192.168.79.180   sv-01:Administrator@vsphere.local@192.168.79.180   svc-velero-domain-c10

 

つづく。