public boolean writeExternalAddress() {
        List<NodeAddress> addresses = client.nodes().withName(config.getNodeName()).get().getStatus().getAddresses();
        StringBuilder externalAddresses = new StringBuilder();

        String address = NodeUtils.findAddress(addresses, null);

        if (address == null) {
            LOGGER.error("External address not found");
            return false;
        } else  {
            LOGGER.info("Default External address found {}", address);
            externalAddresses.append(externalAddressExport(null, address));
        }

        for (NodeAddressType type : NodeAddressType.values())   {
            address = NodeUtils.findAddress(addresses, type);
            LOGGER.info("External {} address found {}", type.toValue(), address);
            externalAddresses.append(externalAddressExport(type, address));
        }

        return write(FILE_EXTERNAL_ADDRESS, externalAddresses.toString());
    }
@Test
    public void testWriteExternalAddress() throws IOException {

        // create and configure (env vars) the path to the rack-id file
        File kafkaFolder = new File(tempDir.getPath(), "/opt/kafka");
        String addressFolder = kafkaFolder.getAbsolutePath() + "/external.address";
        new File(addressFolder).mkdirs();

        Map<String, String> envVars = new HashMap<>(ENV_VARS);
        envVars.put(InitWriterConfig.INIT_FOLDER.key(), addressFolder);

        InitWriterConfig config = InitWriterConfig.fromMap(envVars);

        KubernetesClient client = mockKubernetesClient(config.getNodeName(), Map.of(), ADDRESSES);

        InitWriter writer = new InitWriter(client, config);
        assertThat(writer.writeExternalAddress(), is(true));
        assertThat(readFile(addressFolder + "/external.address"), is("export STRIMZI_NODEPORT_DEFAULT_ADDRESS=my.external.address\n" +
                "export STRIMZI_NODEPORT_EXTERNALIP_ADDRESS=my.external.address\n" +
                "export STRIMZI_NODEPORT_EXTERNALDNS_ADDRESS=my.external.address\n" +
                "export STRIMZI_NODEPORT_INTERNALIP_ADDRESS=192.168.2.94\n" +
                "export STRIMZI_NODEPORT_INTERNALDNS_ADDRESS=my.internal.address\n" +
                "export STRIMZI_NODEPORT_HOSTNAME_ADDRESS=my.external.address\n"));
    }