Install Python agent in a container
Using the Agent Wizard is the simplest way to deploy a new agent by selecting Language-specific > Python > Install in a container. Installing the PHP agent in a container to AWS Fargate is also supported.
Select method to deploy
Select Dockerfile or Kubernetes.
Build Dockerfile image with agent
Under Build image with agent:
Install the agent in the image using your preferred package manager. For example, using PIP, add the following to your Dockerfile:
RUN pip install contrast-agent
Modify your application command to include the Agent:
CMD ["contrast-python-run", "--", [original application startup command]]
The double dash separator
--separates the runner command's arguments from ones that belong to the original command.Build the image:
docker build -t my-app-with-contrast .
For Kubernetes (Linux only)
Under Select method to deploy with containers, select Kubernetes.
Under Select method to configure agent operator, select Helm charts or Manifest.
For Helm:
Under Download and set up the values file, copy the code displayed in the wizard to create a values file.
Skip this step if you already have the operator installed.
Under Install and deploy Helm chart, run the Helm commands in the wizard.
Skip this step if you already have the operator installed.
Under Label namespaces, run the command displayed to label your namespaces to add AgentInjectors.
Under Label deployments, follow the wizard steps and run the commands to label your deployments.
For Manifest:
Under Install operator, run the commands displayed in the wizard to install the Contrast agent operator.
Skip this step if you already have the operator installed.
Under Configure operator, follow the wizard steps to deploy the secret, connect your cluster, and apply the configuration.
Skip this step if you already have the operator configured.
Under Configure Injector, copy or download the YAML file, run the
kubectl applycommand displayed in the wizard, and then wait for the command to complete.Under Label namespaces, run the command displayed to label your namespaces to add AgentInjectors.
Under Label deployments, follow the wizard steps and run the commands to label your deployments.
Configure the agent
A connection token is the recommended method.
For a Dockerfile install, a connection token is the recommended method. Set
CONTRAST__API__TOKENin the environment where you run your application. You can also use other environment variables or the Python YAML template.For a Kubernetes install, the operator uses the connection details from the secret and
ClusterAgentConnectionthat you created in the Configure operator step. Use the optional Configure the Python agent step to set other agent settings for your workloads.
Verify the agent deployment
Interact with your application as you normally would. For example, interact with your application's web interface or send API commands.
In the Agent Wizard, select View agent activity to verify that your agent appears in the agents list.
Verify that you see the name of your application in the applications list.
In Northstar, select Applications from the left navigation.
In Contrast, select Applications from the header.
Verify that you see the name of your local server in the servers list.
In Northstar, select Servers from the left navigation.
In Contrast, select Servers from the header.