ラベル Kubernetes の投稿を表示しています。 すべての投稿を表示
ラベル Kubernetes の投稿を表示しています。 すべての投稿を表示

2025年8月15日金曜日

Ubuntu20.04 に Minikube をベアメタルインストールする

前提

  • Hyper-V を使用
  • OS: Ubuntu Server 20.04 LST
  • 標準インストール直後からの開始

ファイアウォールを OFF に

本当はまじめに穴あけしなきゃいけないのだけど、とりあえず動作確認という事で…

sudo ufw disable

Minikube の none ドライバ実行に必要なパッケージのインストール

conntrack

sudo apt install conntrack

containernetworking-plugins

CNI_PLUGIN_VERSION="v1.7.1"
CNI_PLUGIN_TAR="cni-plugins-linux-amd64-$CNI_PLUGIN_VERSION.tgz" # change arch if not on amd64
CNI_PLUGIN_INSTALL_DIR="/opt/cni/bin"

curl -LO "https://github.com/containernetworking/plugins/releases/download/$CNI_PLUGIN_VERSION/$CNI_PLUGIN_TAR"
sudo mkdir -p "$CNI_PLUGIN_INSTALL_DIR"
sudo tar -xf "$CNI_PLUGIN_TAR" -C "$CNI_PLUGIN_INSTALL_DIR"
rm "$CNI_PLUGIN_TAR"

crictl

DOWNLOAD_DIR="/usr/local/bin"
sudo mkdir -p "$DOWNLOAD_DIR"
CRICTL_VERSION="v1.33.0"
ARCH="amd64"
curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-${ARCH}.tar.gz" | sudo tar -C $DOWNLOAD_DIR -xz

kubectl

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Docker

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
           "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
             $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
               sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
               sudo apt-get update
 sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

cri-docker

curl -LO https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.18/cri-dockerd_0.3.18.3-0.ubuntu-focal_amd64.deb
sudo apt install -y ./cri-dockerd_0.3.18.3-0.ubuntu-focal_amd64.deb

Minikube

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb

OS 設定

何やっているか知らないけど、 minikube start --driver=none で怒られたので実行した。

sudo sysctl fs.protected_regular=0

Minikube クラスタの作成

sudo minikube start --driver=none

動作確認

mikoto@kubernetes:~$ sudo kubectl get nodes
NAME         STATUS   ROLES           AGE     VERSION
kubernetes   Ready    control-plane   7m51s   v1.33.1

mikoto@kubernetes:~$ sudo kubectl run hello-world --image=hello-world --restart=Never
pod/hello-world created

mikoto@kubernetes:~$ sudo kubectl get pod
NAME          READY   STATUS      RESTARTS   AGE
hello-world   0/1     Completed   0          23s


mikoto@kubernetes:~$ sudo kubectl logs pod/hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

OK.

参考資料

2025年8月14日木曜日

Ubuntu20.04 に kubeadm で Kubernetes を構築する

コントロールプレーンに接続できたりできなかったりと、よくわからない状態になってしまったが、とりあえず作業記録として残す。

前提

  • OS: Ubuntu Server 20.04
  • 標準インストール直後からの開始

必須パッケージのインストール

環境構築中に必要になる雑多パッケージをインストール。

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gpg

swap の無効化

sudo swapoff -a
sudo sed -i '/\sswap\s/s/^/#/' /etc/fstab

containerd のインストール

sudo apt-get update
sudo apt-get install -y containerd

kubeadm のインストール

Kubernetes パッケージリポジトリの公開鍵をダウンロード

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

Kubernetes パッケージのリポジトリを登録

echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.33/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list

インストール

kubelet, kubeadm, kubectl をインストールし、バージョンを固定する。

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

シングルノードクラスターの作成

sudo kubeadm init

root ユーザーでない自分んが kubectl を実行できるように設定

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

コントロールプレーンに Pod を配置できるように設定

シングルノード設定なので、コントロールプレーンに相乗りする。

デフォルトではセキュリティ上相乗りできないので、相乗りできるように設定する。

