Even so, South Africa seemed well-placed until Mohammed Shami made a double strike shortly before tea.
With batting conditions seemingly easier in bright sunshine than on the overcast first day, South Africa reached 159 for four, with Petersen and Bavuma both batting relatively comfortably.
But the consistently accurate Shami produced a ball which climbed on Bavuma, forcing an edge which was taken by Kohli at second slip.
Two balls later Kyle Verreynne prodded at a good-length delivery from Shami and was caught behind, leaving South Africa with no more recognised batsmen.
Bumrah followed by bowling Jansen with the last ball before tea and then had Petersen caught at first slip in the second over after the interval.
Petersen had to face the third ball of the morning after Aiden Markram padded up and was bowled by an in-swinger from Bumrah without a run added to the overnight 17 for one.
When nightwatchman Keshav Maharaj was bowled by Umesh Yadav for 25, South Africa were precariously placed at 45 for three.
The slightly-built Petersen batted with skill and application in partnerships of 67 with Rassie van der Dussen (21) and 47 with Bavuma before Shami struck.
His 72, which came off 166 balls and included nine fours, was his second half-century following the 62 he made in the first innings in the previous Test at the Wanderers.
Bumrah, though, was India's most effective bowler.
He dismissed South African captain Dean Elgar on the first evening and posed problems for all the batsmen on a pitch which still offered good bounce and some seam movement for the bowlers.
Rabada had a hostile opening spell when India started their second innings. Mayank Agarwal was given out caught behind but won a reprieve when a review showed the ball had brushed a pad and not the inside edge of his bat.
But Agarwal made only seven before edging Rabada to Elgar at first slip. Jansen struck in the next over when KL Rahul was caught at second slip.
Pujara and Kohli prevented any further breakthroughs before the close of play.