attaching backup to helm chart but throws pods is forbidden error

5/5/2020

I'm trying attach backup to CouchDB helm chart, but got Crashloopbackoff error. When I check the pod log it says:

pods is forbidden: User "system:serviceaccount:couchdb:n14-couchdb-backup" cannot list resource "pods" in API group "" in the namespace "-l"

after using clusterrole and clusterrole-binding, I got error as

no pods were found in namespace -l by selector

What might be the error? and how to solve it?

My backup-rbac.yaml file

{{- if .Values.backup.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: service-account 
  namespace: couchdb
  labels:

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: 
  namespace: couchdb
  labels:

rules:
- apiGroups: [""]
  resources: ["pods", "pods/log"]
  verbs: ["get", "list"]
- apiGroups: [""]
  resources: ["pods/exec"]
  verbs: ["create"]
- apiGroups: [""]
  resources: ["namespaces"]
  verbs: ["create", "get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: 
  labels:
rules:
- apiGroups: [""]
  resources: ["services", "endpoints", "pods"]
  verbs: ["get", "list", "watch"]
- apiGroups: [""]
  resources: ["secrets"]
  verbs: ["get", "watch", "list"]
- apiGroups: [""]
  resources: ["namespaces"]
  verbs: ["create", "get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: 
  labels:
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: 
subjects:
  - kind: ServiceAccount
    name: service-account
    namespace: couchdb
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: 
  namespace: couchdb
  labels:
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: 
subjects:
- kind: ServiceAccount
  name: service-account
  namespace: couchdb 
{{- end }}
-- Ashwitha
backup
couchdb
kubernetes
kubernetes-cronjob
kubernetes-helm

0 Answers