Esper fired Spenser. Esper told Spenser to write a resignation letter on Sunday and deliver it to Trump the same day. This happened before Trump tweeting anything related. Trump became aware of the termination as a result of the resignation letter and tweeted as a result.
Here is an article where Esper explains why he fired Spenser to Pentagon officials. https://townhall.com/tipsheet/cortneyobrien/2019/11/25/esper...