kubectl taint nodes --all node-role.kubernetes.io/control-plane-

動作確認

hello-world のイメージをデプロイしてみる。

mikoto@kubernetes:~$ sudo docker run -it --rm hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

良さそう。以上。

参考資料

2022年5月5日木曜日

Oracle Kubernetes Engine を試す - クラスタ作成から Ingress デプロイまで

OCI 用コンテナ起動

docker run -it --rm --name oci debian:bullseye-slim

OCI ツールのインストール

# 必須ツールのインストール
apt-get update
apt-get -y install \
        curl

# インストール
curl -LO https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh \
    && bash install.sh --accept-all-defaults --install-dir /opt/oci-cli --exec-dir /usr/local/bin --script-dir /opt/oci-cli-scripts

kubectl のインストール

apt-get update
apt-get install -y apt-transport-https gnupg2
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubectl

OCI ツールの設定

TENANCY_IDOCID をメモして、 oci setup config コマンドでログイン設定を行う。

  • TENANCY_ID: OCI コンソール -> プロファイル -> テナンシ:xxxx -> OCID
  • OCID: OCI コンソール -> プロファイル -> マイ・プロファイル -> OCID
oci setup config

API キーの追加

  1. OCI コンソール -> プロファイル -> マイ・プロファイル -> APIキー -> APIキーの追加 を選択
    • CLI ツールの設定 で作成した公開鍵(~/.oci/oci_api_key_public.pem)を選択

Kubernetes クラスタへの接続情報作成

mkdir -p $HOME/.kube
oci ce cluster create-kubeconfig \
        --cluster-id ocid1.cluster.oc1.ap-osaka-1.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \
        --file $HOME/.kube/config \
        --region ap-osaka-1 \
        --token-version 2.0.0  \
        --kube-endpoint PUBLIC_ENDPOINT

動作確認

root@50c44ed35822:/# kubectl get node
NAME          STATUS   ROLES   AGE   VERSION
10.0.10.111   Ready    node    45m   v1.22.5
root@50c44ed35822:/# kubectl get pod -A
NAMESPACE     NAME                                   READY   STATUS    RESTARTS      AGE
kube-system   coredns-c54fdf6bc-ndlr6                1/1     Running   0             48m
kube-system   csi-oci-node-k52lv                     1/1     Running   1 (44m ago)   45m
kube-system   kube-dns-autoscaler-5cf654bff9-c7h8l   1/1     Running   0             48m
kube-system   kube-flannel-ds-j6xgp                  1/1     Running   1 (44m ago)   45m
kube-system   kube-proxy-tz5wf                       1/1     Running   0             45m
kube-system   proxymux-client-xtdtb                  1/1     Running   0             45m

nginx-ingress-controller のデプロイ

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/1.22/deploy.yaml

公開 IP アドレスを確認する。

root@50c44ed35822:/# kubectl get svc -n ingress-nginx
NAME                                 TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.96.139.46   138.2.48.48   80:31906/TCP,443:30887/TCP   4m25s
ingress-nginx-controller-admission   ClusterIP      10.96.73.63    <none>        443/TCP                      4m25s

参考資料

2022年4月16日土曜日

Oracle Cloud の Ampere A1 VM(ARM VM) に Eclipse Che をインストールする

前回 は、 Kubernetes をインストールしたので、その上に Eclipse Che を載せてみる。

Che が提供している Docker イメージは、 amd64 版なので、 Ampere A1 VM 上で動くように arm64 版でビルドしなおしてデプロイする。

あらかじめ残課題をあげておくとこんな感じ。まだあるかも。

  • che-theia は謎の Exception でロードが完了しないため amd64 版のまま使用する
  • 今回 arm64 ビルドしたイメージ以外は qemu-user-static を使って amd64 イメージとして動かす
  • Che が提供するほとんどのスタックは、QEMU がセグフォ吐いて死ぬ

ビルド環境構築

ビルド用コンテナ起動

dind を使用するので、 /var/run/docker.sock をマウントしておく。

