CNN national security analyst John Kirby, a retired rear admiral in the US Navy, was a spokesman for both the State and Defense Departments in the Obama administration. The opinions expressed in this commentary, adapted from a speech delivered at the Sorensen Institute for Political Leadership, are his own. View more opinion articles on CNN.

(CNN) Secretary of Defense James Mattis submitted his resignation on Thursday. It was an honorable thing to do. But it wasn't much of a choice. He did exactly what military tradition demands when one can't ethically or morally support the boss anymore.

It's a wonder, quite frankly, that it took this long. It's arguably one of the worst kept secrets in town that Mattis has not been aligned with Trump on many policy issues.

He opposed the President's decision to ban transgender troops from service. He slow-rolled Trump's ridiculous desire for a grand military parade . According to Bob Woodward, Mattis had to personally intervene to convince the President not to remove American troops from the Korean peninsula

Mattis failed to convince Trump to stay in the Iran deal. He is rumored not to have supported moving the US Embassy to Jerusalem. He went out of his way to shore up NATO allies after Trump bludgeoned them over defense spending. And he was in favor of a defense strategy that went straight at Russia and China , two countries Trump hates to criticize.

But it's been a particularly bad couple of months for the defense chief. In late October, Trump announced that he was ordering thousands of troops to the southern border, ostensibly to shore up border patrol personnel. Mattis bristled at critics who called it a "political stunt," but there is scant evidence to suggest he was happy about Trump's decision. And some believe he was incensed that Trump blew off his recommendation for the next joint chiefs chairman and chose the Army Chief of Staff, Gen. Mark Milley, despite Mattis' objection.

Then there is the President's rash and reckless decision to rapidly pull US troops out of Syria, made again over his defense secretary's demurrals and apparently with little notice and no consultation with Congress or our allies and partners. This appears to have been the last straw for the defense secretary.

In his resignation letter, Mattis made it clear that those alliances are important.

"One core belief I have always held," wrote Mattis "is that our strength as a nation is inextricably linked to the strength of our unique and comprehensive system of alliances and partnerships. While the US remains the indispensable nation in the free world, we cannot protect our interests or serve that role effectively without maintaining strong alliances and showing respect to those allies."

This from a man who spent a lifetime fighting alongside sister services and troops from scores of other nations -- to a man who seems only to think of allies as leeches or losers.

There is one line, however, in that extraordinary letter with which I disagree. Mattis tells Trump that the President has "the right to have a Secretary of Defense whose views are better aligned" with Trump's own. I suppose in the macro sense that is true.

A president's cabinet typically reflects and supports his worldview and his general vision for the country. But what any commander-in-chief needs most -- especially in these challenging times -- is a secretary of defense who can speak truth to power, who can challenge his thinking, and who can marshal the moral fiber when needed to move those worldviews into a better place.

They don't have to aligned or even alike.

As was once said of Abraham Lincoln and his War Secretary Edwin Stanton, "No two men were ever more utterly and irreconcilably unlike. The secretiveness which Lincoln wholly lacked, Stanton had in marked degree; the charity which Stanton could not feel, coursed from every pore in Lincoln."

And yet, "no two men ever did or could work better in harness. They supplemented each other's nature, and they fully recognized that they were a necessity of each other."

Mattis did the honorable thing. He resigned. But he really had no choice.

Trump now does have a choice. He can select an ideologue to succeed Mattis -- a lap dog, someone who shares Trump's disdain for alliances, diplomacy, strategy and multi-lateral institutions, someone who will not challenge his thinking, someone comfortable with the further abdication of American leadership on the world stage.

Stay up to date... Sign up for our new newsletter. Join us on Twitter and Facebook

Or he can go the other way. He can prove unafraid to be so challenged, to be unmoved by the discomfort of having a defense secretary like the one he just lost -- courageous and calm -- someone who is "a necessity" to this particular commander-in-chief.

I suspect we already know which path he'll take -- which means we already know which path American leadership will take.