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 のマニュアルの精度については一切保証しません。

Create the Kubernetes Cluster

注: You can use kops to create your own managed Kubernetes cluster on AWS. If you want to create self-managed cluster on a different cloud or your own datacenter, you might want to look into other tools like Kubeadm or Kubespray. See installing Kubernetes with deployment tools.

To create a Kubernetes cluster in Bare Metal K8s:

  1. Install and configure AWS CLI.
  2. To create IAM Role, enter.
    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. Configure AWS CLI credentials using aws configure with the access key obtained in the previous step.
  4. Based on your platform, install kops following these instructions.
  5. To create S3 bucket, enable versioning by entering:
    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. To create cluster, enter:
    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
    注: Specify the KOPS_KUBERNETES_VERSION from one of the compatible versions.
    注: The node-size and node-count in the above code snippet are selected according to recommended configuration type. You can specify a configuration of your choice with a different type and number of nodes. See EC2 instance types.
  7. To validate if the cluster is running (might take some time for cluster to set up and run), enter:
    kops validate cluster
Access the Cluster

To access the Kubernetes cluster, follow these instructions to install kubectl, a utility to interact with the cluster.

To verify that the cluster is running, enter:

kubectl get nodes

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

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

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

注: バイパスリストの設定は、Web モニタリング PSA でのみサポートされています。
  1. values.yaml ファイルを開きます。
  2. [browserMonitoringAgent] の [bypassList] フィールドにドメイン URL を追加します。
    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 は、プロキシサーバーにリダイレクトされます。

Configure Proxy Server at a Job Level

You can configure a proxy server and a bypass list for a particular job. Any proxy server URL and bypass list configured at the agent level gets overridden by the proxy server URL and bypass list configured at the job level. Perform the following steps to configure a proxy server at the job level:
  1. Create or edit a Synthetic job.
  2. Select the Run a script option.
  3. Add the following details in the beginning the script:
    '''yml
    jobLevelProxyConfig:
      proxyServer: "<proxy-server-address>"
      bypassProxyList: "<list of URLs that you want to bypass, separated by semi-colon>"
    '''
    Example:
    '''yml
    jobLevelProxyConfig:
      proxyServer: "http://tinyproxy: tinyproxy.svc.cluster.local:8888"
      bypassProxyList: "*abc.com;*xyz1.com;*xyz2.com"
    '''
    
    pageUrl = "https://help.splunk.com/en"
    driver.get(pageUrl)
    assert "Splunk" in driver.title, "Title should contain Splunk"

Docker イメージのプル

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

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

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 を作成します。

    # 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. 新しいイメージをビルドするには、次のように入力します。

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

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

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

クラスタがアクセスできるように、イメージにタグを付けてレジストリにプッシュする必要があります。これは、次の方法で実行できます。

EC2 を使用した Bare Metal K8S

Vanilla K8S は AWS インフラストラクチャで動作します。kops は適切なロールを作成してクラスタノードに割り当てるため、他の設定なしで Elastic Container Registry(ECR)に直接アクセスできます。

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

Web Monitoring PSA:

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:

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>

<aws_account_id><region> をアカウントとリージョンの値に置き換えます。

リポジトリを作成するには、次のように入力します。

Web Monitoring PSA:

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

API Monitoring PSA:

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

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

Web Monitoring PSA:

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:

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

注: AWS 上にない独自の Kubernetes クラスタを管理している場合は、独自のレジストリサーバを展開する必要があります。「Deploy a registry server」を参照してください。「レジストリサーバーの展開」を参照してください。

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

Web Monitoring PSA:

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:

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>

<REGISTRY_HOST> および <REGISTRY_PORT> をレジストリの展開時に設定した値に置き換えます。

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

Web Monitoring PSA:

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:

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>

Web モニタリング PSA と API モニタリング PSA を展開します。

注: Web モニタリング PSA および API モニタリング PSA をインストールするときは、それぞれの該当する一連の手順に必ず従ってください。一部の手順は、両方で共通しています。

イメージがレジストリに登録されると、アプリケーションはクラスタに展開されます。Helm チャートを使用して、必要な順序ですべての Kubernetes リソースを展開および作成します。

