Bayern's captain was sent off before half-time, but Vincent Kompany's patched-up side held on to keep their unbeaten Bundesliga record.