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?

RHEL9でkind(Kubernetes in Docker)を構築

Posted at

概要

  • kind を一言でいうと、コンテナを k8s ノードと見なしてクラスタを実行させる箱庭的な便利ツール
  • kind を試すのに docker 使うのは普通ですが、 ここはやっぱり podman machine でやってみたい
  • 検証用で構築したRHEL9でkindが動作するまでの手順

検証した環境

[root@RHEL9 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.4 (Plow)

RHEL9へのPodmanの導入

導入及び事前準備に関しては以下の記事をご参照ください。
virtualboxでRHEL9を起動してpodmanをサクッと起動

kubectlのダウンロード

クラスタ操作のため以下コマンドでkubectlをダウンロード

[root@RHEL9 ~]# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0    686      0 --:--:-- --:--:-- --:--:--   686
100 49.0M  100 49.0M    0     0  4955k      0  0:00:10  0:00:10 --:--:-- 4726k
[root@RHEL9 ~]# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0    650      0 --:--:-- --:--:-- --:--:--   647
100    64  100    64    0     0    236      0 --:--:-- --:--:-- --:--:--   236
[root@RHEL9 ~]# echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check
kubectl: 完了
[root@RHEL9 ~]# install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
[root@RHEL9 ~]# kubectl version
Client Version: v1.30.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.0
[root@RHEL9 ~]#

バイナリファイルからkindをインストール

[root@RHEL9 ~]# [ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-$(uname)-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    97  100    97    0     0    176      0 --:--:-- --:--:-- --:--:--   176
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 6381k  100 6381k    0     0  3438k      0  0:00:01  0:00:01 --:--:-- 28.4M
[root@RHEL9 ~]#
[root@RHEL9 ~]# chmod +x ./kind
[root@RHEL9 ~]# mv ./kind /usr/local/bin/kind

このままkindを起動させるとデフォルトの1ノードクラスタで起動するためyamlファイルを作成

[root@RHEL9 ~]# cat <<'EOF'> kind-1m3w.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
  disableDefaultCNI: false
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
EOF

先程用意したファイルをベースにクラスタを起動する

[root@RHEL9 ~]# kind create cluster --config kind-1m3w.yaml
ignoring unknown value "podma" for KIND_EXPERIMENTAL_PROVIDER
enabling experimental podman provider
Creating cluster "kind" ...
 ? Ensuring node image (kindest/node:v1.30.0) ?
 ? Preparing nodes ? ? ? ?
 ? Writing configuration ?
 ? Starting control-plane ??
 ? Installing CNI ?
 ? Installing StorageClass ?
 ? Joining worker nodes ?
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community ?

podman ps で node の動作を確認すると正常に node が起動されていることが確認できる

[root@RHEL9 ~]# podman ps
CONTAINER ID  IMAGE                                                                                           COMMAND     CREATED        STATUS        PORTS                      NAMES
ac145e89ff59  docker.io/kindest/node@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e              2 minutes ago  Up 2 minutes                             kind-worker3
cbaa4535d02d  docker.io/kindest/node@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e              2 minutes ago  Up 2 minutes                             kind-worker2
ef89c1276b13  docker.io/kindest/node@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e              2 minutes ago  Up 2 minutes  127.0.0.1:45415->6443/tcp  kind-control-plane
0e2997ef8406  docker.io/kindest/node@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e              2 minutes ago  Up 2 minutes                             kind-worker
[root@RHEL9 ~]#
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?