Kubernetes CLI を使用したクラスタエージェントのインストール

このページでは、 OpenShift OperatorHub バンドルを使用してクラスタエージェントをインストールする方法について説明します。これは、「Kubernetes CLI を使用したクラスタエージェントのインストール」の代替手段です。

要件

開始する前に、次のことを確認します。

Installation Procedure

  1. If you have not already installed the metrics-server, see https://github.com/kubernetes-sigs/metrics-server for the most recent installation instructions. However, if you are using OpenShift Container Platform >=4.16, you do not require to install metric server separately.
    kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
  2. Download the Kubernetes or OpenShift Cluster Agent bundle from the Download portal, unzip the contents of the bundle to the current directory:
    unzip appdynamics-cluster-agent-alpine-linux-<version>.zip
  3. Create a namespace appdynamics in the cluster. If you require to use a custom namespace, you can ignore this step and ensure to use the same namespace during installation. Here, we have used namespace as appdynamics.
    kubectl create namespace appdynamics
  4. (Optional) If you require to use the Kubernetes API server, ensure that you set the USE_CUSTOM_KUBECONFIG env variable to true and specify the server API details in the cluster-agent-operator.yaml file. For details, see Configure Image to Use Kubernetes API Server.
  5. Install the Cluster Agent Operator using the correct Kubernetes and OpenShift version (where applicable):
    Kubernetes >= 1.16
    kubectl create -f cluster-agent-operator.yaml
    OpenShift with Kubernetes >= 1.16
    kubectl create -f cluster-agent-operator-openshift.yaml
    OpenShift with Kubernetes <= 1.15
    kubectl create -f cluster-agent-operator-openshift-1.15-or-less.yaml
    注: You can also install Cluster Agent Operator from OpenShift OperatorHub in your OpenShift cluster.
  6. Based on the Account Access Key for the Controller, create the Controller Access Key Secret that the Cluster Agent reports to:
    kubectl -n appdynamics create secret generic cluster-agent-secret --from-literal=controller-key=<access-key>
  7. Edit cluster-agent.yaml nsToMonitorRegexThis example assumes the use of the pre-built Cluster Agent image on Docker Hub. See Configure the Cluster Agent, Cluster Agent Container Image to build your own image.
    apiVersion: cluster.appdynamics.com/v1alpha1
    kind: Clusteragent
    metadata:
      name: k8s-cluster-agent
      namespace: appdynamics
    spec:
      appName: "dev-cluster"
      controllerUrl: "http://mycontroller.com:8080"
      account: "my-account"
      # docker image info where, <version> is the image tag version that you are installing
      image: "docker.io/appdynamics/cluster-agent:<version>"
      serviceAccountName: appdynamics-cluster-agent
      nsToMonitorRegex: namespace1|namespace2
      stdoutLogging: "true"
  8. (Optional) If you require multiple Cluster Agents to monitor a single cluster, set up Target Allocator. In thecluster-agent.yaml file, enable target allocator with the number of Cluster Agent replicas to enable the operator to create Cluster Agent replicas. See Target Allocator.
    注: Auto-instrumentation and containerAppCorrelationMethod (for Kubernetes >= 1.25) is not supported when the Target Allocator is enabled. Set spec.instrumentationMethod to "" or "None" and spec.containerAppCorrelationMethod to ""or "none".

    cluster-agent.yaml

    …
    spec:
      …
    appName: "my-cluster"
    nsToMonitorRegex: ".*"
    instrumentationMethod: "None"
    containerAppCorrelationMethod: "none" 
    targetAllocator:
        enabled: true         # false if autoScaling is enabled
        clusterAgentReplicas: 3
        autoScaling:
          enabled: false #false by default
          replicaProfile: Default 
          maxClusterAgentReplicas: 12
          scaleDown:
            stabilizationWindowSeconds: 86400 #In Seconds
        podConfig:
          imagePullPolicy: Always
          imagePullSecret: ecr-secret
          priorityClassName: high-priority
          serviceAccountName: appdynamics-target-allocator
          nodeSelector:{}
          tolerations:[]
          resources:
            limits:
              cpu: 500m
              memory: 500Mi
            requests:
              cpu: 200m
              memory: 200Mi
          labels:{}
          securityContext:{}
  9. Install the Cluster Agent:
    kubectl create -f cluster-agent.yaml
See Validate the Cluster Agent Installation to validate and troubleshoot the installation. Once the install is validated, see Container Installation Options for options to install App Server Agents in applications in the cluster.

カスタム Kubernetes API サーバーを使用するための設定

Kubernetes API サーバーを使用するには、cluster-agent-operator.yaml(Kubernetes 1.16 以降の場合)または cluster-agent-operator-openshift.yaml(OpenShift with Kubernetes 1.16 以降の場合)の spec に以下を追加する必要があります。

  1. cluster-agent-operator.yaml ファイル内の configMap を Kubernetes API サーバーの詳細で更新します。これらの詳細情報は必須です。
    • server:Kubernetes API サーバーの URL を指定します。
    • clusters.name:クラスタの名前。
    • users.name:Kubernetes API サーバーにアクセスできるユーザーの名前。
    • contexts.context:クラスタ名とユーザー名を更新して、ユーザーの詳細を特定のクラスタにマッピングします。次のサンプルの yaml ファイルには、必要なパラメータが含まれています。
      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: custom-kubeconfig
        namespace: appdynamics
      data:
        kubeconfig: |
          apiVersion: v1
          clusters:
          - cluster:
              server: "https://kubernetes.default.svc"
              certificate-authority: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
            name: psr-cluster
          contexts:
          - context:
              cluster: psr-cluster
              user: psr-user
            name: psr-context
          current-context: psr-context
          kind: Config
          preferences: {}
          users:
          - name: psr-user
            user:
              tokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
      ここで、https://kubernetes.default.svc は API サーバーの URL です。[clusters] では、psr-cluster はクラスタの名前です。users では、psr-user は Kubernetes API サーバーを使用できるユーザーです。
  2. cluster-agent-operator.yaml ファイル(Kubernetes 1.16 以降の場合)または cluster-agent-operator-openshift.yaml ファイル(OpenShift with Kubernetes 1.16 以降の場合)で USE_CUSTOM_KUBECONFIG 環境変数を true に設定します。
    
    - name: USE_CUSTOM_KUBECONFIG
      value: "true