Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

GitHub Actions ジョブを実行する

PFCP では、クラスタ上で GitHub Actions ジョブを実行できます。 クラスタ上のリソースを活用した CI/CD パイプラインの構築が可能です。

GitHub Actions ジョブを実行する手段として、PFCP では Actions Runner Controller (ARC) を提供しています。 ARC を利用することで、GitHub Actions ジョブを実行するためのセルフホスト型ランナーをクラスタ上にデプロイできます。

以下では、ARC を利用した GitHub Actions ジョブの実行方法を紹介します。

セルフホスト型ランナーの構成

まず、以下の手順にしたがい、クラスタ上にセルフホスト型ランナーを構成します。 ランナーの個数は、キューに積まれたジョブの数におうじて自動でスケーリングします。

  1. GitHub App を作成し、対象リポジトリにインストールします。また、GitHub App の認証情報を格納した Kubernetes Secret を作成します。

  2. クラスタに AutoscalingRunnerSet リソースを作成します。例を以下に示します。

    apiVersion: actions.github.com/v1alpha1
    kind: AutoscalingRunnerSet
    metadata:
      name: NAME
    spec:
      githubConfigUrl: https://github.com/ORG/REPO # ランナーを登録するリポジトリ
      githubConfigSecret: SECRET_NAME # 1 で作った Secret の名前
      runnerScaleSetName: RUNNER_NAME # GitHub Actions ジョブの "runs-on" で指定することになる名前
      # Runner の自動スケーリング設定
      minRunners: 0
      maxRunners: 20
      # Runner pod のテンプレート
      template:
        spec:
          containers:
          - name: runner
            image: ghcr.io/actions/actions-runner
            command:
            - /home/runner/run.sh
            # リソース量は実行したいジョブに合わせて調整してください
            resources:
              requests:
                cpu: 100m
              limits:
                memory: 256Mi
    

    Note

    AutoscalingRunnerSet リソースの app.kubernetes.io/version ラベルと .spec.listenerTemplate フィールドは自動で設定されます。 存在する場合は上書きされます。

GitHub Actions ジョブでの利用

作成したセルフホスト型ランナーを GitHub Actions ジョブで利用するには、以下の手順を実行します。

  1. ジョブの runs-on プロパティに、AutoscalingRunnerSet の runnerScaleSetName に設定した名前を指定します。
    jobs:
      build:
        runs-on: RUNNER_NAME
        steps:
        - ...
    

参考

Actions Runner Controller について詳しくは、公式ドキュメントを参照してください。