---
title: "APISIX Declarative CLIを使用した宣言的なAPISIX管理 - API7.ai"
description: "新しいAPISIX Declarative CLIを使用して、宣言型設定ファイルでAPISIXを管理するためのガイド。"
url: "https://api7.ai/ja/blog/managing-apisix-declaratively"
---

[Blog](https://api7.ai/ja/blog)

[Products](https://api7.ai/ja/category/products)[Technology](https://api7.ai/ja/category/technology)[Ecosystem](https://api7.ai/ja/category/ecosystem)[Case Study](https://api7.ai/ja/category/usercase)[Team & Community](https://api7.ai/ja/category/community)

Search

⌘ + K

[Blog](https://api7.ai/blog)

Technology

# APISIX Declarative CLIを使用した宣言的なAPISIX管理

[![Navendu Pottekkat](https://avatars.githubusercontent.com/u/49474499?v=4)](https://github.com/pottekkat)

[Navendu Pottekkat](https://github.com/pottekkat)

September 22, 2023

[Technology](https://api7.ai/category/technology)

[APISIX](https://docs.api7.ai/apisix/documentation)のユーザーは、主にAdmin APIを使用してAPISIXを設定します。しかし、設定が複雑になるにつれて、Admin APIのみでこれらを管理することはより困難になります。

これを簡単にするために、APISIXの設定を宣言的に定義できるツールである[APISIX Declarative CLI](https://github.com/api7/adc)、通称ADCを開発しました。

この記事では、ADCを使用してAPISIXの設定を管理する方法を見ていきます。

## APISIXのデプロイ

始める前に、まずAPISIXインスタンスを実行して、それと対話し設定する必要があります。DockerでAPISIXを起動するには、次のコマンドを実行します：

```
curl -sL https://run.api7.ai/apisix/quickstart | sh
```

APISIXの使用方法について詳しくは、[APISIXドキュメント](https://docs.api7.ai/apisix/getting-started)を参照してください。

## ADCのインストール

`go install`コマンドを使用してADCをインストールできます：

```
go install github.com/api7/adc@latest
```

これにより、`adc`バイナリが`$GOPATH/bin`ディレクトリにインストールされます。

これを`$PATH`環境変数に追加することを確認してください：

```
export PATH=$PATH:$GOPATH/bin
```

Goがインストールされていない場合、最新の`adc`バイナリをダウンロードして、以下のように`/bin`フォルダに追加することもできます：

```
wget https://github.com/api7/adc/releases/download/v0.2.0/adc_0.2.0_linux_amd64.tar.gz
tar -zxvf adc_0.2.0_linux_amd64.tar.gz
mv adc /usr/local/bin/adc
```

他のオペレーティングシステム用のバイナリは、[リリースページ](https://github.com/api7/adc/releases/tag/v0.2.0)で見つけることができます。将来的には、これらのバイナリはHomebrewなどのパッケージマネージャーで公開される予定です。

`adc`がインストールされているか確認するには、次のコマンドを実行します：

```
adc --help
```

すべてが正常であれば、利用可能なサブコマンドとその使用方法のリストが表示されます。

## APISIXインスタンスでのADCの設定

デプロイされたAPISIXインスタンスでADCを動作させるために、次のコマンドを実行します：

```
adc configure
```

これにより、APISIXサーバーのアドレス（'[http://127.0.0.1:9180'）とトークンを入力するように促されます。](http://127.0.0.1:9180'%EF%BC%89%E3%81%A8%E3%83%88%E3%83%BC%E3%82%AF%E3%83%B3%E3%82%92%E5%85%A5%E5%8A%9B%E3%81%99%E3%82%8B%E3%82%88%E3%81%86%E3%81%AB%E4%BF%83%E3%81%95%E3%82%8C%E3%81%BE%E3%81%99%E3%80%82)

すべてが正しければ、以下のようなメッセージが表示されます：

```
ADC configured successfully!
Connected to APISIX successfully!
```

APISIXとの接続を確認するために、いつでも`ping`サブコマンドを使用できます：

```
adc ping
```

## APISIX設定ファイルの検証

トラフィックをアップストリームに転送するルートを含む基本的なAPISIX設定を作成しましょう：

```
name: "Basic configuration"
version: "1.0.0"
services:
  - name: httpbin-service
    hosts:
      - api7.ai
    upstream:
      name: httpbin
      nodes:
        - host: httpbin.org
          port: 80
          weight: 1
routes:
  - name: httpbin-route
    service_id: httpbin-service
    uri: "/anything"
    methods:
      - GET
```

ADCが実行中のAPISIXインスタンスに接続されたら、設定を適用する前にこれを検証するために次のコマンドを実行できます：

```
adc validate -f config.yaml
```

設定が有効であれば、次のような応答が返されます：

```
Read configuration file successfully: config name: Basic configuration, version: 1.0.0, routes: 1, services: 1.
Successfully validated configuration file!
```

## APISIXインスタンスへの設定の同期

有効な設定を接続されたAPISIXインスタンスと同期するために、ADCを使用できます。これを行うには、次のコマンドを実行します：

```
adc sync -f config.yaml
```

これにより、設定ファイルで宣言した通りにルートとサービスが作成されます：

```
creating service: "httpbin-service"
creating route: "httpbin-route"
Summary: created 2, updated 0, deleted 0
```

ルートが正しく作成されたか確認するために、リクエストを送信してみましょう：

```
curl localhost:9080/anything -H "host:api7.ai"
```

すべてが正しければ、[httpbin.org](https://httpbin.org/)からの応答が返されます。

## ローカルと実行中の設定の比較

次に、`config.yaml`ファイルのローカル設定を更新して、別のルートを追加します：

```
name: "Basic configuration"
version: "1.0.0"
services:
  - name: httpbin-service
    hosts:
      - api7.ai
    upstream:
      name: httpbin
      nodes:
        - host: httpbin.org
          port: 80
          weight: 1
routes:
  - name: httpbin-route-anything
    service_id: httpbin-service
    uri: "/anything"
    methods:
      - GET
  - name: httpbin-route-ip
    service_id: httpbin-service
    uri: "/ip"
    methods:
      - GET
```

この設定をAPISIXと同期する前に、ADCを使用して既存のAPISIX設定との違いを確認できます。これを行うには、次のコマンドを実行します：

```
adc diff -f config.yaml
```

設定の追加や削除を確認し、適用する前に何が変更されたかを理解できます。

## OpenAPI定義からAPISIX設定への変換

ADCは、OpenAPI定義を扱う基本的なサポートも提供しています。ADCを使用して、[OpenAPI形式](https://spec.openapis.org/oas/v3.0.0)の定義をAPISIX設定に変換できます。

例えば、以下のようにOpenAPI形式でAPIをドキュメント化している場合：

```
openapi: 3.0.0
info:
  title: httpbin API
  description: Routes for httpbin API
  version: 1.0.0
servers:
  - url: http://httpbin.org
paths:
  /anything:
    get:
      tags:
        - default
      summary: Returns anything that is passed in the request data
      operationId: getAnything
      parameters:
        - name: host
          in: header
          schema:
            type: string
          example: "{{host}}"
      responses:
        "200":
          description: Successfully return anything
          content:
            application/json: {}
  /ip:
    get:
      tags:
        - default
      summary: Returns the IP address of the requester
      operationId: getIP
      responses:
        "200":
          description: Successfully return IP
          content:
            application/json: {}
```

`openapi2apisix`サブコマンドを使用して、これをAPISIX設定に変換できます：

```
adc openapi2apisix -o config.yaml -f openAPI.yaml
```

これにより、以下のような設定ファイルが作成されます：

```
name: ""
routes:
- desc: Returns anything that is passed in the request data
  id: ""
  methods:
  - GET
  name: getAnything
  uris:
  - /anything
- desc: Returns the IP address of the requester
  id: ""
  methods:
  - GET
  name: getIP
  uris:
  - /ip
services:
- desc: Routes for httpbin API
  id: ""
  name: httpbin API
  upstream:
    id: ""
    name: ""
    nodes: null
version: ""
```

ご覧の通り、設定は不完全で、まだ多くの設定を手動で追加する必要があります。ADCを改善して、OpenAPI定義とAPISIX設定に直接マッピングできるものとの間のギャップを埋めることを目指しています。

## ヒント：オートコンプリートの使用

ADCでは多くのことができ、機能のリストは増え続けています。サブコマンドの使用方法を学ぶには、`--help`または`-h`フラグを使用できます。これにより、サブコマンドのドキュメントが表示されます。

さらに簡単にするために、`completion`サブコマンドを使用してシェル環境のオートコンプリートスクリプトを生成できます。例えば、zshシェルを使用している場合、次のコマンドを実行します：

```
adc completion zsh
```

その後、出力を`.zshrc`ファイルにコピー＆ペーストすると、`adc`を使用する際にヒントが表示されるようになります。

ADCはまだ初期段階にあり、継続的に改善されています。プロジェクトについて詳しく知りたい、バグを報告したい、または機能を提案したい場合は、[github.com/api7/adc](https://github.com/api7/adc)を訪れてください。

Tags:

[APISIX configuration](https://api7.ai/tags/apisix-configuration)

[Declarative configuration](https://api7.ai/tags/declarative-configuration)

[CLI](https://api7.ai/tags/cli)

Share article link

Share

Related Posts

[![実世界におけるAPIゲートウェイの選定：技術評価プロセスの内側](https://static.api7.ai/uploads/2025/06/03/E7OqOddo_api-gateway-decision.webp)](https://api7.ai/blog/api-gateway-decision-inside-technical-evaluation)

## [実世界におけるAPIゲートウェイの選定：技術評価プロセスの内側](https://api7.ai/blog/api-gateway-decision-inside-technical-evaluation)

[![2025年Kong最新定价解析与最佳Kong替代方案](https://static.api7.ai/uploads/2025/03/10/FKRWNsq8_2025-kong-pricing.webp)](https://api7.ai/blog/kong-konnect-pricing)

## [2025年Kong最新定价解析与最佳Kong替代方案](https://api7.ai/blog/kong-konnect-pricing)

Table of Contents

- [APISIXのデプロイ](#apisix%E3%81%AE%E3%83%87%E3%83%97%E3%83%AD%E3%82%A4)
- [ADCのインストール](#adc%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB)
- [APISIXインスタンスでのADCの設定](#apisix%E3%82%A4%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%B3%E3%82%B9%E3%81%A7%E3%81%AEadc%E3%81%AE%E8%A8%AD%E5%AE%9A)
- [APISIX設定ファイルの検証](#apisix%E8%A8%AD%E5%AE%9A%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E6%A4%9C%E8%A8%BC)
- [APISIXインスタンスへの設定の同期](#apisix%E3%82%A4%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%B3%E3%82%B9%E3%81%B8%E3%81%AE%E8%A8%AD%E5%AE%9A%E3%81%AE%E5%90%8C%E6%9C%9F)
- [ローカルと実行中の設定の比較](#%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E3%81%A8%E5%AE%9F%E8%A1%8C%E4%B8%AD%E3%81%AE%E8%A8%AD%E5%AE%9A%E3%81%AE%E6%AF%94%E8%BC%83)
- [OpenAPI定義からAPISIX設定への変換](#openapi%E5%AE%9A%E7%BE%A9%E3%81%8B%E3%82%89apisix%E8%A8%AD%E5%AE%9A%E3%81%B8%E3%81%AE%E5%A4%89%E6%8F%9B)
- [ヒント：オートコンプリートの使用](#%E3%83%92%E3%83%B3%E3%83%88%E3%82%AA%E3%83%BC%E3%83%88%E3%82%B3%E3%83%B3%E3%83%97%E3%83%AA%E3%83%BC%E3%83%88%E3%81%AE%E4%BD%BF%E7%94%A8)

## Related Posts

[![HTTP/3がAPIデバッグを変える：終端点で観測する](https://static.api7.ai/uploads/2026/11/17/ofz6Efrg_http3-api-observability.webp)](https://api7.ai/ja/blog/http3-api-observability)

Technology

November 17, 2026

#### [HTTP/3がAPIデバッグを変える：終端点で観測する](https://api7.ai/ja/blog/http3-api-observability)

QUICトランスポート、プロトコル終端、ゲートウェイポリシー、サービス動作を分離してHTTP/3 APIをデバッグし、すべてのホップにわたるテレメトリーを相関させます。

[API Observability](https://api7.ai/tags/api-observability)

[HTTP/3](https://api7.ai/tags/http/3)

[QUIC](https://api7.ai/tags/quic)

[![短縮リンクはリダイレクト API：安全な廃止に向けて設計する](https://static.api7.ai/uploads/2026/11/19/NvwMhDhH_short-link-cover-fixed.svg)](https://api7.ai/ja/blog/short-link-redirect-security)

Technology

November 17, 2026

#### [短縮リンクはリダイレクト API：安全な廃止に向けて設計する](https://api7.ai/ja/blog/short-link-redirect-security)

短縮リンクを本番環境のリダイレクト API として扱い、所有ドメイン、宛先ポリシー、ステータスコード、監視、再利用できない廃止状態を管理します。

[API Security](https://api7.ai/tags/api-security)

[API Lifecycle](https://api7.ai/tags/api-lifecycle)

[URL Redirects](https://api7.ai/tags/url-redirects)

[![LLMルーティング変更を差分テストする方法](https://static.api7.ai/uploads/2026/11/16/5FzNRmiG_llm-routing-differential-testing.webp)](https://api7.ai/ja/blog/llm-routing-differential-testing)

Technology

November 16, 2026

#### [LLMルーティング変更を差分テストする方法](https://api7.ai/ja/blog/llm-routing-differential-testing)

LLMゲートウェイルーターの動作契約を構築し、新旧の判断を比較して、リトライ、フォールバック、ストリーミング、副作用のリグレッションを検出します。

[AI Gateway](https://api7.ai/tags/ai-gateway)

[LLM Routing](https://api7.ai/tags/llm-routing)

[Testing](https://api7.ai/tags/testing)