docker run -it --rm -v "$HOME/.m2:/root/.m2" -v /var/run/docker.sock:/var/run/docker.sock --name che-buildkit --user root quay.io/eclipse/che-java11-maven:nightly bash

Node のインストール

che-plugin-registry が 16 系を使用しているので、 16 系をインストール。

apt-get update
apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y nodejs

Docker のインストール

minikube が推奨しているので Docker を利用する。

curl -fsSL https://download.docker.com/linux/debian/gpg \
    | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian buster stable" \
    | tee /etc/apt/sources.list.d/docker.list > /dev/null

apt-get update \
    && apt-get -y install \
        docker-ce \
        docker-ce-cli \
        containerd.io

各イメージを arm64 用にビルドと push

以後の作業では、 $HOME/work を作業ディレクトリとして使う。

mkdir -p $HOME/work
WORKDIR=$HOME/work

コンテナレジストリにログイン

ビルドしたものをそのまま push できるようにログインしておく。

docker login

devfile-registry

単純に docker buildx build で arm64 ビルドすれば OK.

リポジトリの取得

cd $WORKDIR
git clone --depth 1 https://github.com/eclipse-che/che-devfile-registry.git
cd che-devfile-registry

devfile-registry のビルド

docker buildx build --platform linux/arm64 -t mikoto2000/che-devfile-registry:arm64 -f ./build/dockerfiles/Dockerfile --target registry .

devfile-registry のプッシュ

docker push mikoto2000/che-devfile-registry:arm64

plugin-registry

yarn プロジェクトをビルドしたうえで、 docker buildx build する。

リポジトリの取得

cd $WORKDIR
git clone --depth 1 https://github.com/eclipse-che/che-plugin-registry.git
cd che-plugin-registry

yarn プロジェクトのビルド

npx yarn
cd ./tools/build
npx yarn build
cd ../..
npx yarn node ./tools/build/lib/entrypoint.js --output-folder:./output

che-plugin-registry のビルド

docker buildx build --platform linux/arm64 -t mikoto2000/che-plugin-registry:arm64 -f ./build/dockerfiles/Dockerfile .

che-plugin-registry のプッシュ

docker push mikoto2000/che-plugin-registry:arm64

che-plugin-broker

このリポジトリ内に che-plugin-artifacts-brokerche-plugin-metadata-broker が含まれているので、両方ともビルド・プッシュする。

リポジトリ取得

cd $WORKDIR
git clone --depth 1 https://github.com/eclipse-che/che-plugin-broker.git
cd che-plugin-broker

Docker イメージのビルド

# che-plugin-artifacts-broker
docker buildx build --platform linux/arm64 -t mikoto2000/che-plugin-artifacts-broker:arm64 -f build/artifacts/Dockerfile .

# che-plugin-metadata-broker
docker buildx build --platform linux/arm64 -t mikoto2000/che-plugin-metadata-broker:arm64 -f build/metadata/Dockerfile .

Docker イメージのプッシュ

docker push mikoto2000/che-plugin-artifacts-broker:arm64
docker push mikoto2000/che-plugin-metadata-broker:arm64

che-server

Maven プロジェクトをビルドしてから docker buildx build でビルドする。

また、使用する Docker イメージを設定するプロパティがあるため、それを arm64 版に書き換える。

リポジトリ取得

main7.46.0 は、起動前に例外が出てしまい Che が起動しなかった。

そのため、今回は 7.45.0 を利用する。

cd $WORKDIR
git clone --depth 1 -b 7.45.0 https://github.com/eclipse-che/che-server.git
cd che-server

che.properties の修正

che-plugin-metadata-brokerche-plugin-artifacts-broker を、 arm64 版に書き換える。

diff --git a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties
index b9c8358..0e008fa 100644
--- a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties
+++ b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties
@@ -560,13 +560,13 @@ che.infra.openshift.project.init_with_server_sa=true
 # Docker image of {prod-short} plugin broker app that resolves workspace tools configuration and copies plugins dependencies to a workspace.
 # The {prod-short} Operator overrides these images by default. Changing the images here will not
 # have an effect if {prod-short} is installed using the Operator.
