To deploy the Cluster Agent using the AppDynamics Operator, you need a Cluster Agent Docker Image and a secret that contains the Controller access key. The secret should be created when deploying the AppDynamics Operator to Kubernetes, as it provides the configuration for the Cluster Agent to start.

Create a Controller Access Key Secret

To create a secret with a Controller access key:

$ kubectl -n appdynamics create secret generic cluster-agent-secret --from-literal=controller-key=<access-key>
CODE

Create Secret to Pull the Cluster Agent from your Docker Repository

(Optional) If you are using a Docker repository that requires access credentials, create a secret to pull the Docker image from the private repository:

$ kubectl -n appdynamics create secret docker-registry regcred --docker-server=https://index.docker.io/v1 --docker-username=<docker-username> --docker-password=<docker-password> --docker-email=unused
CODE

Next, link the secret to the desired service account:

$ kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "regcred"}]}'
CODE

Specify this secret in your cluster-agent.yaml file, using imagePullSecrets and name property.

apiVersion: appdynamics.com/v1alpha1
kind: Clusteragent
metadata:
  name: k8s-cluster-agent
  namespace: appdynamics
spec:
  appName: "<app-name>"
  controllerUrl: "http://<appdynamics-controller-host>:8080"
  account: "<account-name>"
  # docker image info
  image: "<your-docker-registry>/appdynamics/cluster-agent:tag"
  imagePullSecrets:
    name: "regcred"
CODE

Deploy the Cluster Agent 

Start the Cluster Agent and point it to the desired Controller. Deploy the Cluster Agent using the AppDynamics Operator:

$ kubectl create -f cluster-agent.yaml
CODE

Example output:

clusteragent.appdynamics.com/k8s-cluster-agent created
CODE

Stop the Cluster Agent 

To stop the Cluster Agent pod, run: 

$ kubectl delete -f cluster-agent.yaml
CODE