I have two different YAMLs one for Pod and one for Service. Is it possible to combine them into one YAML but not to use Deployment kind YAML in which I know we can specify both Pod and Service definition but I do not need to worry about replicas etc. Is it possible to combine them together? I haven't find such example/ guidance in documentation.
Thank you.
Yes you can put whatever resources you want in a yaml file, you just need to separate them with three dashes e.g:
apiVersion: apps/v1
kind: Service
---
apiVersion: apps/v1
kind: Pod
What are you intending to do with this yaml file? 'kubectl create'?
You can separate objects by a line of 3 hyphens: '---'.
You can concatenate objects in a single YAML, separating them with ---
Something like:
---
apiVersion: v1
kind: Service
...
---
apiVersion: v1
kind: Pod
...
You may want to create a Deployment first, figuring out what your Pod definition should look like.
Order shouldn't matter, though depending on the client loading it, failure may or may not stop applying the rest of the objects -- kubectl would apply everything it can.