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?

More than 3 years have passed since last update.

GNU/Linuxにkindを使ってkubernetesをセットアップする

Last updated at Posted at 2020-05-03

GNU/LinuxでDockerがセットアップされている環境に、kindをつかってkuberenetesクラスタをセットアップします。

kubectlのインストール

公式解説


$ curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl
$ sudo install -m 755 -o root -g root ./kubectl /usr/local/bin
$ source <(kubectl completion bash) # bash補完設定

kindのインストール

公式解説


$ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.8.0/kind-$(uname)-amd64
$ sudo install -m 755 -o root -g root ./kind /usr/local/bin
$ source <(kind completion bash) # bash補完設定

k8s クラスタの作成

最新のk8sクラスタをセットアップする場合

公式解説

$ kind create cluster --name k8s-test
$ kubectl cluster-info --context kind-k8s-test
$ kubectl get node
NAME                    STATUS   ROLES    AGE     VERSION
k8s-test-control-plane  Ready    master   2m12s   v1.18.2

※kindは複数のクラスタを作成し、切り替えての利用が可能です。

作成するk8sのバージョンをkindで指定する場合

kindのReleaseページを参照し、control-planeとworkerのimageを以下のyamlファイルの例のように指定します。ここではv1.14系を指定し、k8s-1.14.yamlというファイル名で保存します。(参考)

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  image: kindest/node:v1.14.10@sha256:6cd43ff41ae9f02bb46c8f455d5323819aec858b99534a290517ebc181b443c6
- role: worker
  image: kindest/node:v1.14.10@sha256:6cd43ff41ae9f02bb46c8f455d5323819aec858b99534a290517ebc181b443c6

作成したyamlファイルを指定して、kindでクラスタを作成します。

$ kind create cluster --config k8s-1.14.yaml 
$ kubectl cluster-info --context kind-kind
$ kubectl get nodes 
NAME                 STATUS   ROLES    AGE    VERSION
kind-control-plane   Ready    master   2m9s   v1.14.10
kind-worker          Ready    <none>   87s    v1.14.10
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?