K-Means takes in an unlabeled data set and a whole real number, k. K is the number of centroids, or clusters you wish to find. If you do not know how many clusters there should be, it is possible to do some pre-processing to find that more automatically, however that is out of the scope of this article. Once you have a data set and defined the size of k, K-Means begins its iterative process. It starts by selecting centroids by moving them to the average of the data associated with them. It then reshuffles all of the data into new groups based on the proximity to each centroid.
This is a big and detailed post, and worth reading in its totality.