-che.workspace.plugin_broker.metadata.image=quay.io/eclipse/che-plugin-metadata-broker:v3.4.0
+che.workspace.plugin_broker.metadata.image=mikoto2000/che-plugin-metadata-broker:arm64

 # Docker image of Che plugin artifacts broker.
 # This broker runs as an init container on the workspace Pod. Its job is to take in a list of plugin identifiers
 # (either references to a plugin in the registry or a link to a plugin meta.yaml) and ensure that the correct .vsix
 # and .theia extensions are downloaded into the /plugins directory, for each plugin requested for the workspace.
-che.workspace.plugin_broker.artifacts.image=quay.io/eclipse/che-plugin-artifacts-broker:v3.4.0
+che.workspace.plugin_broker.artifacts.image=mikoto2000/che-plugin-artifacts-broker:arm64

 # Configures the default behavior of the plugin brokers when provisioning plugins into a workspace.
 # If set to true, the plugin brokers will attempt to merge plugins when possible: they run in

Maven プロジェクトのビルド

Che Multiuser :: PostgreSQL Tck で失敗するため、動作に必要なモジュールを別途個別にビルドしている。

「これで十分かよくわからないけど動いているからヨシ!」という状態。

mvn -B clean install -U -Pintegration -Dmaven.test.skip=true -Dfindbugs.skip=true -Dskip-validate-sources
cd infrastructures
mvn -B install -U -Pintegration -Dmaven.test.skip=true -Dfindbugs.skip=true -Dskip-validate-sources
cd ../assembly
mvn -B install -U -Pintegration -Dmaven.test.skip=true -Dfindbugs.skip=true -Dskip-validate-sources

Docker イメージのビルド

arm64 イメージをビルドするようにビルドスクリプトを修正

ファイルコピーなど必要なようなので、ビルドスクリプトを修正して走らせる方針で行くことにした。

diff --git a/dockerfiles/build.include b/dockerfiles/build.include
index 641be64a26..d7afe297da 100755
--- a/dockerfiles/build.include
+++ b/dockerfiles/build.include
@@ -137,7 +137,7 @@ build_image() {
     -e "s;\${BUILD_PREFIX};${PREFIX};" \
     -e "s;\${BUILD_TAG};${TAG};" \
     > ${DIR}/.Dockerfile
-  cd "${DIR}" && docker build -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} .
+  cd "${DIR}" && docker buildx build --platform linux/arm64 -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} .
   DOCKER_BUILD_STATUS=$?
   rm ${DIR}/.Dockerfile
   if [ $DOCKER_BUILD_STATUS -eq 0 ]; then

Docker イメージビルド

このタイミングでビルド可能な endpoint-watcherche(che-server) をビルド。

cd $WORKDIR/che-server/dockerfiles/
./build.sh --organization:mikoto2000 --tag:arm64 endpoint-watcher che

Docker イメージプッシュ

ビルドしたイメージを push する。

docker push mikoto2000/che-endpoint-watcher:arm64
docker push mikoto2000/che-server:arm64

postgres

ベースイメージが arm64 をサポートしていないため、ベースイメージをさかのぼっていき、大元のイメージを centos:7 にして再構築する。

ベースイメージのビルド

大元のベースイメージを registry.centos.org/centos/centos:7 から centos:7 へ変更。

s2i-base-container のビルド(根本のイメージ)

cd $WORKDIR
git clone --depth 1 --recursive https://github.com/sclorg/s2i-base-container.git
cd s2i-base-container

Dockerfile の FROM を centos:7 に変更

また、centos:7 には nss_wrapper がインストールされていないため、そのパッケージも追加する。

diff --git a/core/Dockerfile b/core/Dockerfile
index 70483fa..428aa9a 100644
--- a/core/Dockerfile
+++ b/core/Dockerfile
@@ -1,5 +1,5 @@
 # This image is the base image for all s2i configurable container images.
