Amazon EC2 を使用したベアメタル K8s での PSA の設定

次のように、Amazon EC2 を使用して、ベアメタル K8s での Web モニタリング PSA と API モニタリング PSA を設定します。既存の Kubernetes クラスタで PSA を設定する場合は、「Kubernetes クラスタの作成」セクションをスキップします。

  1. Kubernetes クラスタを作成します
  2. Docker イメージをプルします
  3. Minikube の Docker デーモンにイメージを保存します。
  4. Web モニタリング PSA と API モニタリング PSA を展開します。
  5. Kubernetes クラスタをモニターします
注: ほとんどの手順は、Web モニタリング PSA と API モニタリング PSA の両方に共通です。該当する場合は、手順の違いが強調表示されています。
警告: このページには、AWS CLI のマニュアルへのリンクが含まれています。AWS CLI で自身のマニュアルを管理しているため、Splunk AppDynamics では AWS CLI のマニュアルの精度については一切保証しません。

Kubernetes クラスタの作成

注: kops を使用して、AWS で独自の管理型 Kubernetes クラスタを作成できます。別のクラウドまたは独自のデータセンターで自己管理型クラスタを作成する場合は、Kubeadm や Kubespray などの他のツールを使用することを検討してください。「展開ツールを使用した Kubernetes のインストール」を参照してください。

Bare Metal K8s で Kubernetes クラスタを作成するには、次の手順を実行します。

  1. AWS CLI をインストールして設定します。
  2. IAM ロールを作成するには、次のように入力します。
    CODE
    aws iam create-group --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonRoute53FullAccess --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/IAMFullAccess --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonVPCFullAccess --group-name kops
    aws iam create-user --user-name kops
    aws iam add-user-to-group --user-name kops --group-name kops
    aws iam create-access-key --user-name kops
  3. 前の手順で取得したアクセスキーと aws configure を使用して、AWS CLI ログイン情報を設定します。
  4. プラットフォームに応じて、次の手順に従って kops をインストールします。
  5. S3 バケットを作成するには、次のように入力してバージョン管理を有効にします。
    CODE
    bucket_name=heimdall-onprem-kops-state-store
    aws s3api create-bucket \
    --bucket ${bucket_name} \
    --create-bucket-configuration LocationConstraint=us-west-2
    aws s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled
  6. クラスタを作成するには、次のように入力します。
    JSON
    export KOPS_CLUSTER_NAME=heimdall-onprem.k8s.local
    export KOPS_STATE_STORE=s3://${bucket_name}
    export KOPS_KUBERNETES_VERSION=1.x.x
    kops create cluster \
    --node-count=4 \
    --node-size=t3.2xlarge \
    --zones=us-west-2a \
    --kubernetes-version=${KOPS_KUBERNETES_VERSION} \
    --name=${KOPS_CLUSTER_NAME}
    kops update cluster --name ${KOPS_CLUSTER_NAME} --yes
    注: 互換性のあるバージョンのいずれかから KOPS_KUBERNETES_VERSION を指定します。
    注: 上記のコードスニペットの node-sizenode-count は、推奨される設定タイプに従って選択されます。異なるタイプとノード数で、任意の設定を指定できます。「EC2 インスタンスタイプ」を参照してください。
  7. クラスタが実行されているかどうかを確認するには(クラスタのセットアップと実行に時間がかかる場合があります)、次のように入力します。
    CODE
    kops validate cluster
クラスタへのアクセス

Kubernetes クラスタにアクセスするには、次の手順に従って、クラスタとの対話型ユーティリティである kubectl をインストールします。

クラスタが実行されていることを確認するには、次のように入力します。

CODE
kubectl get nodes

(オプション)プロキシサーバーの設定

プロキシサーバーを設定すると、すべてのドメインに適用されます。values.yaml ファイルにプロキシサーバーアドレスを指定して、プロキシサーバーを設定します。「キーと値のペアの設定」を参照してください。

プロキシサーバーからドメインをバイパスするには、次の手順を実行します。

