A covered pergola is a great way to block the sun. However, they are not built for complete protection from the rain.
There are a variety of ways that a pergola can provide shade. This can be by training climbing plants over it, such as wisteria or evergreen climbers. A slated roof will provide dappled shade, or sail type blind fittings can be added to the roof section to provide more consistent shade. These type of shades can sometimes be attached to runners so that they can be drawn back when the area of the pergola is not in the sun, to allow more light into the area. This is especially useful if it is to be used for dining.