To find the mass of each ice cube, we can divide the total mass of the water by the number of ice cubes.
Joanna has a total of 30 grams of water and is making 6 ice cubes.
So, the mass of each ice cube can be calculated as follows:
\[ \text{Mass of each ice cube} = \frac{\text{Total mass of water}}{\text{Number of ice cubes}} = \frac{30 \text{ grams}}{6} = 5 \text{ grams} \]
Therefore, the answer is D. 5 grams.