Joachim Low’s side had not won any of their six fixtures in the competition prior to Saturday’s Group A4 match.
They took the lead when Matthias Ginter stabbed in before Leon Goretzka headed home after an error by goalkeeper Georgiy Bushchan.
A Ruslan Malinovskyi penalty set up a tense finale but Germany held on.
Germany, who did not win a game in their inaugural Nations League campaign two years ago, now have five points from three games in the 2020-21 edition of the competition.
Fans were let in to watch this game after local health authorities allowed the 70,000-capacity Olympic Stadium to be filled by up to 30%.
Chelsea defender Antonio Rudiger, who has not played for the Blues at all this season, impressed during the game and provided the assist for Germany’s opener following a clever run outside the Ukraine defence.
Rudiger’s club team-mates Kai Havertz and Timo Werner started on the bench, coming on towards the end of the game as Germany found themselves under pressure from Ukraine as the hosts pressed for an equaliser.