When you look up "Kraut" in Wikipedia, you'll find the following entry: The German word Kraut when standing alone in English is used most frequently as an ethnic slur against German people. Kraut is also used as an abbreviation for the traditional German and central European food, sauerkraut.
Since World War II, Kraut has, in the English language, come to be used as a derogatory term for a German used mainly by U.S. and British soldiers fighting in Europe. This is probably based on Sauerkraut, which was very popular in German cuisine at that time. The stereotype of the sauerkraut-eating German dates back to long before this time though and can be seen, for example, in Jules Verne's depiction of the evil German industrialist Schultz, an avid sauerkraut eater, in "The Begum's Millions". Ironically, the per capita consumption of kraut in the USA during World War II was significantly higher than in Germany. Now the average per capita consumption is twice as high as in the USA, but still lower than in France.