In order to solve the problem of disconnection between manufacturing task decomposition and resource allocation in cloud manufacturing service platform, we proposed a k-means clustering-based algorithm for task decomposition optimization. First, we devise a task preliminary decomposition strategy to decompose the total manufacturing task into meta-tasks that can not be further decomposed. Then, we comprehensively consider the correlation between meta-tasks, task-resource matching, and resource competition to formulate the design principles of task granularity. Finally, we use k-means clustering-based algorithm to reorganize the meta-tasks obtained after the initial decomposition to realize the optimization of task decomposition. Extensive numerical experiments are conducted to verify the effectiveness and feasibility of our algorithm. The results demonstrate that our method could optimize the task decomposition from the two aspects of enhancing the applicability of the method and improving the matching between tasks and resources. Meanwhile, the proposed algorithm can greatly reduce the matching complexity between tasks and resources in the follow-up task processing, and solve the problem of disconnection between task decomposition and resource allocation well.