A suicide bomber has detonated an explosive vest at a compound in northern Afghanistan, killing six people, including two German soldiers.