<p>I have a Kubernetes namespace with limited privileges which excludes the creation of <code>ClusterRole</code> and <code>ClusterRoleBinding</code>.
I want to monitor the resource consumption and pod-related metrics on the namespace level.</p>
<p>E.g., pod health and status, new pod creation, pod restarts, etc.</p>
<p>Although I can create an application-level metrics endpoint for custom metrics by exposing <code>/metrics</code> and adding the annotation <code>prometheus.io/scrape: 'true'</code>.</p>
<p>But is there a way to get <code>resource consumption and pod-related metrics</code> on the namespace level without <code>Cluster Role</code> and <code>ClusterRoleBinding</code>?</p>

<p>It is possible to get namespace level entities from kube-state-metrics.</p>
<ol>
<li><p>Pull the helm chart for kube-state-metrics:
<a href="https://bitnami.com/stack/kube-state-metrics/helm" rel="nofollow noreferrer">https://bitnami.com/stack/kube-state-metrics/helm</a></p>
</li>
<li><p>Edit the values.yaml file and make the following changes:</p>
<pre><code>       rbac:
           create: false
           useClusterRole: false
         collectors:
           - configmaps
           - cronjobs
           - daemonsets
           - deployments
           - endpoints
           - horizontalpodautoscalers
           - ingresses
           - jobs
           - limitranges
           - networkpolicies
           - poddisruptionbudgets
           - pods
           - replicasets
           - resourcequotas
           - services
           - statefulsets
         namespace: &lt;current-namespace&gt;
</code></pre>
</li>
<li><p>In the prometheus ConfigMap, add a job with the following configurations:</p>
<pre><code> - job_name: 'kube-state-metrics'
     scrape_interval: 1s
     scrape_timeout: 500ms
     static_configs:
          - targets: ['{{ .Values.kube_state_metrics.service.name }}:8080']
</code></pre>
</li>
<li><p>Create a role binding:</p>
<pre><code>     apiVersion: rbac.authorization.k8s.io/v1
     kind: RoleBinding
     metadata:
       name: kube-state-metrics
       namespace: &lt;current-namespace&gt;
     roleRef:
       apiGroup: rbac.authorization.k8s.io
       kind: ClusterRole
       name: view
     subjects:
       - kind: ServiceAccount
         name: kube-state-metrics
     namespace: &lt;current-namespace&gt;
</code></pre>
</li>
</ol>
