0
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?

Rancher Desktopとkindを使ってKubernetesクラスタをたてる

Posted at

はじめに

Kubernetesを手元で動かしたい場合、どのように構築するのが良いでしょうか。

以下の手順の通り、Docker Desktopを使うと簡単にKubernetesクラスタを構築することができます。
https://docs.docker.com/desktop/features/kubernetes/
ただ大人の事情でDocker Desktopが使えない場合、他の手段で構築する必要があります。

そのため、本手順ではRancher Desktopとkindを使ってKubernetesクラスタをたてる手順を示します。

環境情報

Component Version
PC M1 MacBook Pro
OS macOS 15.2
Rancher Desktop 1.17.0
docker 27.4.1
kind v0.26.0
kubectl-cli v1.32.0

手順

インストール

brewでRancher Desktopをインストールします。

brew install rancher --cask

また、kindとkubectlとdockerもインストールします。

brew install docker kind kubectl

Rancher Desktopの起動と動作確認

Rancher Desktopがインストールできたら、アプリケーション一覧からRancher Desktopを選択し起動します。

起動後はdocker psを実行し、正常終了するか確認します。

docker ps

kindでKubernetesクラスタをたてる

dockerコマンドが叩けるようになったら、kindでKubernetesクラスタをたてていきます。

以下の通り、kindの設定ファイルをyamlで記述し、kind-sandbox.yamlという名前で保存します。
ちなみに、control plane1つ、worker node2つのsandboxという名前のKubernetesクラスタを作る設定ファイルです。

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: sandbox
nodes:
- role: control-plane
- role: worker
- role: worker

kind createコマンドを実行して、Kubernetesクラスタを起動します。

kind create cluster --config kind-sandbox.yaml

1,2分ほどで作成が終わるので、以下のコマンドを実行しsandboxが表示されるか確認します。

kind get clusters

最後に、kubectlコマンドを実行できるか確認します。

kubectl get nodes

最後に

本手順でRancher Desktopをkindを使ってKubernetesクラスタをたてることができるようになりました。
kindを使うとKubernetesクラスタの作成と廃棄が簡単にできるようになるので、いろいろと手元で実験してみたいときに役に立ちます。

0
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
0
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?