I have 3 micro service applications, which shall be deployed in K8s. Do I need to create 3 deployment files and 3 service files for this or to concatenate all 3 deployments to a single file (as well as services) ?
You should create deployment and service definition YAMLs for each service and deploy them seperately.
You can also include all deployment and service defitions in one YAML file and deploy all in one go.
I have all of the separated, one file per deployment, service, ingress, etc..., one file per entity. I think that if you are developing in a cluster is better to have all of them separated is easier to versioning, updates and handle them with scripts/tools.
I have a lab/test/blog cluster online that is opensource, here is the main repository: https://github.com/vicjicaman/microservice-realm
You can see here how I have all the entities separated, I hope that this could be helpful you as a reference case.
You did not provide information about thoses microservices.
You can do it in one file, however the Best Practise is to have each Applicataion
/ Microservice
in separate Deployments.
Currently it might be only 3 microservices
but in the future you may consider adding new features and new microservices
will be needed.
If you have each microservice
in different deployment
You will be able to make fast configuration changes, without scrolling many rows of YAML code (less likely that you will make a syntax mistake inside the file). It will easier to troubleshoot specific microservices
and manage traffic between them - you can use Istio to do that.
As each microservice will be in different deployment
you will have more versatility as you will be able to create some initContainers or there will be need to use Horizontal Pod Autoscaler.
In addition you don't need to limit only to Deployments
. You can also use StatefulSets for specific applications (i.e apps which requiring Databases).
You also can create your own Helm chart which allow you to deploy application using one command but have all deployments organized in directories.