We extend certain basic and general concepts of thermodynamics to discrete Markov systems exchanging work and heat with reservoirs. In this framework we show that the celebrated Clausius inequality can be generalized and becomes an equality, significantly extending several recent results. We further show that achieving zero dissipation in a system implies that detailed balance obtains, and as a consequence there is zero power production. We obtain inequalities for power production under more general circumstances and show that near equilibrium obtaining maximum power production requires dissipation to be of the same order of magnitude.