|
| 1 | +# azure-ip-masq-merger |
| 2 | + |
| 3 | +`azure-ip-masq-merger` is a utility for merging multiple ip-masq-agent configuration files into a single, valid configuration for use in Kubernetes clusters. |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +The goal of this program is to periodically scan a directory for configuration fragments (YAML or JSON files starting with `ip-masq`), validate and merge them, and write the resulting configuration to a target directory for consumption. This allows us to combine non-masquerade CIDRs and related options between multiple files, for example if we had one ip masq config managed by the cloud provider and another supplied by the user. |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +Follow the steps below to build and run the program: |
| 12 | + |
| 13 | +1. Build the binary using `make`: |
| 14 | + ```bash |
| 15 | + make azure-ip-masq-merger |
| 16 | + ``` |
| 17 | + or make an image: |
| 18 | + ```bash |
| 19 | + make azure-ip-masq-merger-image |
| 20 | + ``` |
| 21 | + |
| 22 | +2. Deploy or copy the binary to your node(s). |
| 23 | + |
| 24 | +3. Prepare your configuration fragments in the input directory (see below for defaults). Each file should be named with the prefix `ip-masq` and contain valid YAML or JSON for the ip-masq-agent config. |
| 25 | + |
| 26 | +4. Start the program with: |
| 27 | + ```bash |
| 28 | + ./azure-ip-masq-merger --input=/etc/config/ --output=/etc/merged-config/ |
| 29 | + ``` |
| 30 | + - The `--input` flag specifies the directory to scan for config fragments. Default: `/etc/config/` |
| 31 | + - The `--output` flag specifies where to write the merged config. Default: `/etc/merged-config/` |
| 32 | + |
| 33 | +5. The merged configuration will be written to the output directory as `ip-masq-agent`. If no valid configs are found, any existing merged config will be removed. |
| 34 | + |
| 35 | +## Manual Testing |
| 36 | + |
| 37 | +You can test the merger locally by creating sample config files in your input directory and running the merger. |
| 38 | + |
| 39 | +## Configuration File Format |
| 40 | + |
| 41 | +Each config fragment should be a YAML or JSON file that may have the following fields: |
| 42 | +```yaml |
| 43 | +nonMasqueradeCIDRs: |
| 44 | + - 10.0.0.0/8 |
| 45 | + - 192.168.0.0/16 |
| 46 | +masqLinkLocal: true |
| 47 | +masqLinkLocalIPv6: false |
| 48 | +``` |
| 49 | +- `nonMasqueradeCIDRs`: List of CIDRs that should not be masqueraded. Appended between configs. |
| 50 | +- `masqLinkLocal`: Boolean to enable/disable masquerading of link-local addresses. OR'd between configs. |
| 51 | +- `masqLinkLocalIPv6`: Boolean to enable/disable masquerading of IPv6 link-local addresses. OR'd between configs. |
| 52 | + |
| 53 | +## Debugging |
| 54 | + |
| 55 | +Logs are output to standard error. Increase verbosity with the `-v` flag: |
| 56 | +```bash |
| 57 | +./azure-ip-masq-merger -v 2 |
| 58 | +``` |
| 59 | + |
| 60 | +## Development |
| 61 | + |
| 62 | +To run tests: |
| 63 | +```bash |
| 64 | +go test ./... |
| 65 | +``` |
| 66 | +or at the repository level: |
| 67 | +```bash |
| 68 | +make test-azure-ip-masq-merger |
| 69 | +``` |
0 commit comments