This is, at least to a certain extend, a similar situation as during the Cuban Missile Crisis. How would the USA react today - or maybe better fifteen years ago to ignore the effects of the Ukraine conflict - to an Russian attempt to have missiles in Cuba? Would we believe that it is purely for defensive reasons?
This might have been avoidable, while it is impossible that both parties get what they desire, there might have been a compromise. Now with the war this probably becomes much harder, Ukraine has more reasons for a NATO membership, Russia has more reasons not to want Ukraine in the NATO.
Now the question is whether Ukraine has a chance to win the war. If they do not, it would probably really be the best option to just surrender. But judging the chances of that seems really hard at the moment because it depends on the amount of support from the west, the effects of the sanctions and the reaction of the Russian population, on China's position, on the kind of war that Russia is willing to fight, ...