Kagemaru was found under a bridge by a young assassin who was running away from the enemies. He found the 4 years old boy freezing to death, so he brought him to the nearby ninja camp. The boy cried for his mom and dad and soon it became clear that they were murdered right in front of his eyes while he himself managed to hide and run away.
Of course Kagemaru stayed with his rescuers. It was soon discovered that his dad was a martial artist and the one who killed him was one of "the enemies" and when Kagemaru grows up he will "kill them all". The ninjas were very happy about the boy, he was pretty strong and flexible for a 4 years old kid and he willingly joined the training to be a ninja.
The ninja school he joined was a bit eccentric, in a way that it concentrated on espionage and hiding, rather than fighting, and it was even more eccentric in the ways of training. It consisted primarily of boys and young men who were all small, quick and seemingly had no bones at all and, with the black suits on, they didn't even look human but more like some strange-shaped, quickly moving shadows. Kagemaru was in awe, even more so after the kids were asked to demonstrate to the new boy what he's going to be able to do in a few years of training, and even more so after they took their ninja masks off and looked nothing like demons but just like the normal youth from the street.
Because he was properly pre-trained by his dad, Kagemaru succeeded quickly. Because it's essential for any ninja/spy to be completely pain-proof just in case they get caught by the enemies and interrogated, the trainees had to undergo several standard tests before they're allowed to take part in serious ninja missions. These tests were extremely hard and it usually took 8 to 12 years to prepare the body for them, and sometimes even more.
I read somewhere that in real life spies in the army were often trained by sticking needles into their shoulders, so after several months of such training the spy's pain resistance was at the required level. In Kagemaru's school they use extreme stretching instead, since contortion is also very well known for increasing the threshold of pain, but on top of that also allows the ninjas to hide in the most unusual places (and not just behind the curtain like James Bond), which is a definite bonus.
Normally all ninja spies wear black bodysuits, but during the finals they're not allowed to wear anything but fundoshi, so that they couldn't hide sweating. Intense sweating would be the sign of being in pain and that the trainee is still not capable of controlling his body, so in this case he would be sent for another year of training.
It took Kagemaru 3 extra years of training to pass the finals until his body was proven immune to all of the traditional tests. After successfully passing the last test, Kage would have his hair washed and bleached and he would be allowed to grow a nice ponytail, the signs of his awesome skill level and his new rank.