-FROM registry.centos.org/centos/centos:7
+FROM centos:7

 ENV SUMMARY="Base image which allows using of source-to-image."        \
     DESCRIPTION="The s2i-core image provides any images layered on top of it \
@@ -50,9 +50,11 @@ RUN rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \
   scl-utils \
   tar \
   unzip \
-  yum-utils" && \
+  yum-utils \
+  nss_wrapper" && \
   mkdir -p ${HOME}/.pki/nssdb && \
   chown -R 1001:0 ${HOME}/.pki && \
+  yum install -y epel-release && \
   yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
   rpm -V $INSTALL_PKGS && \
   yum -y clean all --enablerepo='*'

修正が完了したらビルドする。

docker buildx build --platform linux/arm64 -t mikoto2000/s2i-core-centos7:arm64 -f core/Dockerfile .

postgresql-13-centos7 のビルド(che-postgres が直接依存しているイメージ)

cd $WORKDIR
git clone --depth 1 https://github.com/sclorg/postgresql-container.git -b generated
cd postgresql-container/13

Dockerfile の FROM を mikoto2000/s2i-core-centos7:arm64 に修正。

diff --git a/13/Dockerfile b/13/Dockerfile
index c4de6e1..860a6da 100644
--- a/13/Dockerfile
+++ b/13/Dockerfile
@@ -1,4 +1,4 @@
-FROM quay.io/centos7/s2i-core-centos7
+FROM mikoto2000/s2i-core-centos7:arm64

 # PostgreSQL image for OpenShift.
 # Volumes:

Docker イメージのビルド

docker buildx build --platform linux/arm64 -t mikoto2000/postgresql-13-centos7:arm64 .

che-postgres のビルド

che-server 内に Dockerfile があるので、それを利用してビルドする。

cd $WORKDIR/che-server/dockerfiles/postgres

FROM を mikoto2000/postgresql-13-centos7:arm64 へ修正。

diff --git a/dockerfiles/postgres/Dockerfile b/dockerfiles/postgres/Dockerfile
index fe02d72..f36b2d5 100644
--- a/dockerfiles/postgres/Dockerfile
+++ b/dockerfiles/postgres/Dockerfile
@@ -6,7 +6,7 @@
 # SPDX-License-Identifier: EPL-2.0
 #

-FROM centos/postgresql-96-centos7
+FROM mikoto2000/postgresql-13-centos7:arm64
 ADD init-che-user-and-run.sh.erb init-che-user.sh.erb /var/lib/pgsql/
 RUN cat /var/lib/pgsql/init-che-user.sh.erb | \
     sed -e "/exit 0/d" > /var/lib/pgsql/init-che-user-and-run.sh && \

che-postgres のビルド

docker buildx build --platform linux/arm64 -t mikoto2000/che-postgres:arm64 .

che-postgres のプッシュ

docker push mikoto2000/che-postgres:arm64

keycloak

keycloak のビルド(che-keycloak が依存しているイメージ)

che-keycloak が使用しているのベースイメージを取得して、 arm64 版としてビルドする。

cd $WORKDIR
git clone --depth 1 https://github.com/keycloak/keycloak-containers.git
cd keycloak-containers/server
docker buildx build --platform linux/arm64 -t mikoto2000/keycloak:arm64 .

che-keycloak のビルド

che-server 内に Dockerfile があるので、それを利用してビルド。

cd $WORKDIR/che-server/dockerfiles/keycloak

Dockerfile の FROM を mikoto2000/keycloak:arm64 に修正

diff --git a/dockerfiles/keycloak/Dockerfile b/dockerfiles/keycloak/Dockerfile
index 0af6915..a82a458 100644
--- a/dockerfiles/keycloak/Dockerfile
+++ b/dockerfiles/keycloak/Dockerfile
@@ -6,7 +6,7 @@
 # SPDX-License-Identifier: EPL-2.0
 #

-FROM quay.io/keycloak/keycloak:15.0.2
+FROM mikoto2000/keycloak:arm64

 ADD che /opt/jboss/keycloak/themes/che
 ADD che-username-readonly /opt/jboss/keycloak/themes/che-username-readonly

修正が終わったらビルドする。

docker buildx build --platform linux/arm64 -t mikoto2000/che-keycloak:arm64 .

