South Africa has deployed troops to the streets of the country's biggest city to help police fight gang violence and illegal mining.