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

おさらい

前回の記事ではk8sでPipeCD環境を構築したので
今回はdocker-composeで構築する

  • 前回の記事

構築

ありがたいことに日本語ガイドが公開されているのでガイドに則って構築する
https://github.com/pipe-cd/tutorial/tree/main/content/ja/30-install

今回のアーキテクチャ図
image.png
参照:インストールガイドより

1. Gitリポジトリのセットアップ

空のリポジトリを作成した後にpushする

# pipecdのチュートリアルのリポジトリをクローン
📁 ~/work ❯ git clone https://github.com/pipe-cd/tutorial.git
Cloning into 'tutorial'...
remote: Enumerating objects: 7642, done.
remote: Counting objects: 100% (42/42), done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 7642 (delta 13), reused 10 (delta 10), pack-reused 7600 (from 2)
Receiving objects: 100% (7642/7642), 27.46 MiB | 22.79 MiB/s, done.
Resolving deltas: 100% (3286/3286), done.
# チュートリアルのリポジトリに移動し、不必要なフィアルを削除する
📁 ~/work ❯ cd tutorial 
📁 ~/work/tutorial ❯ rm -rf .git*
📁 ~/work/tutorial ❯ ls -la | grep git
# 自分のリポジトリにチュートリアルに必要なファイル一式を移動
📁 ~/work/tutorial ❯ cd ../
📁 ~/work ❯ mv tutorial pipetest/
📁 ~/work ❯ cd pipetest 
📁 ~/work/pipetest ❯ ll
total 8
-rw-r--r--  1 XXX  staff   16  8  6 16:24 README.md
drwxr-xr-x  9 XXX  staff  288  8  6 16:27 tutorial

2. Control Planeの構築

docker-composeで起動する

📁 ~/work/pipetest/tutorial/src/install/control-plane ❯ ll
total 8
-rw-r--r--  1 XXX  staff  2177  8  6 16:25 docker-compose.yaml
drwxr-xr-x  5 XXX  staff   160  8  6 16:25 volume
📁 ~/work/pipetest/tutorial/src/install/control-plane ❯ docker-compose up 

起動したら以下のURLにアクセスする
http://localhost:8080

プロジェクトの名前を求められるので以下を入力する

  • プロジェクト名: tutorial

image.png

ユーザー名、パスワードでのログインを求められるので以下を入力する

  • ユーザ名/パスワード: hello-pipecd (どちらも一緒)

image.png

ログインできるとApplicationの画面が表示される

image.png

3. Pipedの構築

Pipedを構築する前にそもそもPipedは何ものなのかを確認しておく
公式ドキュメントを見ると以下の様に記載がある。
https://pipecd.dev/docs-v0.52.x/installation/install-piped/

Since Piped is a stateless agent, no database or storage is required to run. 
In addition, a Piped can interact with one or multiple platform providers, so the number of Piped and where they should run is entirely up to your preference. 
For example, you can run your Pipeds in a Kubernetes cluster to deploy not just Kubernetes applications but your Terraform and Cloud Run applications as well.

要約するとPipedはステートレスなエージェントでDBなどのストレージを必要とせず
マルチプラットフォーム連携できる優秀なエージェントということだ。
ではその優秀なエージェントが何ものなのか知れたので、構築していこう。

まずはPipedのをControle Planeの登録するためのIDを払出していく

以下URLにアクセスしてPipedタブの+ADDをクリックする
http://localhost:8080/settings/piped

任意の名前と説明を入力してSAVEをクリックする
image.png

PipedのIDとKeyが表示される
これは全てメモしておく
image.png

冒頭のGitリポジトリのセットアップでcloneしたディレクトリの中のpipedのディレクトリに移動する

$ cd tutorial/src/install/piped 

pipedを起動する際にkeyファイルが必要となるのでkeyファイルを作成する

$ echo -n <前述の手順で発行したPiped Key> > .pipedKey

piped.yamlを自分の環境に合わせて編集する

  • pipedID: 前述の手順でControl PlaneでPipedを発行した際に出力されたPiped ID
  • pipedKeyFile: 前述の手順で発行した.pipedKeyファイルのパス(絶対パス)
  • remote: リポジトリのセットアップで作成したプライベートリポジトリのURL
  • platformProviders: デプロイ先の環境のコメントアウトを外す

参考までに自分のを載せておく(マスクあり)