che-keycloak のプッシュ

docker push mikoto2000/che-keycloak:arm64

che-dashboard

リポジトリ取得

クローンしてビルドするだけ。

cd $WORKDIR
git clone --depth 1 https://github.com/eclipse-che/che-dashboard.git
cd che-dashboard

che-dashboard のビルド

docker buildx build --platform linux/arm64 . -f build/dockerfiles/Dockerfile -t mikoto2000/che-dashboard:arm64

Docker イメージのプッシュ

docker push mikoto2000/che-dashboard:arm64

Eclipse Che デプロイ

ここからは、 Ampere A1 VM 上で作業する。

ARM 対応していないイメージへの対応

qemu-user-static をインストールすることで、 amd64 のイメージも、 QEMU 上で実行してくれるようになる。

sudo apt update
sudo apt install -y qemu-user-static

リポジトリ取得

git clone --depth 1 -b 7.45.0 https://github.com/eclipse-che/che-server.git
cd che-server/deploy/kubernetes/helm/che/

イメージ名を修正

diff --git a/deploy/kubernetes/helm/che/custom-charts/che-devfile-registry/values.yaml b/deploy/kubernetes/helm/che/custom-charts/che-devfile-registry/values.yaml
index 6e84ca680e..6a3fbc7401 100644
--- a/deploy/kubernetes/helm/che/custom-charts/che-devfile-registry/values.yaml
+++ b/deploy/kubernetes/helm/che/custom-charts/che-devfile-registry/values.yaml
@@ -12,7 +12,7 @@ global:
     class: "nginx"

 cheDevfileRegistry:
-  image: quay.io/eclipse/che-devfile-registry:next
+  image: mikoto2000/che-devfile-registry:arm64
   imagePullPolicy: Always
   memoryLimit: 256Mi
   memoryRequests: 16Mi
diff --git a/deploy/kubernetes/helm/che/custom-charts/che-keycloak/values.yaml b/deploy/kubernetes/helm/che/custom-charts/che-keycloak/values.yaml
index a192f56a24..6881844402 100644
--- a/deploy/kubernetes/helm/che/custom-charts/che-keycloak/values.yaml
+++ b/deploy/kubernetes/helm/che/custom-charts/che-keycloak/values.yaml
@@ -19,9 +19,9 @@ global:
     serverTrustStoreConfigMapName: ""
   # Image used by endpoint watcher (postgres)
   endpointWatcher:
-    image: quay.io/eclipse/che-endpoint-watcher:nightly
+    image: mikoto2000/che-endpoint-watcher:arm64

-image: quay.io/eclipse/che-keycloak:nightly
+image: mikoto2000/che-keycloak:arm64

 ## Admin credentials configuration
 # Manually define them in clear
diff --git a/deploy/kubernetes/helm/che/custom-charts/che-plugin-registry/values.yaml b/deploy/kubernetes/helm/che/custom-charts/che-plugin-registry/values.yaml
index 3fd3b90f8a..f75b524d57 100644
--- a/deploy/kubernetes/helm/che/custom-charts/che-plugin-registry/values.yaml
+++ b/deploy/kubernetes/helm/che/custom-charts/che-plugin-registry/values.yaml
@@ -12,7 +12,7 @@ global:
     class: "nginx"

 chePluginRegistry:
-  image: quay.io/eclipse/che-plugin-registry:next
+  image: mikoto2000/che-plugin-registry:arm64
   imagePullPolicy: Always
   memoryLimit: 256Mi
   memoryRequests: 16Mi
diff --git a/deploy/kubernetes/helm/che/custom-charts/che-postgres/values.yaml b/deploy/kubernetes/helm/che/custom-charts/che-postgres/values.yaml
index 4e68228059..65168d2e67 100644
--- a/deploy/kubernetes/helm/che/custom-charts/che-postgres/values.yaml
+++ b/deploy/kubernetes/helm/che/custom-charts/che-postgres/values.yaml
@@ -10,4 +10,4 @@
 # Default values for postgres.
 # This is a YAML-formatted file.
 # Declare variables to be passed into your templates.
