|
| 1 | +# Use your own custom images |
| 2 | + |
| 3 | +By default, `elastic-package stack up` command starts the required docker images for each service. |
| 4 | + |
| 5 | +Setting `--version` flag, you can start the Elastic stack using different versions, for instance SNAPSHOT version (e.g. 8.8.2-SNAPSHOT). |
| 6 | +If this flag is not set, the default version used is by elastic-package is defined [here](../../internal/install/stack_version.go). |
| 7 | + |
| 8 | +There could be cases where you need to use your own custom images for development or debugging purposes. |
| 9 | +If you need to use your own custom docker images for your service (e.g. elastic-agent), this could be |
| 10 | +achieved in two different ways: |
| 11 | +- [defining environment variables](#using-environment-variables) |
| 12 | +- [updating elastic-package configuration file](#using-the-configuration-file) |
| 13 | + |
| 14 | +If both ways are used, environment variables have preference to set the custom image. |
| 15 | + |
| 16 | +The current images that could be overwritten are: |
| 17 | + |
| 18 | +| Service | Environment Variable | Entry configuration file | |
| 19 | +| --- | --- | --- | |
| 20 | +| Elasticsearch | ELASTICSEARCH_IMAGE_REF_OVERRIDE | elasticsearch | |
| 21 | +| Kibana | KIBANA_IMAGE_REF_OVERRIDE | kibana | |
| 22 | +| Elastic Agent | ELASTIC_AGENT_IMAGE_REF_OVERRIDE | elastic-agent | |
| 23 | + |
| 24 | + |
| 25 | +For the following two examples, it will be used as example overwriting elastic-agent image. |
| 26 | +You can find here the instructions to create the docker images for the examples ([docs link](https://github.com/elastic/elastic-agent#packaging)): |
| 27 | + |
| 28 | +```bash |
| 29 | +# Go to elastic-agent repository and create the packages for docker |
| 30 | +git checkout 8.8 # or the required tag like v8.8.* |
| 31 | +DEV=true SNAPSHOT=true EXTERNAL=true PLATFORMS=linux/amd64 PACKAGES=docker mage -v package |
| 32 | + |
| 33 | +docker tag docker.elastic.co/beats/elastic-agent-complete:8.8.2-SNAPSHOT docker.elastic.co/beats/elastic-agent-complete:8.8.2-SNAPSHOT-test |
| 34 | + |
| 35 | +git checkout v8.8.1 |
| 36 | +DEV=true SNAPSHOT=true EXTERNAL=true PLATFORMS=linux/amd64 PACKAGES=docker mage -v package |
| 37 | + |
| 38 | +docker tag docker.elastic.co/beats/elastic-agent-complete:8.8.1-SNAPSHOT docker.elastic.co/beats/elastic-agent-complete:8.8.1-SNAPSHOT-test |
| 39 | +docker tag docker.elastic.co/beats/elastic-agent-complete:8.8.1-SNAPSHOT docker.elastic.co/beats/elastic-agent-complete:8.8.1-SNAPSHOT-foo |
| 40 | +``` |
| 41 | + |
| 42 | +## Using Environment variables |
| 43 | + |
| 44 | +Depending on the service you need to use a custom image, you need to set a different environment variable. |
| 45 | + |
| 46 | +Following the example of elastic-agent, it is required to define the `ELASTICSEARCH_IMAGE_REF_OVERRIDE` environment variable before running `elastic-package stack up`: |
| 47 | +``` |
| 48 | +export ELASTIC_AGENT_IMAGE_REF="docker.elastic.co/beats/elastic-agent-complete:8.8.2-SNAPSHOT-test" |
| 49 | +elastic-package stack up -v -d --version 8.8.0-SNAPSHOT |
| 50 | +``` |
| 51 | + |
| 52 | +Once the Elastic stack is running, you can check that the docker image used for the elastic-agent image is now the one it was built: |
| 53 | + |
| 54 | +```bash |
| 55 | + $ docker ps --format "{{.Names}} {{.Image}}" |
| 56 | +elastic-package-stack-elastic-agent-1 docker.elastic.co/beats/elastic-agent-complete:8.8.2-SNAPSHOT-test |
| 57 | +elastic-package-stack-fleet-server-1 docker.elastic.co/beats/elastic-agent-complete:8.8.2-SNAPSHOT-test |
| 58 | +elastic-package-stack-kibana-1 docker.elastic.co/kibana/kibana:8.8.2-SNAPSHOT |
| 59 | +elastic-package-stack-elasticsearch-1 docker.elastic.co/elasticsearch/elasticsearch:8.8.2-SNAPSHOT |
| 60 | +elastic-package-stack-package-registry-1 elastic-package-stack-package-registry |
| 61 | +``` |
| 62 | + |
| 63 | +## Using the configuration file |
| 64 | + |
| 65 | +These custom version or images can also be defined in the configuration file that is located at |
| 66 | +`~/.elastic-package/config.yml`. |
| 67 | + |
| 68 | +```yaml |
| 69 | +stack: |
| 70 | + image_ref_overrides: {} |
| 71 | +profile: |
| 72 | + current: default |
| 73 | +``` |
| 74 | +
|
| 75 | +To define the same elastic-agent image as in the previous section without any environment variable, |
| 76 | +it should be added a map for each Elastic stack version (e.g. 8.8.2-SNAPSHOT) under `image_ref_overrides` key. |
| 77 | +Each Elastic stack map would contain the required custom images. |
| 78 | + |
| 79 | +It is important to note that Elastic stack version set in this configuration file must match with the version |
| 80 | +set in the `--version` flag. |
| 81 | + |
| 82 | +For instance, the following configuration file sets a custom image for Elastic stack versions `8.8.2-SNAPSHOT` and `8.8.1-SNAPSHOT`: |
| 83 | + |
| 84 | +```yaml |
| 85 | +stack: |
| 86 | + image_ref_overrides: |
| 87 | + 8.8.2-SNAPSHOT: |
| 88 | + elastic-agent: docker.elastic.co/beats/elastic-agnet-complete:8.8-2-SNAPSHOT-test |
| 89 | + # elasticsearch: <elasticsearch_image> |
| 90 | + # kibana: <kibana_image> |
| 91 | + 8.8.1-SNAPSHOT: |
| 92 | + elastic-agent: docker.elastic.co/beats/elastic-agnet-complete:8.8-1-SNAPSHOT-test |
| 93 | + # elasticsearch: <elasticsearch_image> |
| 94 | + # kibana: <kibana_image> |
| 95 | +profile: |
| 96 | + current: default |
| 97 | +``` |
| 98 | + |
| 99 | +If Elastic stack version `8.8.1` is started, then there would not be any custom image spun up. |
| 100 | + |
| 101 | +Some examples with the given configuration file: |
| 102 | + |
| 103 | +```bash |
| 104 | + $ elastic-stack up -v --version 8.8.1-SNAPSHOT |
| 105 | + $ docker ps --format "{{.Names}} {{.Image}}" |
| 106 | +elastic-package-stack-elastic-agent-1 docker.elastic.co/beats/elastic-agent-complete:8.8.1-SNAPSHOT-test |
| 107 | +elastic-package-stack-fleet-server-1 docker.elastic.co/beats/elastic-agent-complete:8.8.1-SNAPSHOT-test |
| 108 | +elastic-package-stack-kibana-1 docker.elastic.co/kibana/kibana:8.8.1-SNAPSHOT |
| 109 | +elastic-package-stack-elasticsearch-1 docker.elastic.co/elasticsearch/elasticsearch:8.8.1-SNAPSHOT |
| 110 | +elastic-package-stack-package-registry-1 elastic-package-stack-package-registry |
| 111 | +
|
| 112 | + $ elastic-stack up -v --version 8.8.2-SNAPSHOT |
| 113 | + $ docker ps --format "{{.Names}} {{.Image}}" |
| 114 | +elastic-package-stack-elastic-agent-1 docker.elastic.co/beats/elastic-agent-complete:8.8.2-SNAPSHOT-test |
| 115 | +elastic-package-stack-fleet-server-1 docker.elastic.co/beats/elastic-agent-complete:8.8.2-SNAPSHOT-test |
| 116 | +elastic-package-stack-kibana-1 docker.elastic.co/kibana/kibana:8.8.2-SNAPSHOT |
| 117 | +elastic-package-stack-elasticsearch-1 docker.elastic.co/elasticsearch/elasticsearch:8.8.2-SNAPSHOT |
| 118 | +elastic-package-stack-package-registry-1 elastic-package-stack-package-registry |
| 119 | +
|
| 120 | + $ elastic-stack up -v --version 8.8.1 |
| 121 | + $ docker ps --format "{{.Names}} {{.Image}}" |
| 122 | +elastic-package-stack-elastic-agent-1 docker.elastic.co/elastic-agent/elastic-agent-complete:8.8.1 |
| 123 | +elastic-package-stack-fleet-server-1 docker.elastic.co/elastic-agent/elastic-agent-complete:8.8.1 |
| 124 | +elastic-package-stack-kibana-1 docker.elastic.co/kibana/kibana:8.8.1 |
| 125 | +elastic-package-stack-elasticsearch-1 docker.elastic.co/elasticsearch/elasticsearch:8.8.1 |
| 126 | +elastic-package-stack-package-registry-1 elastic-package-stack-package-registry |
| 127 | +``` |
0 commit comments