<p><code>kubectl</code> I am looking for a single command or maybe combination of commands for the following yaml file </p>

<pre><code>---
#
# Create a role, `pod-reader`, that can list pods and
# bind the default service account in the `mynamespace` namespace
# to that role.
#

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: pod-reader
  namespace: mynamespace
rules:
- apiGroups: [""] # "" indicates the core API group
  resources: ["pods"]
  verbs: ["get", "watch", "list"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: read-pods
  namespace: mynamespace
subjects:
- kind: Group
  name: system:serviceaccounts:mynamespace
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io
</code></pre>

<p>So pretty much create a namespace that can get, watch and list pods</p>

<p>This assumes the namespace and service account are already created:</p>

<pre><code>$ kubectl create namespace mynamespace

$ kubectl create serviceaccount mysa -n mynamespace
</code></pre>

<p>Create the role with:</p>

<pre><code>$ kubectl create role pod-reader --namespace=mynamespace \
    --verb=get,list,watch \
    --resource=pods \
</code></pre>

<p>Create the rolebinding with:</p>

<pre><code>$ kubectl create rolebinding read-pods --namespace=mynamespace \
    --role=pod-reader \
    --group=system:serviceaccounts:mynamespace
</code></pre>

<p>Tip: if you want to preview the generated YAML rather than actually creating the resource, append <code>--dry-run=true -o=yaml</code> to the commands.</p>