注: PSA 23.12 リリース以降、Ignite と Heimdall の両方を「measurement」という名前の単一の名前空間に展開する必要があります。

  1. 次の手順に従って、Helm をインストールします。
  2. Apache Ignite ポッドを実行するための新しい名前空間を作成します。
    警告: 最初に Apache Ignite のコマンドを実行してから、Heimdall のコマンドを実行してください。
    新しい measurement 名前空間を作成するには、次のように入力します。
    kubectl create namespace measurement
    Apache Ignite を展開する前に、いくつかの設定オプションを設定する必要があります。設定オプションを表示するには、すでにダウンロードした ignite-psa.tgz ファイルに移動し、次のように入力します。
    helm show values ignite-psa.tgz > values-ignite.yaml
    注: 永続化を有効にする場合は、persistence > enabled を設定します。この設定は、オプションです。
  3. 上記の設定を使用して Helm チャートを展開するには、すでにダウンロードした ファイルに移動し、次のように入力します。
    helm install synth ignite-psa.tgz --values values-ignite.yaml --namespace ignite
    すべての Kubernetes リソースがクラスタに作成され、Apache Ignite を使用できます。数秒後、Apache Ignite が初期化され、コントローラに表示されます。
  4. ポッドが実行されているかどうかを確認するには、次のように入力します。
    kubectl get pods --namespace measurement

    Apache Ignite ポッドが正常に実行された後にのみ、次の手順に進みます。

  5. 1 つのコマンドを使用して、展開の詳細を含む Helm チャートを展開できます。エージェントを展開するには、以前にダウンロードした zip ファイルの Helm チャート を使用します。Private Synthetic Agent を展開する前に、いくつかの設定オプションを設定する必要があります。設定オプションを表示するには、すでにダウンロードした sum-psa-heimdall.tgz ファイルに移動し、次のように入力します。
    helm show values sum-psa-heimdall.tgz > values.yaml

    以下は、values.yaml ファイルで編集する必要がある設定キーと値のペアです。

    Web Monitoring PSA Using EC2:
    設定キー
    heimdall > repository<aws_account_id>.dkr.ecr.<region>. amazonaws.com/sum/sum-heimdall
    heimdall > tag<heimdall-tag>
    heimdall > pullPolicyalways
    chromeAgent > repository<aws_account_id>.dkr.ecr.<region>. amazonaws.com/sum/sum-chrome-agent
    chromeAgent > tag<agent-tag>
    shepherd > urlShepherd URL
    shepherd > credentialscredentials
    shepherd > locationagent location
    API Monitoring PSA Using EC2:
    設定キー
    heimdall > repository<aws_account_id>.dkr.ecr.<region>. amazonaws.com/sum/sum-heimdall
    heimdall > tag<heimdall-tag>
    heimdall > pullPolicyalways
    apiMonitoringAgent > repository<aws_account_id>.dkr.ecr.<region>. amazonaws.com/sum/sum-api-monitoring-agent
    apiMonitoringAgent > tag<agent-tag>
    shepherd > urlShepherd URL
    shepherd > credentialscredentials
    shepherd > locationagent location
    Web Monitoring PSA Using Private Registry:
    設定キー
    heimdall > repository<REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall
    heimdall > tag<heimdall-tag>
    heimdall > pullPolicyalways
    chromeAgent > repository<REGISTRY_HOST>:<REGISTRY_PORT>/sum-chrome-agent
    chromeAgent > tag<agent-tag>
    privateRegistrytrue
    shepherd > urlShepherd URL
    shepherd > credentialscredentials
    shepherd > locationagent location
    API Monitoring PSA Using Private Registry:
    設定キー
    heimdall > repository<REGISTRY_HOST>:<REGISTRY_PORT>/sum-heimdall
    heimdall > tag<heimdall-tag>
    heimdall > pullPolicyalways
    apiMonitoringAgent > repository<REGISTRY_HOST>:<REGISTRY_PORT>/sum-api-monitoring-agent
    apiMonitoringAgent > tag<agent-tag>
    privateRegistrytrue
    shepherd > urlShepherd URL
    shepherd > credentialscredentials
    shepherd > locationagent location
    注: プライベートレジストリを使用して設定した後

    レジストリログイン情報を作成するには、次のように入力します。

    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

    regcred レジストリログイン情報を使用するように、測定名前空間のデフォルト サービス アカウントにパッチを適用します。

    kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "regcred"}]}' --namespace measurement
    残りの値はデフォルトのままにすることも、要件に基づいて設定することもできます。シェパード URL、ログイン情報、場所、およびオプションのキーと値のペアの詳細については、「Web モニタリング PSA および API モニタリング PSA の設定」を参照してください。
    注: <aws_account_id><region> をアカウントとリージョンの値に置き換える必要があります。
    注:

    Kubernetes クラスタがロックダウンされていて、クラスタ全体の設定を行うことができない場合は、ポッドレベルの変更を行うことができます。

    たとえば、ポッドレベルの DNS サーバー設定を変更して、DNS 名の解決に内部ネームサーバーを使用する場合は、values.yaml ファイルで次の詳細を指定します。

    設定キー
    agentDNSConfig:
    enabled: true
    dnsConfig:
    nameservers:["4.4.4.4"]
    searches:["svc.cluster.local", "cluster.local"]
  6. 上記の設定を使用して Helm チャートを展開するには、すでにダウンロードした sum-psa-heimdall.tgz ファイルに移動し、次のように入力します。
    helm install heimdall-onprem sum-psa-heimdall.tgz --values values.yaml --namespace measurement
    すべての Kubernetes リソースがクラスタに作成され、Heimdall を使用できます。数秒後、Heimdall が初期化され、コントローラに表示されます。
  7. ポッドが実行されているかどうかを確認するには、次のように入力します。
    kubectl get pods --namespace measurement
    初期導入後に values.yaml に変更を加えるには、すでにダウンロードした sum-psa-heimdall.tgz ファイルに移動して、次のように入力します。
    helm upgrade heimdall-onprem sum-psa-heimdall.tgz --values values.yaml --namespace measurement
    警告:

    展開を削除するには、次のコマンドを実行します。

    helm uninstall heimdall-onprem --namespace measurement

    これは、必要でない限り推奨されません。

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

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

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

