New Zealand's military chief, Air Marshal Tony Davies, has resigned following his admission of an inappropriate relationship as a unit leader.