It was established that a Maester is appointed to a certain castle or stronghold and serves there for life, no matter if it changes hands, they always stay loyal to the actual location.
Do they swear oaths?
Was wondering because Cressen was the Maester of Storm's End but followed Stannis to Dragonstone.
How do Maesters get selected?
Did Renly (or Penrose) need to pull out the Maester Catalogue 283 and order a new Maester?
Or let's say Harrenhal needs a new Maester. Is there a room in the Citadel where all the Measters are gathered, they draw straws and everyone crosses fingers, hoping that they are not appointed to a cursed castle for life?