モニタリングスタックのインストール

  1. 別のモニタリングを作成するには、次のように入力します。

    kubectl create namespace monitoring
    設定オプションを確認するには、次のように入力します。
    helm show values sum-psa-monitoring.tgz > values-monitoring.yaml
    これにより、すべての設定オプションを含む values-monitoring.yaml ファイルが生成されます。Helm チャートのインストール中に生成された values-monitoring.yaml ファイルを変更して渡すには、次のように入力します。
    helm install psa-monitoring sum-psa-monitoring.tgz --values values-monitoring.yaml --namespace monitoring
  2. モニタリングスタックをインストールした後、(クラスタ内で実行される)Grafana を起動してダッシュボードを表示できます。クラスタの外部から Grafana にアクセスするには、ポートフォワーディングを設定するか、Ingress を設定します。ローカルにアクセスするようにポートフォワーディングを設定するには、次のように入力します。

    kubectl port-forward svc/psa-monitoring-grafana 3000:80 --namespace monitoring
  3. ブラウザから localhost:3000 を起動し、デフォルトのログイン情報(ユーザー名:admin、パスワード:prom-operator)を使用してログインします。Private Simple Synthetic Agent という名前のダッシュボードに、Kubernetes クラスタ、Apache Ignite、Heimdall、および実行中の測定に関する詳細が表示されます。

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

Pull the Docker Image

Pull the pre-built docker images for sum-chrome-agent, sum-api-monitoring-agent, and sum-heimdall from DockerHub. The pre-built images include the dependent libraries, so you can use these images even when you do not have access to the Internet.

Run the following commands to pull the agent images:

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

Add Custom Python Libraries

This is an optional step. In addition to the available standard set of libraries, you can add custom Python libraries to the agent to use in scripted measurements. You build a new image based on the image you loaded as the base image.

  1. Create a Dockerfile and then create RUN directives to run pythonpip. For example, to install the library algorithms you can create a Dockerfile:

    # 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
    Note: You can create any number of RUN directives to install the required libraries.
  2. To build the new image, run the following commands:

    Web Monitoring PSA:
    docker build -t sum-chrome-agent:<agent-tag> - < Dockerfile
    API Monitoring PSA:
    docker build -f Dockerfile-PSA -t sum-api-monitoring-agent:<agent-tag> .
    You must build the images on the host with the same OS type of Kubernetes cluster nodes. For example, if you are pushing the image to AWS, then run the following command:
    docker buildx build -f Dockerfile-PSA --platform=linux/amd64 -t sum-api-monitoring-agent:<api-tag> .
    The newly built agent image contains the required libraries.

Tag and Push Images to the Registry

If you are managing your own Kubernetes cluster, then you must deploy your own registry server. For more details, see Deploy a Registry Server. After deploying the registry, tag and push the images.

Note: Replace <REGISTRY_HOST> and <REGISTRY_PORT> with the values that you used while deploying the registry.

To tag the images, enter:

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>

To push the images, enter:

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>

Update the Helm Chart

Follow these steps and update the configuration key value pairs in the values.yaml file:

Upgrade the PSA

Note: From PSA 23.12 onwards, you must deploy Ignite and Heimdall in a single namespace named measurement.
  1. Navigate to the new Linux distribution folder and run the following command:

    helm install synth ignite-psa.tgz --values values-ignite.yaml --namespace measurement
  2. Wait until the status of Ignite pods changes to running. Then, run the following command:

    helm upgrade heimdall-onprem sum-psa-heimdall.tgz --values values.yaml --namespace measurement
  3. After the status of the new Heimdall and Ignite pods changes to running, uninstall the old Ignite namespace:

    helm uninstall synth -n ignite