Given a smooth compact manifold with boundary, we study variational properties of the volume functional and of the area functional of the boundary, restricted to the space of the Riemannian metrics with prescribed curvature. We obtain a sufficient and necessary condition for a metric to be a critical point. As a by-product, a very natural analogue of V-statics metrics is obtained. In the second part, using the Yamabe invariant in the boundary setting, we solve the Kazdan-Warner-Kobayashi problem in a compact manifold with boundary. For several cases, depending on the signal of the Yamabe invariant, we give sufficient and necessary condition for a smooth function to be the scalar or mean curvature of a metric with constraint on the volume or area of the boundary.