GitLab Runner Operatorをインストールする
Red Hat OpenShiftへのインストール
- プラン: Free、Premium、Ultimate
- 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated
OpenShiftのウェブコンソールで、OperatorHubの安定チャンネルからGitLab Runner Operatorを使用して、Red Hat OpenShift v4以降にGitLab Runnerをインストールします。インストールが完了すると、新しくデプロイされたGitLab Runnerインスタンスを使用して、GitLab CI/CDジョブを実行できます。各CI/CDジョブは、個別のポッドで実行されます。
前提要件
- 管理者権限を持つOpenShift 4.xクラスター
- GitLab Runnerの登録トークン
OpenShift Operatorのインストール
最初に、OpenShift Operatorをインストールする必要があります。
管理者権限を持つユーザーとしてOpenShift UIを開き、サインインします。
左側のペインで、Operators(Operators)、OperatorHub(OperatorHub) の順に選択します。
メインペインのAll Items(All Items)の下で、キーワード
GitLab Runnerを検索します。インストールするには、GitLab Runner Operatorを選択します。
GitLab Runner Operatorの概要ページで、インストールを選択します。
Install Operatorページで、以下を行います:
- Update Channel(Update Channel) で、stable(stable)を選択します。
- Installed Namespace(Installed Namespace)で、目的のネームスペースを選択し、インストールを選択します。
Installed Operatorsページで、GitLab Operatorの準備ができると、ステータスが完了に変わります。
Kubernetesにインストールする
- プラン: Free、Premium、Ultimate
- 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated
OperatorHub.ioの安定チャンネルからGitLab Runner Operatorを使用して、Kubernetes v1.21以降にGitLab Runnerをインストールします。インストールが完了すると、新しくデプロイされたGitLab Runnerインスタンスを使用して、GitLab CI/CDジョブを実行できます。各CI/CDジョブは、個別のポッドで実行されます。
前提要件
- Kubernetes v1.21以降
- Cert manager v1.7.1
Kubernetes Operatorのインストール
OperatorHub.ioの手順に従ってください。
- 前提条件をインストールします。
- 右上にあるインストールを選択し、指示に従って
olmとOperatorをインストールします。
GitLab Runnerをインストールする
Runner認証トークンを取得します。次のいずれかの方法があります:
GitLab Runnerトークンでシークレットファイルを作成します:
cat > gitlab-runner-secret.yml << EOF apiVersion: v1 kind: Secret metadata: name: gitlab-runner-secret type: Opaque # Only one of the following fields can be set. The Operator fails to register the runner if both are provided. # NOTE: runner-registration-token is deprecated and will be removed in GitLab 18.0. You should use runner-token instead. stringData: runner-token: REPLACE_ME # your project runner token # runner-registration-token: "" # your project runner secret EOF実行して、クラスターに
secretシークレットを作成します:kubectl apply -f gitlab-runner-secret.ymlカスタムリソース定義(CRD)ファイルを作成し、次の設定を含めます。
cat > gitlab-runner.yml << EOF apiVersion: apps.gitlab.com/v1beta2 kind: Runner metadata: name: gitlab-runner spec: gitlabUrl: https://gitlab.example.com buildImage: alpine token: gitlab-runner-secret EOFコマンドを実行して、
CRDファイルを適用します:kubectl apply -f gitlab-runner.ymlGitLab Runnerがインストールされていることを確認するには、次を実行します:
kubectl get runner NAME AGE gitlab-runner 5mRunnerポッドも表示されるはずです:
kubectl get pods NAME READY STATUS RESTARTS AGE gitlab-runner-bf9894bdb-wplxn 1/1 Running 0 5m
OpenShift用の他のバージョンのGitLab Runner Operatorをインストールします。
Red Hat OperatorHubで利用可能なGitLab Runner Operatorのバージョンを使用したくない場合は、別のバージョンをインストールできます。
公式に利用可能なOperatorのバージョンを確認するには、gitlab-runner-operatorリポジトリのタグを表示します。Operatorが実行しているGitLab Runnerのバージョンを確認するには、目的のコミットまたはタグのAPP_VERSIONファイルの内容(例:https://gitlab.com/gitlab-org/gl-openshift/gitlab-runner-operator/-/blob/1-17-stable/APP_VERSION)を表示します。
特定のバージョンをインストールするには、このcatalogsource.yamlファイルを作成し、<VERSION>をタグまたは特定のコミットに置き換えます:
特定のコミットのイメージを使用する場合、タグ形式はv0.0.1-<COMMIT>です。例: registry.gitlab.com/gitlab-org/gl-openshift/gitlab-runner-operator/gitlab-runner-operator-catalog-source:v0.0.1-f5a798af。
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: gitlab-runner-catalog
namespace: openshift-marketplace
spec:
sourceType: grpc
image: registry.gitlab.com/gitlab-org/gl-openshift/gitlab-runner-operator/gitlab-runner-operator-catalog-source:<VERSION>
displayName: GitLab Runner Operators
publisher: GitLab Community次を使用してCatalogSourceを作成します:
oc apply -f catalogsource.yaml1分以内に、新しいRunnerがOpenShiftクラスターのOperatorHubセクションに表示されるはずです。
オフライン環境のKubernetesクラスターにGitLab Runner Operatorをインストールする
前提要件:
- インストールプロセスに必要なイメージにアクセスできること。
インストール中にコンテナイメージをプルするには、GitLab Runner Operatorは、外部ネットワーキング上のパブリックインターネットへの接続を必要とします。オフライン環境にKubernetesクラスターがインストールされている場合は、ローカルイメージレジストリまたはパッケージリポジトリを使用して、インストール中にイメージまたはパッケージをプルできます。
ローカルリポジトリは、次のイメージを提供する必要があります:
| 画像 | デフォルト値 |
|---|---|
| GitLab Runner Operator(GitLab Runner Operator)イメージ | registry.gitlab.com/gitlab-org/gl-openshift/gitlab-runner-operator/gitlab-runner-operator:vGITLAB_RUNNER_OPERATOR_VERSION |
| GitLab Runner(GitLab Runner)イメージとGitLab Runner Helper(GitLab Runner Helper)イメージ | これらのイメージはRunnerカスタムリソースのインストール時にGitLab Runner UBIイメージレジストリからダウンロードされ、使用されます。使用されるバージョンは要件によって異なります。 |
| RBAC Proxy(RBAC Proxy)イメージ | registry.gitlab.com/gitlab-org/gl-openshift/gitlab-runner-operator/openshift4/ose-kube-rbac-proxy:v4.13.0 |
ダウンロードしたソフトウェアパッケージとコンテナイメージをホストするために、切断されたネットワーク環境にローカルリポジトリまたはレジストリを設定します。次を使用できます:
- コンテナイメージ用のDockerレジストリ。
- Kubernetesバイナリと依存関係用のローカルパッケージレジストリ。
GitLab Runner Operator v1.23.2以降の場合、
operator.k8s.yamlファイルの最新バージョンをダウンロードします:curl -O "https://gitlab.com/gitlab-org/gl-openshift/gitlab-runner- operator/-/releases/vGITLAB_RUNNER_OPERATOR_VERSION/downloads/operator.k8s.yaml"operator.k8s.yamlファイルで、次のURLを更新します:GitLab Runner Operator imageRBAC Proxy image
更新されたバージョンの
operator.k8s.yamlファイルをインストールします:kubectl apply -f PATH_TO_UPDATED_OPERATOR_K8S_YAML GITLAB_RUNNER_OPERATOR_VERSION = 1.23.2+
Operatorのアンインストール
Red Hat OpenShiftでのアンインストール
Runner
CRDの削除:kubectl delete -f gitlab-runner.ymlsecretを削除:kubectl delete -f gitlab-runner-secret.ymlRed HatドキュメントのWebコンソールを使用したクラスターからのOperatorの削除の手順に従ってください。
Kubernetesからアンインストール
Runner
CRDの削除:kubectl delete -f gitlab-runner.ymlsecretを削除:kubectl delete -f gitlab-runner-secret.ymlOperatorのサブスクリプションを削除します:
kubectl delete subscription my-gitlab-runner-operator -n operatorsインストールされている
CSVのバージョンを確認します:kubectl get clusterserviceversion -n operators NAME DISPLAY VERSION REPLACES PHASE gitlab-runner-operator.v1.7.0 GitLab Runner 1.7.0 SucceededCSVを削除します:kubectl delete clusterserviceversion gitlab-runner-operator.v1.7.0 -n operators
設定
OpenShiftでGitLab Runnerを設定するには、OpenShiftでのGitLab Runnerの設定ページを参照してください。
モニタリング
GitLab Runner Operatorデプロイのモニタリングとメトリクス収集を有効にするには、GitLab Runner Operatorを監視しますを参照してください。


