LoginSignup
0
0

More than 1 year has passed since last update.

actions-runner-controllerを試してみる

Last updated at Posted at 2023-01-15

kubernetes上でself hosted runnerが動かせるみたい。docker in kubernetesだったら欲しいので試してみる。

結果、最強でした。

quick start

1. cert-manager を入れる

また後で調べることにして、とりあえず getting-start にある通りインストールする。

🎐 ❯ kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml

2. ARC を入れる

2023-01-15時点の最新は v0.26.0

🎐 ❯ kubectl apply -f https://github.com/actions/actions-runner-controller/releases/download/v0.26.0/actions-runner-controller.yaml
...
Error from server (Invalid): error when creating "https://github.com/actions/actions-runner-controller/releases/download/v0.26.0/actions-runner-controller.yaml": CustomResourceDefinition.apiextensions.k8s.io "runnerdeployments.actions.summerwind.dev" is invalid: metadata.annotations: Too long: must have at most 262144 bytes
Error from server (Invalid): error when creating "https://github.com/actions/actions-runner-controller/releases/download/v0.26.0/actions-runner-controller.yaml": CustomResourceDefinition.apiextensions.k8s.io "runnerreplicasets.actions.summerwind.dev" is invalid: metadata.annotations: Too long: must have at most 262144 bytes
Error from server (Invalid): error when creating "https://github.com/actions/actions-runner-controller/releases/download/v0.26.0/actions-runner-controller.yaml": CustomResourceDefinition.apiextensions.k8s.io "runners.actions.summerwind.dev" is invalid: metadata.annotations: Too long: must have at most 262144 bytes

too long はサーバー側デプロイをすれば問題なく通るはずなので、一旦削除してから入れ直す。

🎐 ❯ kubectl delete -f https://github.com/actions/actions-runner-controller/releases/download/v0.26.0/actions-runner-controller.yaml
🎐 ❯ kubectl apply --server-side -f https://github.com/actions/actions-runner-controller/releases/download/v0.26.0/actions-runner-controller.yaml
...
Error from server (Forbidden): deployments.apps "controller-manager" is forbidden: unable to create new content in namespace actions-runner-system because it is being terminated
Error from server (Forbidden): certificates.cert-manager.io "serving-cert" is forbidden: unable to create new content in namespace actions-runner-system because it is being terminated
Error from server (Forbidden): issuers.cert-manager.io "selfsigned-issuer" is forbidden: unable to create new content in namespace actions-runner-system because it is being terminated

🎐 ❯ kubectl apply --server-side  -f https://github.com/actions/actions-runner

エラーが出たけど、これは削除即追加の時のエラーっぽい。そもそも削除する必要もなかったか。

PATが必要なので作って登録する。
試しに repo:* と workflow をつけてみた。

追記: このページ によると repo:* だけで大丈夫そう

🎐 ❯ kubectl create secret generic controller-manager \
    -n actions-runner-system \
    --from-literal=github_token=REPLACE_YOUR_TOKEN_HERE

3. runner を作成する

self-host-runner/runner-deployment.yaml に作成した。

runner-deployment.yaml
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: runner-rec-adio
spec:
  replicas: 1
  template:
    spec:
      repository: sun-yryr/Rec-adio
🎐 ❯ kubectl apply -f self-host-runner/runner-deployment.yaml
Error from server (InternalError): error when creating "self-host-runner/runner-deployment.yaml": Internal error occurred: failed calling webhook "validate.runnerdeployment.actions.summerwind.dev": failed to call webhook: Post "https://webhook-service.actions-runner-system.svc:443/validate-actions-summerwind-dev-v1alpha1-runnerdeployment?timeout=10s": x509: certificate signed by unknown authority

デフォルトの場合、namespaceを actions-runner-system にしないと証明書関連で落ちちゃうのか。下記のyamlなら通る。

runner-deployment.yaml
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: runner-rec-adio
  namespace: actions-runner-system
spec:
  replicas: 1
  template:
    spec:
      repository: sun-yryr/Rec-adio

出てきた!
スクリーンショット 2023-01-15 19.40.04.png

軽く調査

  • runnerとdockerの2つのコンテナが動いている。
  • runner内ではdockerコマンドが利用できる。おそらくdockerコンテナの方のdockerソケットを見ている気がする。
  • 動かしてみたところ、ワークフローが1つ終わる(正常 or 異常)ごとにコンテナをリセットしている。最強
    • 同時に発生するワークフローは待ち時間が長くなってしまうので、スケーリング を設定した方が良さそう。
  • しばらくワークフロー発生させてたら勝手にpod2つになった(すぐ消えたので、ローリングアップデート的処理で2つ生える時間なだけだったかもしれない)
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