Skip to content

Commit bccf68b

Browse files
authored
Merge pull request kubernetes#81662 from bclau/test-images/documentation-update
test images: Adds README containing image building process
2 parents 927f451 + 210d762 commit bccf68b

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

test/images/README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Kubernetes test images
2+
3+
## Overview
4+
5+
All the images found here are used in Kubernetes tests that ensure its features and functionality.
6+
The images are built and published as manifest lists, allowing multiarch and cross platform support.
7+
8+
This guide will provide information on how to: make changes to images, bump their version, build the
9+
new images, test the changes made.
10+
11+
12+
## Prerequisites
13+
14+
In order to build the docker test images, a Linux node is required. The node will require `make`
15+
and `docker (version 18.06.0 or newer)`. Manifest lists were introduced in 18.03.0, but 18.06.0
16+
is recommended in order to avoid certain issues.
17+
18+
The node must be able to push the images to the desired container registry, make sure you are
19+
authenticated with the registry you're pushing to.
20+
21+
22+
## Making changes to images
23+
24+
There are several thousands of tests in Kubernetes E2E testing. Not all of them are being run on
25+
new PRs, and thus, not all images are used, especially those that are not used by Conformance tests.
26+
27+
So, in order to prevent regressions in the images and failing jobs, any changes made to the image
28+
itself or its binaries will require the image's version to be bumped. In the case of a regression
29+
which cannot be immediately resolved, the image version used in E2E tests will be reverted to the
30+
last known stable version.
31+
32+
The version can easily be bumped by modifying the file `test/images/${IMAGE_NAME}/VERSION`, which will
33+
be used when building the image. Additionally, for the `agnhost` image, also bump the `Version` in
34+
`test/images/agnhost/agnhost.go`.
35+
36+
The typical image used in E2E testing is the `agnhost` image. It contains several subcommands with
37+
different [functionalities](agnhost/README.md), used to validate different Kubernetes behaviours. If
38+
a new functionality needs testing, consider adding an `agnhost` subcommand for it first, before
39+
creating an entirely separate test image.
40+
41+
Some test images (`mounttest`, `test-webserver`) are used as bases for other images (`mounttest-user`,
42+
`kitten`, `nautilus`). If the parent image's `VERSION` has been bumped, also bump the version in the
43+
children's `BASEIMAGE` files in order for base image changes to be reflected in the child images as well.
44+
45+
TODO: Once [Centralization part 4](https://github.com/kubernetes/kubernetes/pull/81226) merges, the paragraph
46+
above will have to be updated, as those images will be included into `agnhost`.
47+
48+
After the desired changes have been made, the affected images will have to be built and published,
49+
and then tested. After the pull request with those changes has been approved, the new images will be
50+
built and published to the `gcr.io/kubernetes-e2e-test-images` registry as well.
51+
52+
53+
## Building images
54+
55+
The images are built through `make`. Since some images (`mounttest`, `test-webserver`)
56+
are used as a base for other images, it is recommended to build them first, if needed.
57+
58+
TODO: Once [Centralization part 4](https://github.com/kubernetes/kubernetes/pull/81226) merges, the paragraph
59+
above will have to be updated, as those images will be included into `agnhost`.
60+
61+
An image can be built by simply running the command:
62+
63+
```bash
64+
make all WHAT=test-webserver
65+
```
66+
67+
To build AND push an image, the following command can be used:
68+
69+
```bash
70+
make all-push WHAT=test-webserver
71+
```
72+
73+
By default, the images will be tagged and pushed under the `gcr.io/kubernetes-e2e-test-images`
74+
registry. That can changed by running this command instead:
75+
76+
```bash
77+
REGISTRY=foo_registry make all-push WHAT=test-webserver
78+
```
79+
80+
*NOTE* (for test `gcr.io` image publishers): Some tests (e.g.: `should serve a basic image on each replica with a private image`)
81+
require the `agnhost` image to be published in an authenticated repo as well:
82+
83+
```bash
84+
REGISTRY=gcr.io/kubernetes-e2e-test-images make all-push WHAT=agnhost
85+
REGISTRY=gcr.io/k8s-authenticated-test make all-push WHAT=agnhost
86+
```
87+
88+
89+
## Testing the new image
90+
91+
Once the image has been built and pushed to an accesible registry, you can run the tests using that image
92+
by having the environment variable `KUBE_TEST_REPO_LIST` set before running the tests that are using the
93+
image:
94+
95+
```bash
96+
export KUBE_TEST_REPO_LIST=/path/to/repo_list.yaml
97+
```
98+
99+
`repo_list.yaml` is a configuration file used by the E2E tests, in which you can set alternative registries
100+
to pull the images from. Sample file:
101+
102+
```yaml
103+
dockerLibraryRegistry: your-awesome-registry
104+
e2eRegistry: your-awesome-registry
105+
gcRegistry: your-awesome-registry
106+
sampleRegistry: your-awesome-registry
107+
```
108+
109+
Keep in mind that some tests are using multiple images, so it is a good idea to also build and push those images.
110+
111+
Finally, make sure to bump the image version used in E2E testing by modifying the file `test/utils/image/manifest.go`, and recompile afterwards:
112+
113+
```bash
114+
./build/run.sh make WHAT=test/e2e/e2e.test
115+
```
116+
117+
After all the above has been done, run the desired tests.
118+
119+
120+
## Known issues and workarounds
121+
122+
`docker manifest create` fails due to permission denied on `/etc/docker/certs.d/gcr.io` (https://github.com/docker/for-linux/issues/396). This issue can be resolved by running:
123+
124+
```bash
125+
sudo chmod o+x /etc/docker
126+
```

0 commit comments

Comments
 (0)