注: バイパスリストの設定は、Web モニタリング PSA でのみサポートされています。
  1. values.yaml ファイルを開きます。
  2. [browserMonitoringAgent] の [bypassList] フィールドにドメイン URL を追加します。
    CODE
    browserMonitoringAgent:
    enabled: true
    server: "<proxy server address>"
    bypassList: "<specify the domain URLs that you want to bypass separated by semicolon>"

    たとえば、 bypassList: "*abc.com;*xyz1.com;*xyz2.com"

    bypassList で指定したドメイン URL は、プロキシサーバーにリダイレクトされません。bypassList に任意の数のドメインを追加できます。他のすべての指定されていないドメイン URL は、プロキシサーバーにリダイレクトされます。

Docker イメージのプル

DockerHub から sum-chrome-agent、sum-api-monitoring-agent、sum- heimdall の既成の Docker イメージをプルします。既成イメージには依存ライブラリが含まれているため、インターネットにアクセスできない場合でもこれらのイメージを使用できます。

次のコマンドを実行して、エージェントイメージをプルします。

CODE
docker pull appdynamics/heimdall-psa
docker pull appdynamics/chrome-agent-psa
docker pull appdynamics/api-monitoring-agent-psa

(オプション)カスタム Python ライブラリの追加

注: このセクションは、Web モニタリング PSA にのみ適用されます。

使用可能な標準ライブラリセットに加えて、スクリプト測定で使用するカスタム Python ライブラリをエージェントに追加できます。ベースイメージとしてロードしたイメージに基づいて新しいイメージをビルドします。

  1. Dockerfile を作成し、Python pip を実行する RUN ディレクティブを作成します。たとえば、algorithms ライブラリをインストールするには、次のように Dockerfile を作成します。

    CODE
    # Use the sum-chrome-agent image you just loaded as the base image
    FROM appdynamics/chrome-agent-psa:<agent-tag>
    USER root
    RUN apk add py3-pip
    USER appdynamics
    # Install algorithm for python3 on top of that
    RUN python3 -m pip install algorithms==0.1.4 --break-system-packages
    注: 任意の数の ディレクティブを作成して、必要なライブラリをインストールできます。
  2. 新しいイメージをビルドするには、次のように入力します。

    CODE
    docker build -t sum-chrome-agent:<agent-tag> - < Dockerfile

    新しくビルドされたエージェントイメージには、必要なライブラリが含まれています。

Tag and Push Images to the Registry

You must tag and push the images to a registry for the cluster to access it. It can be done in the following ways:

Bare Metal K8S using EC2

Vanilla K8S runs on AWS infrastructure. As kops create and assign appropriate roles to the cluster nodes, they can directly access Elastic Container Registry (ECR), without any other configuration.

To tag images, enter:

Web Monitoring PSA:

CODE
docker tag sum-heimdall:<heimdall-tag> <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sum/sum-heimdall:<heimdall-tag>
docker tag sum-chrome-agent:<agent-tag> <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sum/sum-chrome-agent:<agent-tag>

API Monitoring PSA:

CODE
docker tag sum-heimdall:<heimdall-tag> <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sum/sum-heimdall:<heimdall-tag>
docker tag sum-api-monitoring-agent:<agent-tag> <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sum/sum-api-monitoring-agent:<agent-tag>

Replace <aws_account_id> and <region> with your account and region values.

To create repositories, enter:

Web Monitoring PSA:

CODE
aws ecr create-repository --repository-name sum/sum-heimdall
aws ecr create-repository --repository-name sum/sum-chrome-agent

API Monitoring PSA:

CODE
aws ecr create-repository --repository-name sum/sum-heimdall
aws ecr create-repository --repository-name sum/sum-api-monitoring-agent

To push the images, enter:

Web Monitoring PSA:

CODE
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com
docker push <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sum/sum-heimdall:<heimdall-tag>
docker push <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sum/sum-chrome-agent:<agent-tag>

API Monitoring PSA:

CODE
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com
docker push <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sum/sum-heimdall:<heimdall-tag>
docker push <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sum/sum-api-monitoring-agent:<agent-tag>

Bare Metal K8S using Private Registry

注: If you are managing your own Kubernetes cluster which is not on AWS, then you must deploy your own registry server. See deploy a registry server. See deploy a registry server.

To tag images, enter:

Web Monitoring PSA:

CODE
docker tag sum-heimdall:<heimdall-tag> <REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall:<heimdall-tag>
docker tag sum-chrome-agent:<agent-tag> <REGISTRY_HOST>:<REGISTRY_PORT>/sum-chrome-agent:<agent-tag>

