Been wondering about this for a while. Wikipedia doesn't say much, just don't confuse them with each other.
Adding to /u/snakeskinjim's brief and clear post, here's the etymology of Cossack:
Cossack (n.) 1590s, from Russian kozak, from Turkish kazak "adventurer, guerilla, nomad," from qaz "to wander." The same Turkic root is the source of the people-name Kazakh and the nation of Kazakhstan.
So they share the same root word but they refer to completely different groups. Kazakh came to denote the warlike nomadic Kazakh people and Cossack became used for rebels in Russia much later on in history.
Today's Cossacks are descended from bands of escaped and freed serfs from across Russia. They generally existed near the borders of the Russian Empire, such as in Ukraine. They were afforded special privileges by the Russian Imperial government in exchange for military service and guarding the border of the Empire. Generally, an escaped serf was not allowed to be returned to his master if he managed to join a Cossack host. Cossacks are not so much a distinct ethnic group but do have a distinct culture and history.
Kazakhs are an ethnic group, and unless a Kazakh joined a Cossack host, the two are pretty much separate despite both existing in the Russian Empire.