Allegiance is literally where you belong. This is incredibly important in a medieval world, and everyone always knew where he belonged to. You were never "Richard", you were "Richard of Ubent" (or from Ubent, if you were a commoner).
There are multiple layers of allegiance:
At the top of the hierarchy is the ruler. The ruler only belongs to a duchy if he is a duke. Dukes swear fealty to the ruler. Dukes can be lords of a region within their duchy, but this is not required, and dukes cannot be lord of a region in another duchy. Region lords swear fealty a duke. Region lords can take an estate in their region, but this is not required, and lords cannot have an estate in a region other than their own. Knights occupy an estate.
These layers are also an indication of your status within the feudal society. The sooner you can say "I don't owe them allegiance, they owe me", the higher you are. Only the ruler can claim that the realm belongs to him and not he to the realm, but a lord (who owns a region instead of being owned by one) is higher than a knight (who only owes allegiance and is owed none).
In a feudal society, allegiance is tied in closely with Oaths. Your allegiance does not come free (unless you are a commoner, in which case you are inventory and belong to the region anyway).
In a true medieval society, the oaths and allegiances binding the society together could get arbitrarily complex. In BattleMaster, we simplify things a little. The deal is: Service for Money.
Every level of allegiance can contain a benefit. Most often, only the lowest level will. For most knights, their belonging to a specific region (and thus oweing service to its lords, whoever he may be at that time) is in return for receiving a part of the regions tax income by claiming an estate in that region. The size of the estate, and thus the income earned, is controlled by the lord.
It is possible to change your allegiance. The main disadvantage is that doing so also means losing all advantages your old allegiance had given you.
The basic principles of allegiance changes are:
- Everyone changes on his level
- Everything below follows
So a knight will change his region, not his duchy or realm - any changes to duchy and/or realm follow from the region he joins. If he signs up with a lord of another realm, then yes his realm will change, too.
A lord always changes his duchy, taking his region and all troops and knights with him. Again, if that duchy happens to be in another realm, then everyone changes realm as well.
A duke always changes his realm, again taking all regions, troops and knights within his duchy with him.
There are a few exceptions to these rules, but these are the basic rules.