2
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 1 year has passed since last update.

GitLab Runner Kubernetes executorをarm64で構築したときにコケた話

Last updated at Posted at 2022-03-05

おうち Kubernetes クラスターをラズパイで構築して、いざ実運用しようとしたが、 arm64 のイメージがないとお話にならない。。。今までは手元でクロスコンパイルしてたりしたけど毎度それをやるのは手間なので GitLab CI でいい感じに実現したい。 gitlab.com の shared runner は amd64 ぽいので、 Kubernetes クラスター上で GitLab runner も動かしてしまおう、という話です。

環境

  • Raspberry Pi 4B
  • Kubernetes 1.23
  • GitLab 14.9.0-pre (gitlab.com, 2022-03-15 時点)
  • GitLab Runner Helm Chart 0.37.2
    • GitLab runner 14.7.0
  • Helm 3.3.4
  • Helmfile 0.135.0

結論

helmdile.yaml
repositories:
- name: gitlab
  url: https://charts.gitlab.io

releases:
- name: runner
  namespace: gitlab-managed-apps
  chart: gitlab/gitlab-runner
  version: 0.37.2
  installed: true
  values:
    - values.yaml.gotmpl
values.yaml.gotmpl
## REQUIRED VALUES
gitlabUrl: {{ requiredEnv "CI_SERVER_URL" | quote }}
runnerRegistrationToken: {{ requiredEnv "GITLAB_RUNNER_REGISTRATION_TOKEN" | quote }}
rbac:
  create: true
  clusterWideAccess: false
runners:
  image: ubuntu:20.04
  builds: {}
  services: {}
  helpers: {}
  config: |
    [[runners]]
      [runners.kubernetes.node_selector]
        "kubernetes.io/arch" = "arm64"
        "kubernetes.io/os" = "linux"
  tags: kubernetes,cluster,arm64
  privileged: false
resources: {}
docker run --rm --net=host \
  -v "${HOME}/.kube:/root/.kube" -v "${HOME}/.config/helm:/root/.config/helm" -v "${PWD}:/wd" --workdir /wd \
  -e CI_SERVER_URL=https://gitlab.com/ \
  -e GITLAB_RUNNER_REGISTRATION_TOKEN=xxxxxxxxxxxx \
  quay.io/roboll/helmfile:helm3-v0.135.0 helmfile -f helmfile.yaml sync

Gitlab runner の helmfile は GitLab Cluster Management のテンプレ から入手しました。 helmfile の実行コンテナは helmfile のリポジトリに記載の手順 を基にしています。

コケたところ

GitLab Cluster Management のテンプレからほとんど何も変えずに適用したところ、 CI job の pod が一瞬で Init:Error になって終了するというとてもデバッグのしにくい事象に遭遇しました。

ERROR: Job failed (system failure): prepare environment: waiting for pod running: pod status is failed. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

色々調べながら試してみたところ、 helper コンテナが arm64 ではなく amd64 のイメージを使っていることが判明しました。 GitLab runner ドキュメントの node selector の項には以下のようにあります。

Runner additionally uses the information provided to determine the OS and architecture for the build. This ensures that the correct helper image is used. By default, the OS and architecture is assumed to be linux/amd64.
訳) Runner は提供された情報をビルドのための OS とアーキテクチャの決定に加えて使用します。これによって正しい helper image が使われることを確実にします。デフォルトでは、 OS とアーキテクチャは linux/amd64 と推定されます。

ということで arm64 用のサンプルの通りに設定してみたところ、あっさり解決しました :tada:

同じような事象で困っている方の助けになれば幸いです。

参考文献

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