Extending Deployment Image
env zero self-hosted Kubernetes agent allows you to run deployments on your own infrastructure, giving you more control and security. While the default deployment image includes all the necessary tools for env zero’s native features, you may need to install additional tools or specific versions of existing tools to support your custom workflows. This guide will walk you through extending the default deployment image to meet your specific needs.Why Extend the Deployment Image?
Extending the deployment image is necessary when you want to:- Use custom tools: If your deployment process relies on tools that are not included in the base image, such as specific CLI tools, testing frameworks, or security scanners.
- Pre-install env zero supported tools: To save network bandwidth and reduce deployment times, you can pre-install tools that env zero supports but doesn’t include in the base image.
- Standardize your environment: Ensure that all your deployments run in a consistent environment with the exact tool versions your organization requires.
Creating a Custom Dockerfile
To extend the base image, you’ll need to create a Dockerfile that uses the env zero deployment image as its base and then adds your custom tools and configurations. Here’s an example of a Dockerfile that pre-installs theaws
and gcloud
CLIs with a specific version for gcloud:
Dockerfile
RUN
commands to install your own custom tools or perform other setup tasks.
Available tools
These tools can be pre-installed in your image using the install-package-cli.js script provided by env0. This script ensures that the specified CLI tools are available during runtime without requiring installation in your deployment steps.Build Your Own Image from a Custom Base Image
For advanced use cases, you might want to use your own company’s base image, which may already be hardened and configured according to your internal standards. This approach allows you to layer the env zero agent capabilities on top of your existing infrastructure.This is an experimental featureBuilding on a custom base image is not officially supported and may lead to unexpected behavior. While it can work, we cannot guarantee that all env zero features will function correctly. Proceed with caution and test thoroughly.
curl
git
gnupg
jq
nodejs
Example Dockerfile using a Custom Base
You can create a Dockerfile that uses your image as a base and copies the necessary env zero agent files from the official image. A multi-stage build is the recommended approach for this. The package installation commands (apt-get) in the example are for Debian-based systems and should be adapted for your image’s specific package manager.Dockerfile
Updating the Agent Configuration
After you have built your custom Docker image and pushed it to a container registry, you need to configure your env zero agent to use this new image. This is done by updating the Helm chart values for your agent installation. You will need to modify the following values in yourvalues.yaml
file:
dockerImage
: Set this to the URL of your custom Docker image in your container registry.agentImagePullSecret
(Optional): If your container registry requires authentication, you’ll need to create a Kubernetes secret with the credentials and specify the name of the secret here.
values.yaml
file:
values.yaml
values.yaml
file, apply the changes to your Helm release to update the agent with the new image.