Confucius didn’t “do god” in the sense of worshiping a specific deity or religion, but he did subscribe to a belief in the idea of an all-seeing and all-knowing “Heaven” (天/tiān) that acted as a sort of moral guide for the world and bestowed its goodness and wisdom on worthy individuals who would lead it out of chaos and darkness.
These included the ancient sage kings Yao and Shun, as well as the founders of the Xia, Shang, and Zhou dynasties, all of whom Confucius believed were given a mandate by Heaven to restore peace and prosperity to the world. Confucius also included his great hero on the Duke of Zhou on the list, as well as his own good self.
When he says that at the age of fifty “I knew the will of Heaven” in Chapter IV of Book 2, Confucius is indicating that he understood and embraced the mission it had given to him: namely to return his conflict-riven land to its former glory by restoring the traditional moral values exemplified by the Duke of Zhou when laying the foundations for the growth of the Zhou Dynasty.
The irony is, of course, that Confucius singularly failed in the mission that he believed Heaven had given him – at least in his own lifetime. Perhaps the proliferation of his teachings among subsequent generations shows that he was right about it after all and that Heaven was just operating on a different time scale.
As the old saying goes, Heaven works in mysterious ways.