Whenever the governing body shall deem it advisable, a municipality owning and operating its own electric lighting system or waterworks may enter into contracts with persons, corporations, or limited liability companies maintaining manufacturing plants, residences, or other buildings outside of the municipal limits, to furnish such plants or buildings with electricity or water if it can be furnished from the surplus remaining after supplying the needs of the municipality and its inhabitants.