-image: quay.io/eclipse/che-postgres:next
+image: mikoto2000/che-postgres:arm64
diff --git a/deploy/kubernetes/helm/che/values.yaml b/deploy/kubernetes/helm/che/values.yaml
index dea4689a5b..9ea49edc02 100644
--- a/deploy/kubernetes/helm/che/values.yaml
+++ b/deploy/kubernetes/helm/che/values.yaml
@@ -21,7 +21,7 @@ cheWorkspaceNoProxy: ""
 #    operator: "Equal"
 #    value: "aValue"
 #    effect: "NoExecute"
-cheImage: quay.io/eclipse/che-server:next
+cheImage: mikoto2000/che-server:arm64
 cheImagePullPolicy: Always
 cheKeycloakRealm: "che"
 cheKeycloakClientId: "che-public"
@@ -50,7 +50,7 @@ global:
   cheHost: ""
   # Image used by endpoint watchers
   endpointWatcher:
-    image: quay.io/eclipse/che-endpoint-watcher:next
+    image: mikoto2000/che-endpoint-watcher:arm64
   # Use internal cluster svc names to communicate between components
   useInternalClusterSVCNames: true

@@ -129,7 +129,7 @@ che:
   logLevel: "INFO"

 dashboard:
-  image: quay.io/eclipse/che-dashboard:next
+  image: mikoto2000/che-dashboard:arm64
   imagePullPolicy: "Always"
   memoryRequest: 16Mi
   memoryLimit: 256Mi

デプロイ

helm dependency update
helm upgrade --install che --namespace che --create-namespace --set global.ingressDomain=140-83-80-200.nip.io ./

しばらく待つと、一通りの Pod が Running になっているのが確認できる。

ubuntu@eclipse-che:~$ ubuntu@eclipse-che:~$ kubectl get pod -nche
NAME                                READY   STATUS    RESTARTS   AGE
che-599ddc4c4c-6p2r7                1/1     Running   0          2m33s
che-dashboard-575588559f-plr4q      1/1     Running   0          41m
devfile-registry-6c68bb7858-drztk   1/1     Running   0          41m
keycloak-6455687696-vjg4j           1/1     Running   0          41m
plugin-registry-7f7bb8d6d4-rx8hn    1/1     Running   0          41m
postgres-5b8856f9b9-zfkkl           1/1     Running   0          41m

その他

「Che が提供するほとんどのスタックは、QEMU がセグフォ吐いて死ぬ」についての関連ツイート。

参考資料

付録

che-theia のビルド挑戦メモ

以下て順で arm64 のビルドを行ったが、ワークスペース作成時に例外を吐いてロード画面から進まなくなる。

コンテナ起動

che-theia は、ubuntu:20.04 コンテナを起動してビルドする。

docker run -it --rm -v "/var/run/docker.sock:/var/run/docker.sock" arm64v8/ubuntu:20.04 bash

ビルド環境構築

# Docker
apt update
apt install -y curl gpg
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
    | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" \
    | tee /etc/apt/sources.list.d/docker.list > /dev/null

apt-get update \
    && apt-get -y install \
        docker-ce \
        docker-ce-cli \
        containerd.io

# node
apt update
apt-get install -y build-essential curl git pkg-config libsecret-1-dev
curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs
npm install -g yarn

リポジトリの取得

cd $WORKDIR
git clone --depth 1 https://github.com/eclipse-che/che-theia.git
cd che-theia

Docker イメージのビルド

# `docker build` を `docker buildx` に修正する。
export GITHUB_TOKEN=<GitHub のパーソナルアクセストークン、これが無いとプラグインの組み込み()に失敗してビルドができない、とりあえず全リード権限を与えた>
export SKIP_LINT=true
export SKIP_TEST=true
export SKIP_FORMAT=true
./build.sh --organization:mikoto2000 --tag:arm64 --skip-tests

2022年4月13日水曜日

Oracle Cloud Free Tier の Ampere A1 VM(ARM VM) に Kubernetes をインストールする (minikube 版)

