

# メトリクスエクスポーターを使用して、Amazon EKS および Kubernetes で HAProxy をセットアップする
<a name="ContainerInsights-Prometheus-Sample-Workloads-haproxy"></a>

HAProxy は、オープンソースのプロキシアプリケーションです。詳細については、「[HAProxy](https://www.haproxy.org)」を参照してください。

Fargate 起動タイプのクラスターで HAProxy を実行している場合は、この手順の各ステップを実行する前に Fargate プロファイルを設定する必要があります。プロファイルを設定するには、次のコマンドを入力します。*MyCluster* をクラスターの名前に置き換えます。

```
eksctl create fargateprofile --cluster MyCluster \
--namespace haproxy-ingress-sample --name haproxy-ingress-sample
```

**メトリクスエクスポーターとともに HAProxy をインストールして、Container Insights の Prometheus サポートをテストするには**

1. 次のコマンドを入力して、Helm インキュベーターレポジトリを追加します。

   ```
   helm repo add haproxy-ingress https://haproxy-ingress.github.io/charts
   ```

1. 以下のコマンドを入力して、新しい名前空間を作成します。

   ```
   kubectl create namespace haproxy-ingress-sample
   ```

1. 次のコマンドを入力して、HAProxy をインストールします。

   ```
   helm install haproxy haproxy-ingress/haproxy-ingress \
   --namespace haproxy-ingress-sample \
   --set defaultBackend.enabled=true \
   --set controller.stats.enabled=true \
   --set controller.metrics.enabled=true \
   --set-string controller.metrics.service.annotations."prometheus\.io/port"="9101" \
   --set-string controller.metrics.service.annotations."prometheus\.io/scrape"="true"
   ```

1. 次のコマンドを入力して、サービスの注釈を確認します。

   ```
   kubectl describe service haproxy-haproxy-ingress-metrics -n haproxy-ingress-sample
   ```

   次の注釈が表示されます。

   ```
   Annotations:   prometheus.io/port: 9101
                  prometheus.io/scrape: true
   ```

**HAProxy をアンインストールするには**
+ 以下のコマンドを入力します。

  ```
  helm uninstall haproxy --namespace haproxy-ingress-sample
  kubectl delete namespace haproxy-ingress-sample
  ```