Desertion is often treated as equivalent to cowardice, treason, and other such things generally considered distasteful. As any anarchist could tell you, treason only makes sense if you feel some kind of loyalty to the nation-state or government or state you’re born into or under. This left-wing market anarchist most certainly doesn’t. As for cowardice, it takes quite a bit of courage to walk away from a cause considered popular or just by the vast majority of people. You’re truly on your own or with few allies in that scenario.
Desertion is an eminently libertarian approach to dealing with an unjust war as a soldier. It would seem that many pro-war conservatives think an individual should continue fighting and killing people unjustly rather than walk away from the battlefield. This is akin to mindlessly obeying orders and committing war crimes in the process. The libertarian and especially the anarchist preferably knows better.
That still leaves the question of desertion from a just war unanswered. It may be morally reprehensible to do so, but that doesn’t mean the behavior should be criminalized. The criminalization of desertion under any circumstances amounts to involuntary servitude. Desertion is another term for quitting your job. Something that the law recognizes in cases of non-military work. No private employer could rightfully conscript you based on the enforcement of a contract alienating your will. The same is preferable in the case of government employment.
Some might object that desertion endangers the other participants in a war, because the fighting strength of the army from which a person is deserting will go down. In the case of an unjust war, this objection has little power to persuade. The soldiers engaged in an illegitimate war don’t have their rights violated by someone refusing to assist them in mass murder. In fact, it is unfortunately true that the lessening of the fighting strength of said army would be a plus. It would mean less people die unjustly. As for the case of desertion in a just conflict, it may be morally wrong, but it’s no legal duty. The notion of a legal duty to serve as part of a military force engenders indentured servitude at best and slavery at worst. No person has an unconditional acontextual legal obligation to help fellow soldiers in even the context of a just war. Let’s work towards ending imperialist wars of aggression, so no one has to decide whether to desert as a matter of justice ever again.