CHIEF US spymaster David Petraeus, who gained international notoriety as military commander in the Iraq and Afghanistan wars, has resigned form his post as CIA director over an extramarital affair, bringing an abrupt and ignominious end to a brilliant government career.