It seems that since Kakashi and Rin both were cornered by anbu Kakashi probrably thought he was going to die that moment, before dying he killed Rin to prevent the enemy from capturing her.
Of course he was not expecting Obito to come but what I am getting at is that there were two choices Kakashi had
Either die and let Rin get captured or Kill Rin and die along side with her
Though with Obito in the picture, a new outcome was possible which was sparring Kakashi's life AND the capture of Rin
Of course Obito wouldn't kill kakashi as he was morning Rins death and also soon konoha reinforcements arrive.
But did anyone from konoha know kakashi killed Rin? It seemed like some people did, like Gai.
But anyways yea for sure Rin is dead, and no not spy or genjutsu >.>