I have a road bike equipped with full Shimano 105 11-speed groupset from top to bottom. The current rear derailleur is RD-5800. Is it ok to replace it with a Deore M5100 Rear derailleur, which is also 11-speed? I only plan to use it as a road bike, maybe some easy gravel ride too. I have a 11-28 teeth cassette. Maybe I will also swap that with 11-30 cassette. Is there anything I need to look out for?
It's not compatible: MTB and road products above 10 speeds have different pull-ratios (ratio between cable movement derailleur displacement), and also because the Deore is designed to be paired with cassettes much larger than cassettes typically found on road bikes.
If your goal is to fit a larger cassette: the medium cage version of the RD-R5800 is compatible with 11/32. The short cage version is however limited to 11/28 cassettes.
The largest cassette that would be compatible is 11/34, with a GRX derailleur (RD-RX810) or a 105 RD-R7000-GS (that is now discontinued, so availability is less guaranteed), but I would only go in that direction if you have the short cage version and need this capability, or if your your rear derailleur is broken. The gain compared to what a medium cage can support is marginal.
You'll also need a slightly longer chain if you install a larger cassette (2 links longer from 11/28 to 11/32).