New Zealand's most-capped player Sam Whitelock will retire from rugby at the end of the French club season.