Question: Is there any way to add labels in .spec.template after a deployment has been created? So, I know this can be done 

`kubectl label deployment myDeployment myLabelKey=myLabelValue`

But this would only add the label to `.metadata.labels`. I would like to add a label to `.spec.template.metadata.labels`.

Answer: 
This should be possible using the [`kubectl patch`](https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/) command. The following patch file would add a new label to the `spec.template.metadata.labels` property:

```
spec:
  template:
    metadata:
      labels:
        myLabelKey: myLabelValue

```

Then apply with:

```
$ kubectl patch deployment myDeployment --patch "$(cat patchfile.yaml)" 

```

Alternatively, with inline JSON instead of a separate file:

```
$ kubectl patch deployment myDeployment --patch '{"spec": {"template": {"metadata": {"labels": {"myLabelKey": "myLabelValue"}}}}}'

```
the solution by @helmbert is correct but it's missing double quotes after myLabelValue.

```html
$ kubectl patch deployment myDeployment --patch '{"spec": {"template": {"metadata": {"labels": {"myLabelKey": "myLabelValue"}}}}}'
```