|
| 1 | +# Agnhost |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +There are significant differences between Linux and Windows, especially in the way |
| 6 | +something can be obtained or tested. For example, the DNS suffix list can be found in |
| 7 | +`/etc/resolv.conf` on Linux, but on Windows, such file does not exist, the same |
| 8 | +information could retrieved through other means. To combat those differences, |
| 9 | +`agnhost` was created. |
| 10 | + |
| 11 | +`agnhost` is an extendable CLI that behaves and outputs the same expected content, |
| 12 | +no matter the underlying OS. The name itself reflects this idea, being a portmanteau |
| 13 | +word of the words agnost and host. |
| 14 | + |
| 15 | +The image was created for testing purposes, reducing the need for having different test |
| 16 | +cases for the same tested behaviour. |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +The `agnhost` binary is a CLI with the following subcommands: |
| 21 | + |
| 22 | +- `dns-suffix`: It will output the host's configured DNS suffix list, separated by commas. |
| 23 | +- `dns-server-list`: It will output the host's configured DNS servers, separated by commas. |
| 24 | +- `etc-hosts`: It will output the contents of host's `hosts` file. This file's location |
| 25 | + is `/etc/hosts` on Linux, while on Windows it is `C:/Windows/System32/drivers/etc/hosts`. |
| 26 | +- `pause`: It will pause the execution of the binary. This can be used for containers |
| 27 | + which have to be kept in a `Running` state for various purposes, including executing |
| 28 | + other `agnhost` commands. |
| 29 | +- `help`: Prints the binary's help menu. Additionally, it can be followed by another |
| 30 | + subcommand in order to get more information about that subcommand, including its |
| 31 | + possible arguments. |
| 32 | + |
| 33 | +For example, let's consider the following `pod.yaml` file: |
| 34 | + |
| 35 | +```yaml |
| 36 | + apiVersion: v1 |
| 37 | + kind: Pod |
| 38 | + metadata: |
| 39 | + name: test-agnhost |
| 40 | + spec: |
| 41 | + containers: |
| 42 | + - args: |
| 43 | + - dns-suffix |
| 44 | + image: gcr.io/kubernetes-e2e-test-images/agnhost:1.0 |
| 45 | + name: agnhost |
| 46 | + dnsConfig: |
| 47 | + nameservers: |
| 48 | + - 1.1.1.1 |
| 49 | + searches: |
| 50 | + - resolv.conf.local |
| 51 | + dnsPolicy: None |
| 52 | +``` |
| 53 | +
|
| 54 | +After we've used it to create a pod: |
| 55 | +
|
| 56 | +```console |
| 57 | + kubectl create -f pod.yaml |
| 58 | +``` |
| 59 | + |
| 60 | +We can then check the container's output to see what is DNS suffix list the Pod was |
| 61 | +configured with: |
| 62 | + |
| 63 | +```console |
| 64 | + kubectl logs pod/test-agnhost |
| 65 | +``` |
| 66 | + |
| 67 | +The output will be `resolv.conf.local`, as expected. Alternatively, the Pod could be |
| 68 | +created with the `pause` argument instead, allowing us execute multiple commands: |
| 69 | + |
| 70 | +```console |
| 71 | + kubectl exec test-agnhost -- /agnhost dns-suffix |
| 72 | + kubectl exec test-agnhost -- /agnhost dns-server-list |
| 73 | +``` |
| 74 | + |
| 75 | +## Image |
| 76 | + |
| 77 | +The image can be found at `gcr.io/kubernetes-e2e-test-images/agnhost:1.0` for Linux |
| 78 | +containers, and `e2eteam/agnhost:1.0` for Windows containers. In the future, the same |
| 79 | +repository can be used for both OSes. |
0 commit comments