Prerequisites
- Self-hosted agents enabled for your organization. They are available to Enterprise customers only. If your organization does not have them, the Agents page tells you to contact your account manager.
- Admin role or Edit Organization Settings permission.
- A Kubernetes cluster at version 1.24 or later, with nodes of at least 2 CPU and 8 GiB memory. Your
kubectlcontext must point to it. - Helm installed.
- Outbound HTTPS access from the cluster to the required domains.
- A VCS connection and a fork of env0/templates.
This tutorial stores deployment state with env zero-hosted encrypted state, so you do not need a
StorageClass or a persistent volume. To keep state on a persistent volume instead, see Persistent Volume/Storage Class.Create an agent pool
1
Open the Agents page
Go to Organization Settings > Agents.
2
Create the agent
Click Create Agent, enter a name in Agent Name, and click Create. The name must be unique in your organization.
Create an agent secret
1
Add a secret
In the secrets dialog, click Add Secret, enter a Description such as
tutorial, and click Create Secret.2
Copy the token
Copy the value under Secret Token and keep it. env zero shows it once.
Install the agent
1
Add the env zero Helm repository
2
Install the chart
Replace The agent encrypts and decrypts your deployment state with the passphrase, and env zero never has access to it. Keep it in your own secret store.
<YOUR_AGENT_ACCESS_TOKEN> with the secret token and <YOUR_PASSPHRASE> with a passphrase you choose.env0StateEncryptionKey to be base64 of text, which is why the command encodes the passphrase. If you pass a value that is not base64, helm install fails with an error that names the value.
Verify the installation
1
Check the agent deployment
env0-agent-agent-trigger-deployment. The agent trigger polls env zero for deployment tasks.2
Run the chart tests
env0StateEncryptionKey. If a test fails, its log shows which check failed.3
Check the agent status in env zero
Return to Organization Settings > Agents and click the refresh icon in the Agent Pools header. Agent Status shows Active when the agent is ready to run deployments. If it shows Inactive, wait and refresh again. See Monitoring self-hosted agents for what each state means.
Assign the agent to a project
1
Find the assignments
On the Agents page, scroll to Agent Assignments. It lists your projects.
2
Select your agent
In the row of the project you will deploy in, such as Default Organization Project, open the dropdown and select your agent.
Create a template that needs no cloud credentials
Follow Create your first template with these values:
The
misc/null-resource folder contains one null_resource and no provider credentials. Skip the cloud account step.
Run the deployment on your cluster
1
Watch the pods
In a terminal, run:
2
Run the template
In env zero, open your project, find the template under Project Templates, click Run Now, and click Run.
kubectl output and stays as Completed after the deployment finishes, until the agent trigger cleans up old jobs (10 successful jobs are kept by default). In env zero, the environment status changes to Active, and the deployment log lists the null_resource that Terraform created.
If the deployment stays queued or fails, see Troubleshooting and the deployment troubleshooting notes.
Clean up
Open the environment and click Destroy. Thenull_resource holds no cloud cost, but destroying it keeps your project clean.
Next steps
- Self-hosted agents overview - Manage pools, rotate secrets, and delete agents.
- Custom/optional configuration - Set resource limits and other Helm values.
- Authenticating the agent on AWS EKS - Give the agent an IAM role for cloud deployments.
- HA/DR strategy for self-hosted agents - Plan for agent failure.