$ vi piped.yaml
📁 ~/work/pipetest/tutorial/src/install/piped ❯ cat piped.yaml 
# This is a configuration for running a Piped. See https://pipecd.dev/docs/user-guide/managing-piped/configuration-reference/ for details.
apiVersion: pipecd.dev/v1beta1
kind: Piped
spec:
  apiAddress: localhost:9080
  projectID: tutorial
  pipedID: XXXX-XXXX-XXXX-XXXX-XXXX # [EDIT_HERE] Piped ID is generated on the console.
  pipedKeyFile: /XXX/XXXX/.pipedKey # [EDIT_HERE] The path to the Piped Key file.
  repositories:
    - repoID: tutorial-repo
      remote: https://github.com/XXX/pipetest.git # [EDIT_HERE] The HTTPS URL of your repository.
      branch: main
  syncInterval: 15s
  platformProviders:
    # [EDIT_HERE] Uncomment one of followings:
    
    ## [1] Kubernetes
    # - name: my-kubernetes
    #   type: KUBERNETES
    #   config:
    #     kubeconfigPath: <YOUR_KUBECONFIG_PATH> # Your piped will connect to your cluster with this config.

    ## [2] Google Cloud > Cloud Run
    # - name: my-cloudrun
    #   type: CLOUDRUN
    #   config:
    #     project: <YOUR_GOOGLE_CLOUD_PROJECT> # [EDIT_HERE]
    #     region: <YOUR_GOOGLE_GLOUD_REGION> # [EDIT_HERE]

    ## [3] AWS > ECS
    # - name: my-ecs
    #   type: ECS
    #   config:
    #     region: <YOUR_AWS_REGION> # [EDIT_HERE] e.g. ap-northeast-1
    #     profile: default # Name of your AWS credentials profile.

    ## [4] AWS > Lambda
    # - name: my-lambda
    #   type: LAMBDA
    #   config:
    #     region:  <YOUR_AWS_REGION>  # [EDIT_HERE] e.g. ap-northeast-1
    #     profile: default # Name of your AWS credentials profile.

    # [5] Terraform
    - name: my-terraform
      type: TERRAFORM

Pipedを起動するためにバイナリを取得する
https://github.com/pipe-cd/pipecd/releases/latest

$ curl -Lo ./piped  https://github.com/pipe-cd/pipecd/releases/download/v0.50.1/piped_v0.50.1_${OS}_${CPU}

取得したバイナリに権限をつけて実行する

$ chmod +x ./piped
$ ./piped piped --config-file=./piped.yaml --insecure

Pipedの設定画面に移動する
http://localhost:8080/settings/piped

登録に成功すると🟢のマークが名前の右に表示される
スクリーンショット 2025-08-09 17.56.05.png

4. デプロイテスト

公式にも記載がある通り
pipecdによるデプロイは以下の流れとなる

まずは設定ファイルを編集し編集した設定ファイルをリモートにpushする(今回はプライベートリポジトリ)

📁 ~/work/pipetest/tutorial/src/deploy/terraform/simple ❯ vi main.tf 
📁 ~/work/pipetest/tutorial/src/deploy/terraform/simple ❯ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   main.tf

no changes added to commit (use "git add" and/or "git commit -a")
📁 ~/work/pipetest/tutorial/src/deploy/terraform/simple ❯ git commit -m "modify main.tf"
[main 955f799] modify main.tf
 Committer: XX <XX>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 4 insertions(+)
📁 ~/work/pipetest/tutorial/src/deploy/terraform/simple ❯ git push 
Enumerating objects: 15, done.
Counting objects: 100% (15/15), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 673 bytes | 673.00 KiB/s, done.
Total 8 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To https://github.com/XX/pipetest.git
   fdd5488..955f799  main -> main

プッシュするとPipedがその変更を検知する、Pipedがデプロイを開始する
PipeCDのコンソールで確認するとDeploymentsの画面でrunning状態でデプロイが開始される
スクリーンショット 2025-08-09 20.46.48.png

デプロイが成功したことを確認できる!
スクリーンショット 2025-08-09 20.49.34.png

余談ではあるが登録したアプリは以下の様に監視対象のリポジトリとsync状態にあるかどうかも
定期的にポーリングして監視してくれる仕様となっている
スクリーンショット 2025-08-09 20.59.02.png

最後に

チュートリアルを試して引っかかったことや感じたことをまとめておこうと思う。
PipeCDは使うのは初めてだったが、tutorialを一通り通してみて、Control PlaneとPipedの関連性を確認して、少しながら理解することができた気がする。一番引っかかったのは自分のリポジトリとチュートリアルのリポジトリとの連携だった。自分が試した時点では.gitignoreでTerraform関連のファイル一式が除外される様に公式リポジトリで記載があり。結果としてTerraformのプロバイダーを利用しようとしてもgit status時点で変更が検知されていない現象が発生した。それを解決してからはチュートリアルがサクサク進んだ。
今後試す人がいれば注意してもらいたい次第である。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?