API Monitoring PSA:

CODE
docker tag sum-heimdall:<heimdall-tag> <REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall:<heimdall-tag>
docker tag sum-api-monitoring-agent:<agent-tag> <REGISTRY_HOST>:<REGISTRY_PORT>/sum-api-monitoring-agent:<agent-tag>

Replace <REGISTRY_HOST> and <REGISTRY_PORT> to what you configured while deploying the registry.

To push the images, enter:

Web Monitoring PSA:

CODE
docker login <REGISTRY_HOST>:<REGISTRY_PORT>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall:<heimdall-tag>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/sum-chrome-agent:<agent-tag>

API Monitoring PSA:

CODE
docker login <REGISTRY_HOST>:<REGISTRY_PORT>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall:<heimdall-tag>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/sum-api-monitoring-agent:<agent-tag>

Deploy the Web Monitoring PSA and API Monitoring PSA

注: Ensure that you follow the applicable sequence of steps when installing Web Monitoring PSA and API Monitoring PSA, respectively; some steps are common for both procedures.

The application is deployed to the cluster after the images are in the Registry. You use the Helm chart to deploy and create all Kubernetes resources in the required order.

注: Starting from PSA 23.12 release, you must deploy both Ignite and Heimdall in a single namespace named "measurement."
  1. Install Helm following these instructions.
  2. Create a new measurement namespace to run Apache Ignite pods.
    警告: Ensure that you first run the Apache Ignite commands and then run the Heimdall commands.
    To create a new measurement namespace, enter:
    CODE
    kubectl create namespace measurement
    Before you deploy Apache Ignite, you must set some configuration options. To view the configuration options, navigate to the previously downloaded ignite-psa.tgz file and enter:
    CODE
    helm show values ignite-psa.tgz > values-ignite.yaml
    注: If you want to enable persistence, set persistence > enabled. This is an optional configuration
  3. To deploy the Helm chart using the above-mentioned configuration, navigate to the previously downloaded ignite-psa.tgz file and enter:
    CODE
    helm install synth ignite-psa.tgz --values values-ignite.yaml --namespace ignite
    All the Kubernetes resources are created in the cluster, and you can use Apache Ignite. After a few seconds, Apache Ignite initializes and is visible in the Controller.
  4. To verify if the pods are running, enter:
    CODE
    kubectl get pods --namespace measurement

    Proceed to the next steps only after the Apache Ignite pods run successfully.

  5. Using a single command, you can deploy the Helm chart, which contains the deployment details. To deploy the agent, use the Helm chart sum-psa-heimdall.tgz in the zip file that you downloaded previously. Before you deploy the Private Synthetic Agent, you must set some configuration options. To view the configuration options, navigate to the previously downloaded sum-psa-heimdall.tgz file and enter:
    CODE
    helm show values sum-psa-heimdall.tgz > values.yaml

    These are the configuration key-value pairs that you need to edit in the values.yaml file:

    Web Monitoring PSA Using EC2:
    Configuration Key Value
    heimdall > repository <aws_account_id>.dkr.ecr.<region>. amazonaws.com/sum/sum-heimdall
    heimdall > tag <heimdall-tag>
    heimdall > pullPolicy always
    chromeAgent > repository <aws_account_id>.dkr.ecr.<region>. amazonaws.com/sum/sum-chrome-agent
    chromeAgent > tag <agent-tag>
    shepherd > url Shepherd URL
    shepherd > credentials credentials
    shepherd > location agent location
    API Monitoring PSA Using EC2:
    Configuration Key Value
    heimdall > repository <aws_account_id>.dkr.ecr.<region>. amazonaws.com/sum/sum-heimdall
    heimdall > tag <heimdall-tag>
    heimdall > pullPolicy always
    apiMonitoringAgent > repository <aws_account_id>.dkr.ecr.<region>. amazonaws.com/sum/sum-api-monitoring-agent
    apiMonitoringAgent > tag <agent-tag>
    shepherd > url Shepherd URL
    shepherd > credentials credentials
    shepherd > location agent location
    Web Monitoring PSA Using Private Registry:
    Configuration Key Value
    heimdall > repository <REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall
    heimdall > tag <heimdall-tag>
    heimdall > pullPolicy always
    chromeAgent > repository <REGISTRY_HOST>:<REGISTRY_PORT>/sum-chrome-agent
    chromeAgent > tag <agent-tag>
    privateRegistry true
    shepherd > url Shepherd URL
    shepherd > credentials credentials
    shepherd > location agent location
    API Monitoring PSA Using Private Registry:
    Configuration Key Value
    heimdall > repository <REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall
    heimdall > tag <heimdall-tag>
    heimdall > pullPolicy always
    apiMonitoringAgent > repository <REGISTRY_HOST>:<REGISTRY_PORT>/sum-api-monitoring-agent
    apiMonitoringAgent > tag <agent-tag>
    privateRegistry true
    shepherd > url Shepherd URL
    shepherd > credentials credentials
    shepherd > location agent location
    注: After configuring using Private Registry

    Create registry credentials:

    CODE
    kubectl create secret docker-registry regcred --docker-server=<REGISTRY_HOST>:<REGISTRY_PORT> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email> --namespace measurement

    Patch the default service account of the measurement namespace to use the regcred registry credentials:

    JSON
    kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "regcred"}]}' --namespace measurement
    You can leave the rest of the values set to their defaults or configure them based on your requirements. See Configure Web Monitoring PSA and API Monitoring PSA for details on shepherd URL, credentials, location, and optional key-value pairs.
    注: You need to replace <aws_account_id> and <region> with your account and region values.
    注:

    If the Kubernetes cluster is locked down, and you cannot make cluster-wide configuration, you can make pod-level changes.

    For example, if you want to change the pod-level DNS server setting to use your internal nameservers for DNS name resolution, specify the following details in the values.yaml file:

    Configuration Key Value
    agentDNSConfig:
    enabled: true
    dnsConfig:
    nameservers: ["4.4.4.4"]
    searches: ["svc.cluster.local", "cluster.local"]
  6. To deploy the Helm chart using the above-mentioned configuration, navigate to the previously downloaded sum-psa-heimdall.tgz file and enter:
    CODE
    helm install heimdall-onprem sum-psa-heimdall.tgz --values values.yaml --namespace measurement
    All the Kubernetes resources are created in the cluster, and you can use Heimdall. After a few seconds, Heimdall initializes and is visible in the Controller.
  7. To verify if the pods are running, enter:
    CODE
    kubectl get pods --namespace measurement
    To make any changes to the values.yaml after the initial deployment, navigate to the previously downloaded sum-psa-heimdall.tgz file and enter:
    CODE
    helm upgrade heimdall-onprem sum-psa-heimdall.tgz --values values.yaml --namespace measurement
    警告:

    To remove the deployment:

    CODE
    helm uninstall heimdall-onprem --namespace measurement

    This is not recommended unless it is required.

