So as far as I'm aware the republics of India and Pakistan were created only from the parts of India that Great Britain controlled directly. But then it seems the various monarchies of the subcontinent became part of them very quickly afterwards.
So how were they incorporated into the new republics? Did any of them try to remain independent? If so, was the situation solved peacefully, or did India and/or Pakistan go to war to get them to join?
Also, what happened to the rulers afterwards?
By the time of the partition of India in 1947, there we less princely states compared to when the British Raj was established. During the partition, the Maharaja (ruler of the princely state) was given the decision to join either India or Pakistan.
This decision wasn't so black and white as there were many states where there was a Hindu Ruler and a Muslim majority populace and vice versa. Although India and Pakistan were to be democratic, the final say was left to the Maharaja. Princely states like Mysore peacefully acceded to India and this was general trend. However, states like Hyderabad refused to join India and was actually subsequently annexed by India and forced into a union with them in 1948.
The princely state of Jammu and Kashmir had the most ambiguous status following the partition. Kashmir had a Hindu Maharaja and wished to join India but initially stayed neutral as he wanted to form his own country . However they had a Muslim majority populace and they were geographically more accessible via territory that was in Pakistan. As a result there has been a dispute since the Maharaja died without making his decision official. Following that India blocked a popular vote that would determine that state of Kashmir by its citizens resulting in further tension and unrest in the region. This has been one of the causes of India and Pakistan's hostility towards each other as they both defacto control parts of Kashmir but claim the entirety of the territory.
As for the other princely states, after the formation of India they became regular states within the country with no more less political rights or influence then others.
Edit: The maharaja of Kashmir did not die until 1961 and did sign instrument of ascension that acceded Kashmir to India. However Pakistan viewed this as illegitimate as this was not what the general populace wanted. It should also be noted that the Maharaja did this as Pashtun tribesmen from Pakistan had crossed the boarder into Kashmir and began a guerrilla conflict (whether this was planned by Pakistan is subject to debate). The Maharaja requiring military support to combat them was forced to turn to India who in turn directed him to sign the the instrument of accession before they would send troops to the territory.