Extending the docker image on an agent
If you'd like, you can use your own custom docker image with the Kubernetes agent. That way you can add anything you want that is lacking in the base image.
In order to do that, you'd need to:
- Download our base image to your local docker
- Create a Dockerfile off of that image
- Build your custom image and push it to your repository
- Edit the docker image in the agent values
Downloading the base image
- Find the base image tag you're using. Find the helm value of
dockerImage
in your installation. It should be in the following format:ghcr.io/env0/deployment-agent:<image_tag>
- Create a docker config file that has permission to pull the base image: Take the helm value of
agentImagePullSecret
, decode it from base64 and you'll get a JSON. Save that JSON locally in the current folder, in a file namedconfig.json
- Pull the image using this config
# <agentImagePullSecret> should be replaced with the agentImagePullSecret value from helm
# ghcr.io/env0/deployment-agent:<image_tag> is the base image from dockerImage value from helm
echo -n "<agentImagePullSecret>" | openssl base64 -d -A >> config.json
docker --config . pull ghcr.io/env0/deployment-agent:<image_tag>
Create a Dockerfile
Create a Dockerfile based on the image that was downloaded. There are some limitations to the Dockerfile. Read the comments on the template for more information:
# Use the env0 image as the base image
FROM ghcr.io/env0/deployment-agent:<image_tag>
# Enter your custom docker configuration here
# Make sure there is NO ENTRYPOINT in this file
# If you'd like to use CMD, make sure to add `&& npm start` at the end of it
Build the custom image and push it to your own repository
Build your image and push it to your own image repository
# <remote-repository> is the remote image repository you want to use
# <image-tag> is the tag you want for the custom iamge
docker build . -t <remote-rpository>:<image-tag>
docker push <remote-repository>:<image-tag>
Use the custom image in the env0 agent
Now you simply have to overwrite the helm values of agentImagePullSecret
and dockerImage
to match your own custom image
dockerImage
should be :agentImagePullSecret
should be a base64 encoding of the docker config used to pull the image- Perform a
helm upgrade
with those new values
# This should be the image and tag of the custom image you have created
export ENV0_CUSTOM_IMAGE="<remote-repository>:<image-tag>"
# This is a base64 encoded docker config used for pulling the image
# By default, the config file is in ~/.docker/config.json. Change it if you are using a custom config
export ENV0_AGENT_IMAGE_PULL_SECRET=$(cat ~/.docker/config.json | openssl base64 -A)
# Add those values to your custom values yaml, values.customer.yml
echo "dockerImage: $ENV0_CUSTOM_IMAGE" >> values.customer.yml
echo "agentImagePullSecret: $ENV0_AGENT_IMAGE_PULL_SECRET" >> values.customer.yml
# Update your agent with the new image
helm upgrade -f values.yaml -f values.customer.yml
Updated about 1 year ago