Kubernetes クラスタのモニタリング

ダウンロードした zip 内の Helm チャート sum-psa-monitoring.tgz により、モニタリングスタックがインストールされます。この Helm チャートは、Private Simple Synthetic Agent をモニタするためのカスタム Grafana ダッシュボードとともに kube-prometheus-stack をインストールします。

注: この展開のモニタリングはオプションです。ただし、クラスタをモニターして正常性を定期的に確認することを強く推奨します。

Install the Monitoring Stack

  1. To create a separate monitoring namespace, enter:

    CODE
    kubectl create namespace monitoring
    To review configuration options, enter:
    CODE
    helm show values sum-psa-monitoring.tgz > values-monitoring.yaml
    This generates a values-monitoring.yaml file that contains all the configuration options. To modify and pass the generated values-monitoring.yaml file while installing the Helm chart, enter:
    CODE
    helm install psa-monitoring sum-psa-monitoring.tgz --values values-monitoring.yaml --namespace monitoring
  2. After the monitoring stack is installed, you can Launch Grafana (which runs inside the cluster) to view the dashboard. To access Grafana from outside of the cluster, you can configure port forwarding or set up Ingress. To configure port forward to access it locally, enter:

    CODE
    kubectl port-forward svc/psa-monitoring-grafana 3000:80 --namespace monitoring
  3. Launch localhost:3000 from the browser and log in using the default credentials with username as admin and password as prom-operator. A dashboard named Private Simple Synthetic Agent displays and provides details about the Kubernetes cluster, Apache Ignite, Heimdall, and running measurements.