Oracle Cloud Free Tier の Ampere A1 VM(ARM VM) に Kubernetes をインストールする - mikoto2000 の日記 では、 kubeadm を直接使って Kubernetes をインストールしたが、Eclipse Che を動かすのに minikune の方が都合が良かったのでそちらでの構築を行う。

kubeadm、kubelet、kubectl のインストール

iptablesがブリッジを通過するトラフィックを処理できるようにする

sudo modprobe br_netfilter
cat | sudo tee /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

sudo sysctl --system

iptablesがnftablesバックエンドを使用しないようにする

sudo apt-get update
sudo apt-get install -y iptables arptables ebtables

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
sudo update-alternatives --set arptables /usr/sbin/arptables-legacy
sudo update-alternatives --set ebtables /usr/sbin/ebtables-legacy

ポート設定

sudo vi /etc/iptables/rules.v4

差分は以下の通り。

--- /etc/iptables/rules.v4      2022-03-03 19:28:40.279059992 +0000
+++ ./rules.v4  2022-03-30 23:11:47.310270150 +0000
@@ -14,8 +14,15 @@
 -A INPUT -i lo -j ACCEPT
 -A INPUT -p udp --sport 123 -j ACCEPT
 -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
--A INPUT -j REJECT --reject-with icmp-host-prohibited
--A FORWARD -j REJECT --reject-with icmp-host-prohibited
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT -m comment --comment "http"
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT -m comment --comment "https"
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 6443 -j ACCEPT -m comment --comment "Kubernetes API server"
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 2379 -j ACCEPT -m comment --comment "etcd server client API"
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 2380 -j ACCEPT -m comment --comment "etcd server client API"
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 10250 -j ACCEPT -m comment --comment "Kubelet API"
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 10251 -j ACCEPT -m comment --comment "kube-scheduler"
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 10252 -j ACCEPT -m comment --comment "kube-controller-manager"
+-A INPUT -p tcp -m state --state NEW -m tcp --match multiport --dports 30000:32767 -j ACCEPT -m comment --comment "NodePort Service"
 -A OUTPUT -d 169.254.0.0/16 -j InstanceServices
 -A InstanceServices -d 169.254.0.2/32 -p tcp -m owner --uid-owner 0 -m tcp --dport 3260 -m comment --comment "See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or rem
oving this rule" -j ACCEPT
 -A InstanceServices -d 169.254.2.0/24 -p tcp -m owner --uid-owner 0 -m tcp --dport 3260 -m comment --comment "See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or rem
oving this rule" -j ACCEPT

変更したルールを適用。

sudo iptables-restore < /etc/iptables/rules.v4

Docker のインストール

必要な設定の追加

# 必須モジュールのロード
cat | sudo tee /etc/modules-load.d/containerd.conf <<EOF
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo modprobe br_netfilter

# 必要なカーネルパラメータの設定・設定値永続化
cat | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf <<EOF
net.bridge.bridge-nf-call-iptables  = 1
net.ipv4.ip_forward                 = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF

sudo sysctl --system

docker パッケージインストール

sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg \
    | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" \
    | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update \
    && sudo apt-get -y install \
        docker-ce \
        docker-ce-cli \
        containerd.io

kubeadm、kubelet、kubectl パッケージのインストール

まだ kubernetes-focal は無いようなので kubernetes-xenial を使用する。

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

kubelet 再起動

sudo systemctl daemon-reload
sudo systemctl restart kubelet

minikube による Kubernetes の構築

minikube のダウンロード

minikube start | minikube から minikube のバイナリをダウンロードする。

今回は、 Linux, ARM64, Stable, Debian package で進める。

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_arm64.deb
sudo dpkg -i minikube_latest_arm64.deb

minikube の起動

minikube start コマンドで構築。

sudo minikube start --driver=none
  • --driver=none: 仮想化を使わず、ホストに直接構築する

kubectl から接続できるようにする

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

minikube による Ingress のデプロイ

アドオンがあるので、それを有効にする。

sudo minikube addons enable ingress

動作確認

前前回, 前回 を参照。

参考資料