title: ELK : Attempting to acquire leader lease … metricbeat-cluster-leader: Forbidden
body: <p>I want to monitor my Kubernetes cluster using metricbeat, and I'm using for that metricbeat autodiscover feature . Also I use a custom docker image based on my custom debian bullseye image.</p>
  <p>I made all the necessary configurations : Roles and ClusterRoles.</p>
  <p>The problem is that the autodiscover didn't work and I get this error message :</p>
  <pre><code>E0504 14:41:40.623715       1 leaderelection.go:330] error retrieving resource lock bilalnamespace/metricbeat-cluster-leader: Get &quot;https://10.43.0.1:443/apis/coordination.k8s.io/v1/namespaces/bilalnamespace/leases/metricbeat-cluster-leader&quot;: Forbidden 
  </code></pre>
  <p>Also I tried the official docker image and it works fine.
  I didn't understand what is the problem, do you have any ideas ?</p>
  <p>to deploy on Kubernetes I used the official yaml file.
  <a href="https://raw.githubusercontent.com/elastic/beats/8.1/deploy/kubernetes/metricbeat-kubernetes.yaml" rel="nofollow noreferrer">metricbeat-kubernetes.yam</a></p>