0

I'm trying to resolve mx records in a kubernetes pod. The dnsjava library works when tested on mac and ubuntu outside of a container but returns an empty array once deployed.

What needs to be available in k8s or the docker image for this to work?

See https://github.com/dnsjava/dnsjava

EDIT 1

  Record[] records;
  try {
    records = new Lookup(mailDomain, Type.MX).run();
  } catch (TextParseException e) {
    throw new IllegalStateException(e);
  }
  if (records != null && records.length > 0) {
    for (final Record record : records) {
      MXRecord mx = (MXRecord) record;
      //do something with mx...
    }
  } else {
    log.warn("Failed to determine MX record for {}", mailDomain);
  }

The log.warn is always executed in K8s. The docker image is openjdk:11-jdk-slim i.e. it's Debian. I just tested on Debian outside of Docker and it worked as well.

2
  • If it works in ubuntu did you try in ubuntu container? Could you elaborate a bit how you are testing it and what output you received? Commented Aug 21, 2020 at 7:52
  • I've edited to provide more info. There is no output, either run is returning null or an empty array. I'm testing by calling an API which the app provides which then calls the above code. I call the same API in and outside of the container Commented Aug 21, 2020 at 8:48

1 Answer 1

0

In the end I couldn't get dnsjava to work in docker/k8s. I used JNDI directly, following https://stackoverflow.com/a/16448180/400048 this works without any issues exactly as given in that answer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.