<p>I'm trying to accomplish the following:
Create a new service to access the web application using the service-definition-1.yaml file</p>
<pre class="lang-yaml prettyprint-override"><code>  Name: webapp-service
  Type: NodePort
  targetPort: 8080
  port: 8080
  nodePort: 30080
  selector: simple-webapp
</code></pre>
<p>I ran the command</p>
<pre class="lang-sh prettyprint-override"><code>kubectl create service nodeport webapp-service --tcp=8080:8080 --node-port=30080
</code></pre>
<p>and got everything I wanted. However, I have to manually create &amp; edit the  yaml file to add the selector: <code>simple-webapp</code>.</p>
<p>I was curious if I could specify the selectors for a service through the command line?</p>

Parker Shamblin
<p>Try:</p>
<pre><code>kubectl create service nodeport webapp-service --tcp 8080:8080 --node-port 30080 \ 
    --dry-run=client -o yaml | kubectl set selector --local -f - app=simple-webapp -o yaml
</code></pre>