Bare Metal K8s での Private Synthetic Agent のアップグレード

Docker イメージのプル

DockerHub から sum-chrome-agent、sum-api-monitoring-agent、sum- heimdall の既成の Docker イメージをプルします。既成イメージには依存ライブラリが含まれているため、インターネットにアクセスできない場合でもこれらのイメージを使用できます。

次のコマンドを実行して、エージェントイメージをプルします。

CODE
docker pull appdynamics/heimdall-psa
docker pull appdynamics/chrome-agent-psa
docker pull appdynamics/api-monitoring-agent-psa

カスタム Python ライブラリの追加

この手順は任意です。使用可能な標準ライブラリセットに加えて、スクリプト測定で使用するカスタム Python ライブラリをエージェントに追加できます。ベースイメージとしてロードしたイメージに基づいて新しいイメージをビルドします。

  1. Dockerfile を作成してから、pythonpip を実行する RUN ディレクティブを作成します。たとえば、algorithms ライブラリをインストールするには、次のように Dockerfile を作成します。

    CODE
    # Use the sum-chrome-agent image you just loaded as the base image
    FROM appdynamics/chrome-agent-psa:<agent-tag>
    USER root
    RUN apk add py3-pip
    USER appdynamics
    # Install algorithm for python3 on top of that
    RUN python3 -m pip install algorithms==0.1.4 --break-system-packages
    注: 任意の数の ディレクティブを作成して、必要なライブラリをインストールできます。
  2. 新しいイメージを作成するには、次のコマンドを実行します。

    Web Monitoring PSA:
    CODE
    docker build -t sum-chrome-agent:<agent-tag> - < Dockerfile
    API Monitoring PSA
    CODE
    docker build -f Dockerfile-PSA -t sum-api-monitoring-agent:<agent-tag> .
    Kubernetes クラスタノードと同じ OS タイプのホストでイメージをビルドする必要があります。たとえば、イメージを AWS にプッシュする場合は、次のコマンドを実行します。
    CODE
    docker buildx build -f Dockerfile-PSA --platform=linux/amd64 -t sum-api-monitoring-agent:<api-tag> .
    新しくビルドされたエージェントイメージには、必要なライブラリが含まれています。

イメージのタグ付けとレジストリへのプッシュ

独自の Kubernetes クラスタを管理している場合は、独自のレジストリサーバーを展開する必要があります。詳細については、「レジストリサーバーの展開」を参照してください。レジストリを展開したら、イメージにタグを付けてプッシュします。

注: <REGISTRY_HOST><REGISTRY_PORT> を、レジストリの展開中に使用した値に置き換えます。

イメージにタグを付けるには、次のように入力します。

CODE
docker tag sum-heimdall:<heimdall-tag> <REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall:<heimdall-tag>
docker tag sum-chrome-agent:<agent-tag> <REGISTRY_HOST>:<REGISTRY_PORT>/sum-chrome-agent:<agent-tag>
docker tag sum-api-monitoring-agent:<agent-tag> <REGISTRY_HOST>:<REGISTRY_PORT>/sum-api-monitoring-agent:<agent-tag>

イメージをプッシュするには、次のように入力します。

CODE
docker login <REGISTRY_HOST>:<REGISTRY_PORT> docker push <REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall:<heimdall-tag>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/sum-chrome-agent:<agent-tag>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/sum-api-monitoring-agent:<agent-tag>

Helm チャートの更新

次の手順に従って、values.yaml ファイル内の設定キーと値のペアを更新します。

PSA のアップグレード

注: PSA 23.12 以降、Ignite と Heimdall を measurement という名前の単一の名前空間に展開する必要があります。
  1. 新しい Linux ディストリビューション フォルダに移動して、次のコマンドを実行します。

    CODE
    helm install synth ignite-psa.tgz --values values-ignite.yaml --namespace measurement
  2. Ignite ポッドのステータスが running に変わるまで待ちます。その後、次のコマンドを実行します。

    CODE
    helm upgrade heimdall-onprem sum-psa-heimdall.tgz --values values.yaml --namespace measurement
  3. 新しい Heimdall ポッドと Ignite ポッドのステータスが runningに変更されたら、古い Ignite 名前空間をアンインストールします。

    CODE
    helm uninstall synth -n ignite