We study the minimization of a spectral risk measure of the total discounted
cost generated by a Markov Decision Process (MDP) over a finite or infinite
planning horizon. The MDP is assumed to have Borel state and action spaces and
the cost function may be unbounded above. The optimization problem is split
into two minimization problems using an infimum representation for spectral
risk measures. We show that the inner minimization problem can be solved as an
ordinary MDP on an extended state space and give sufficient conditions under
which an optimal policy exists. Regarding the infinite dimensional outer
minimization problem, we prove the existence of a solution and derive an
algorithm for its numerical approximation. Our results include the findings in
B\"auerle and Ott (2011) in the special case that the risk measure is Expected
Shortfall. As an application, we present a dynamic extension of the classical
static optimal reinsurance problem, where an insurance company minimizes its
cost of capital