it's possible to create one deployment with four pods, each pod is identical to each other except the memory limit of their containers.
If it can be done, how is the yaml file look like.
This is not possible with a single deployment.
You can reach a similar effect by creating multiple deployments.
A deployment specifies the template of a single Pod. You cannot define multiple Pods in a single deployment