<p>I am new to kubernetes and trying to create a deployment. So first I created a replicaset named rs.yml shown below.</p>
<pre><code>apiVersion: apps/v1 
kind: ReplicaSet 
metadata:    
  name: web   
  labels:   
    env: dev    
    role: web 
spec:   
  replicas: 4   
  selector:      
    matchLabels:
      role: web   
  template:     
    metadata:
      labels:
        role: web   
    spec:
      containers:
        - name: nginx
          image: nginx
</code></pre>
<p>and applied it using</p>
<blockquote>
<p>kubectl apply -f rs.yml</p>
</blockquote>
<p>now Instead rewriting all this in deployment. I just want to refer this 'rs.yml' file or service inside my deployment.yml file.</p>

Krissh
<p>You can create single YAMl file and add both thing deployment service inside it.</p>
<pre><code>apiVersion: apps/v1 
kind: ReplicaSet 
metadata:    
  name: web   
  labels:   
    env: dev    
    role: web 
spec:   
  replicas: 4   
  selector:      
    matchLabels:
      role: web   
  template:     
    metadata:
      labels:
        role: web   
    spec:
      containers:
        - name: nginx
          image: nginx
---
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
</code></pre>
<p>you can divide the things using the <code>---</code> make the single YAML file.</p>
<p>also, another suggestion don't use the <strong>Replicasets</strong> by default <strong>Deployment</strong> create the <strong>Replicaset</strong> in the background.</p>
<p>You can use the <strong>kind: deployment</strong> can check <code>kubectl get rc</code> still replica set will be there. Deployment creates it in the background and manage it.</p>
