He is not completely immune; he possesses a certain level of immunity that reduces the damage received, but he still takes damage.
Considering that it's an awakened Luffy, the conqueror of death, when he struck him, he temporarily knocked him out, but as he's an awakened Zoan, he regained consciousness.
But it makes sense for him to have that certain immunity against Kaido, as he's the Joyboy destined to defeat Kaido. Therefore, having a slight advantage in the matchup is expected. However, Kaido compensates for this advantage by having greater endurance and being a superior fighter. He was essentially overpowering G5 while G5 screamed in pain and claimed to be finished after a Ragnarok attack. So, the damage Kaido inflicts on G5, even though somewhat reduced, is still significant. Moreover, Kaido has other means to harm Luffy, such as through flames, wind slashes, and the flaming Bagua technique. Hence, Kaido isn't entirely defenseless.