<p>I have a Kubernetes template file that contains multiple temples inside for example:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: logstash-config
  namespace: elastic-foo
data:
  logstash.yml: |
    http.host: &quot;0.0.0.0&quot;
    path.config: /usr/share/logstash/pipeline
  logstash.conf: |
    # all input will come from filebeat, no local logs
    input {
       
    }
    filter {
    
    }
    output {
      
    }
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: logstash-deployment
  namespace: elastic-foo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: logstash
  template:
    metadata:
      labels:
        app: logstash
    spec:
      containers:
      - name: logstash
        image: docker.elastic.co/logstash/logstash:7.10.1
        env:
                       
        ports:
        - containerPort: 5044
        volumeMounts:
          - name: config-volume
            mountPath: /usr/share/logstash/config
          - name: logstash-pipeline-volume
            mountPath: /usr/share/logstash/pipeline
      volumes:
      - name: config-volume
        configMap:
          name: logstash-config
          items:
            - key: logstash.yml
              path: logstash.yml
      - name: logstash-pipeline-volume
        configMap:
          name: logstash-config
          items:
            - key: logstash.conf
              path: logstash.conf
---
kind: Service
apiVersion: v1
metadata:
  name: logstash-service
  namespace: elastic-foo
spec:
  selector:
    app: logstash
  ports:
  - protocol: TCP
    port: 5044
    targetPort: 5044
  type: ClusterIP
</code></pre>
<p>My question is, how can I execute only one template by name
for example :</p>
<pre><code>kubectl create -f Service or Deployment or ConfigMap -f my_config.yml
</code></pre>

<p>That is not a feature of Kubectl. You can split them into different files or pipe through a tool like <code>yq</code> and use <code>kubectl create -f -</code>.</p>
