The cossacks were mostly Slavs who escaped serfdom but for a time they could have been anyone even Jews, Germans or Tatars. Anyone willing to live the free life on the plains.
Cossacks were formed around different Hosts like the Don or most famously Zaporizhan, which were like governments for cossacks with laws to follow, to keep the cossacks from descending in to too much anarchy.